using Core.Mes.Client.Comm.Control; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.Data; using System.Drawing; namespace Core.StlMes.Client.Qcm { /// /// 已被弃用。 /// public class FrmBaseQcm : FrmBase { public DtBaseQcm _dtBaseQcm = null; /// /// 用于其他界面引用的时候,调用加载方法。 /// public void QcmLoad() { base.OnLoad(EventArgs.Empty); } public override void ToolBar_Click(object sender, string ToolbarKey) { bool actionResult = false; base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": _dtBaseQcm.DoQuery("DefaultQuery"); break; case "Add": BeginDoAction(ActionType.Add); actionResult = _dtBaseQcm.DoAction(ActionType.Add); if (actionResult == true) { SuccessDoAction(ActionType.Add); } break; case "Save": BeginDoAction(ActionType.Save); actionResult = _dtBaseQcm.DoAction(ActionType.Save); if (actionResult == true) { SuccessDoAction(ActionType.Save); } break; case "Modify": BeginDoAction(ActionType.Modify); actionResult = _dtBaseQcm.DoAction(ActionType.Modify); if (actionResult == true) { SuccessDoAction(ActionType.Modify); } break; case "Audit": BeginDoAction(ActionType.Audit); actionResult = _dtBaseQcm.DoAction(ActionType.Audit); if (actionResult == true) { SuccessDoAction(ActionType.Audit); } break; case "Delete": BeginDoAction(ActionType.Delete); actionResult = _dtBaseQcm.DoAction(ActionType.Delete); if (actionResult == true) { SuccessDoAction(ActionType.Delete); } break; case "Resume": BeginDoAction(ActionType.Resume); actionResult = _dtBaseQcm.DoAction(ActionType.Resume); if (actionResult == true) { SuccessDoAction(ActionType.Resume); } break; case "Refresh": LoadBaseInfo(); break; case "Close": this.Close(); break; } } /// /// 开始执行非查询时所要调用的方法 /// /// 非查询类型 protected virtual void BeginDoAction(ActionType actionType) { } /// /// 执行非查询成功时所要调用的方法 /// /// 非查询类型 protected virtual void SuccessDoAction(ActionType actionType) { } /// /// 加载基础信息 /// protected virtual void LoadBaseInfo() { } public void SetDeleteColor(InitializeRowEventArgs e, string strDeleteKey, string strDeleteValue) { if (e.Row.Cells[strDeleteKey].Value.ToString() == strDeleteValue) { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } public void ControlGridSelectEdit(InitializeRowEventArgs e, List listNoEdit, List listDrop, string CkbKey) { if (e.Row.Cells[CkbKey].Value.ToString() == "True") { foreach (UltraGridCell cell in e.Row.Cells) { if (cell.Column.Header.Caption == "选择") continue; if (listNoEdit.Contains(cell.Column.Header.Caption)) { cell.Activation = Activation.ActivateOnly; } else if (listDrop.Contains(cell.Column.Header.Caption)) { cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; cell.Activation = Activation.AllowEdit; } else { cell.Activation = Activation.AllowEdit; } } } else { foreach (UltraGridCell cell in e.Row.Cells) { if (cell.Column.Header.Caption == "选择") continue; if (listDrop.Contains(cell.Column.Header.Caption)) { cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; cell.Activation = Activation.ActivateOnly; } else { cell.Activation = Activation.ActivateOnly; } } } } public void SetGridRowActiveWithKey(UltraGrid grid, string key, string value) { UltraGridRow[] rows = GridHelper.GetRowsWithKey(grid, new string[] { key }, new string[] { value }); if (rows.Length > 0) { rows[0].Activate(); } } public void SetGridRowActiveWithKey(UltraGrid grid, string key, string createNameKey, string createTimeKey) { DataTable dt = ((DataSet)grid.DataSource).Tables[grid.DataMember]; DataRow[] drs = dt.Select(createNameKey + "= '" + UserInfo.GetUserName() + "'", createTimeKey + " DESC"); if (drs.Length > 0) { string value = drs[0][key].ToString(); SetGridRowActiveWithKey(grid, key, value); } } } }