using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Tile; using DeviceRepair.Models; using DeviceRepair.Models.Enum; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Windows.Forms; using TsSFCDevice.Client.Biz.Base.Utils; using TsSFCDevice.Client.Biz.Impl; using TsSFCDevice.Client.Launch.Preserve; namespace TsSFCDevice.Client.Launch { public partial class page_PlanDialog : Form { public List Datas { get; set; } public page_PlanDialog() { SetStyle(ControlStyles.UserPaint, true); InitializeComponent(); } /// /// 程序加载 /// /// /// private void page_PlanDialog_Load(object sender, EventArgs e) { DataBind(); if (Datas == null || Datas.Count == 0) this.Close(); gridControl1.DataSource = Datas; } void DataBind() { #region 数据库处理 IList lst = PlanRepository.Instance.Get_PM_PLAN_CurrentMonth(); Datas = lst.ToList(); #endregion //如果tips数据为空则跳过 if (lst == null || lst.Count == 0) this.DialogResult = DialogResult.OK; gridControl1.DataSource = Datas; } private void btn_Ignore_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; this.Close(); } private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) { Rectangle tang = this.ClientRectangle; //获取窗口矩形 为了下面得到窗口的宽高 Graphics g3 = e.Graphics; //新建一个画布 Color c3 = Color.FromArgb(183, 183, 183); //声明一个 颜色 Pen p3 = new Pen(c3); //新建一支画笔 g3.SmoothingMode = SmoothingMode.HighQuality; //抗锯齿 使得线条变柔顺 在画斜线或者曲线的时候使用 g3.InterpolationMode = InterpolationMode.HighQualityBicubic; //使得画出来的效果高质量 g3.CompositingQuality = CompositingQuality.HighQuality; //高质量画图 g3.DrawLine(p3, 0, 0, 0, tang.Height - 1); //在(0,0)和(tang.Width - 1, 0)这两点间画一条直线 g3.DrawLine(p3, 0, tang.Height - 1, tang.Width - 1, tang.Height - 1); //注意必须减1 不然显示不出来 因为 如果假设窗口的高度是3像素 我们知道(0,0)位置代表 窗口最左上角的像素点 那么最左下角的像素点应该是(0,2) 而不是(0,3) 因为0,1,2 已经三个像素点了 g3.DrawLine(p3, tang.Width - 1, tang.Height - 1, tang.Width - 1, 0); g3.DrawLine(p3, tang.Width - 1, 0, 0, 0); //操作栏 上 边框线 g3.DrawLine(p3, tang.Width - 1, tableLayoutPanel1.Height - 60, 0, tableLayoutPanel1.Height - 60); //上 } /// /// 标题栏 - 鼠标拖动 /// /// /// private void lb_Caption_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Win32ApiHelper.ReleaseCapture(); Win32ApiHelper.PostMessage((int)this.Handle, 0x0112, 0xf017, 0); } } private void simpleButton1_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; this.Close(); } private void tileView1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e) { switch (e.Item.Name) { //忽略一条数据 case "btn_Igore": ItemIgore((TileViewItem)e.DataItem); break; //保养一条数据 case "btn_Maintenance": ItemMaintenence((TileViewItem)e.DataItem); break; default: break; } } /// /// 忽略该条保修集合 /// /// void ItemIgore(TileViewItem item) { int handle = item.RowHandle; View_CurrentMonthPlanTips dmp = (View_CurrentMonthPlanTips)tileView1.GetRow(handle); Datas.Remove(dmp); if (Datas.Count == 0) { DialogResult = DialogResult.OK; this.Close(); } tileView1.RefreshData(); gridControl1.RefreshDataSource(); } /// /// 保养一条数据 /// /// void ItemMaintenence(TileViewItem item) { try { if (!Utility.SystemRuntimeInfo.AuthValidate(OperationAuthConstValue.PM_PRESERVE_Add)) { throw new Exception($"当前账号缺少此操作的权限"); } int handle = item.RowHandle; View_CurrentMonthPlanTips dmp = (View_CurrentMonthPlanTips)tileView1.GetRow(handle); /* 保养类型 */ EnumDeviceBelong Belong = dmp.MaintenanceType.Equals("Daily", StringComparison.OrdinalIgnoreCase) ? EnumDeviceBelong.AM : EnumDeviceBelong.PM; if (dmp != null) { this.Hide(); //获取设备信息 DeviceInformationInfo entity = Utility.SystemRuntimeInfo.CurrentDeviceCaches.FirstOrDefault(x => x.EquipmentID.Equals(dmp.EquipmentID, StringComparison.CurrentCultureIgnoreCase)); if (entity == null || (Belong == EnumDeviceBelong.AM ? entity.MaintenanceAMFormVersion : entity.MaintenanceFormVersion) == 0) { XtraMessageBoxHelper.Error("该设备未绑定点检表,请先绑定点检表。"); this.Show(); return; } page_DriveMaintenance view = new page_DriveMaintenance(entity, Belong, dmp.AutoID); if (dmp.MaintenanceType == EnumMaintenanceType.Daily.ToString()) { view.DaylyMaintenanceDate = DateTime.Today; } DialogResult dr = view.ShowDialog(this); if (dr == DialogResult.OK) { ItemIgore(item); XtraMessageBoxHelper.Info("操作成功!"); } else if (dr == DialogResult.Abort) { XtraMessageBoxHelper.Info(view.apiResponseData.Message); } this.Show(); } else { XtraMessageBoxHelper.Error("未能获取到设备信息,请重试。"); this.Show(); } } catch (Exception ex) { XtraMessageBoxHelper.Error(ex.Message); this.Show(); } } } }