using DevExpress.XtraEditors; using DevExpress.XtraGrid.Columns; using DevExpress.XtraGrid.Views.Grid; using Lskj.Business; using Lskj.Business.Impl; using Lskj.Control; using Lskj.Control.Model; using Lskj.Core; using Lskj.Data; using Lskj.Model; using Lskj.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.ProductBarCode { public partial class FrmMain : BaseForm { /// /// 左侧树数据 /// public DataRow LeftRowObj; /// /// 主键名 /// private string _primaryLeftKey; /// /// 表格对象 /// /// The grid view object. public GridControlEx GridControlObj { get { return this.moduleGridEx.GridControlObj; } } /// /// 必须录入字段 /// private DataRow[] _nullFields = new DataRow[] { }; /// /// 基础模型 /// public ModuleModel MoudleObj; /// /// 底部基础模型 /// public ModuleModel MoudleBottomObj; /// /// 表格明细集合 /// public List GridDetailModelObjs; /// /// 控件源数据 /// private DataTable _dtFields; /// /// 单据信息 /// private DataRow _drBillInfo; /// /// 单据模型 /// public BillModel BillModelObj; public DynamicBarCodeModel SysModel; public DynamicModuleModel dmoudelModel; /// /// 单表模型 /// public DynamicModuleModel moudelModel; /// /// 控件对象 /// public MyControl ControlObj { get; private set; } /// /// 控件高度 /// /// The height of the control. public int ControlHeight { get; private set; } /// /// 控件数据源 /// private DataTable _controlTable; /// /// 单据明细列 /// private DataTable _detailColumns; /// /// 单据关联字段 /// public string BillRelation; /// /// 单据明细id /// public int MxId; /// /// 设置红蓝单据 /// public string BillStatus; /// /// 设置是否有操作权限 /// public bool Ispower = true; /// /// 单据名称 /// public string typename; /// /// 左侧表格查询条件 /// private MyControl _leftGridSearchObj; /// /// 是否为初始化创建 /// private bool _isInitFinish; public FrmMain() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { try { //WaitForm.ShowForm(); //this.SysModel.Privilege = SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + ""; //if (!this.SysModel.HasPrivilege()) //{ // MessageUtil.Show(ResourceKeys.UnPurview); // this.Close(); //} //else //{ this._isInitFinish = false; SetInterfaceState();//设置界面状态 SetLeftGridView(); InitializeSetting(); InitControls(); SelectSettingsRows();//设置左侧选中行 //HideControls(); //} this.InitlizeSpiltLocation(); this.splitRightControl.SplitterMoved += SplitRightControl_SplitterMoved; this.splitMainControl.SplitterMoved += SplitMainControl_SplitterMoved; } catch (Exception ex) { LogHelper.Instance.WriteError(ex); //MessageUtil.Show(ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); WaitForm.HideForm(); this._isInitFinish = true; } } /// /// 初始化分割条位置 /// private void InitlizeSpiltLocation() { string MainPosition = IniHelper.Read(string.Format("ProductBarCode_Main_{0}", this.SysModel.ModuleCode)); if (!string.IsNullOrEmpty(MainPosition)) this.splitMainControl.SplitterPosition = Convert.ToInt32(MainPosition); string RightPosition = IniHelper.Read(string.Format("ProductBarCode_Right_{0}", this.SysModel.ModuleCode)); if (!string.IsNullOrEmpty(RightPosition)) this.splitRightControl.SplitterPosition = Convert.ToInt32(RightPosition); } private void SplitMainControl_SplitterMoved(object sender, EventArgs e) { if (this._isInitFinish)// 是否为初始化创建 { IniHelper.Write(string.Format("ProductBarCode_Main_{0}", this.SysModel.ModuleCode), this.splitMainControl.SplitterPosition + ""); } } private void SplitRightControl_SplitterMoved(object sender, EventArgs e) { if (this._isInitFinish)// 是否为初始化创建 { IniHelper.Write(string.Format("ProductBarCode_Right_{0}", this.SysModel.ModuleCode), this.splitRightControl.SplitterPosition + ""); } } /// /// 说明:判断是否终审,加载界面是否可以编辑 /// 创建人:龚宇超 /// 创建日期:2017-10-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// protected void SetInterfaceState() { try { this.BillModelObj = new BillAuditModel(BillImpl.GetBillInfo(this.SysModel.ModuleCode)); this.BillModelObj.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.MasterTable); this.BillModelObj.DetailPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.DetailTable); DataRow rowItem = SqlHelper.ExecuteDataTable(string.Format("SELECT * FROM {2} WHERE {0}='{1}'", this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId, this.BillModelObj.MasterTable)).Rows[0]; if (("1".Equals(rowItem[this.BillModelObj.MasterPreFix + "stepover"] + "") || "true".Equals((rowItem[this.BillModelObj.MasterPreFix + "stepover"] + "").ToLower()))) { this.but_CreatBarCode.Enabled = false; this.Ispower = false; } } catch (Exception) { throw; } } /// /// 说明:设置左侧表格数据 /// 创建人:龚宇超 /// 创建日期:2017-10-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// protected void SetLeftGridView() { this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.SysModel.MoudelId); if (this.LeftRowObj != null) { DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(this.SysModel.MoudelId); DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + ""); this.moduleGridEx.ParentKeyField = this.LeftRowObj["fieldsqlid"] + ""; this.moduleGridEx.ParentUnionField = this.LeftRowObj["fieldname"] + ""; BillRelation = "{" + this.LeftRowObj["fieldsqlname"] + "}"; this.gcLeft.GridView.FocusedRowObjectChanged += OnGridViewRowClick; this.gcLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick); this.gcLeft.SetGridRowColors(dtColorTable); this.gcLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + this.SysModel.MoudelId); this.gcBottom.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick); //this.SetLeftGridCondtion(); } typename = SqlHelper.ExecuteScalar(string.Format("select replace(typename,'单','') as typename from p_systembilltype where typecode='{0}'", this.SysModel.ModuleCode)) + ""; } #region 初始化属性 /// /// 说明:初始化属性设置 /// 创建人:龚宇超 /// 创建日期:2018-02-27 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeSetting() { this.GridControlObj.Tag = "IsOldPost"; this.moudelModel = new DynamicModuleModel(new string[] { "0", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", this.SysModel.MoudelId + "", "0" }); this.MoudleObj = new ModuleModel(MainImpl.GetSystemdllTab(this.moudelModel.ModuleCode)); //初始表头 this.ControlObj = new MyControl(); this.ControlObj = new MyControl(this.MoudleObj.MenuSql, null); this.ControlObj.OnDataSourceBindCallBack+=OnDataSourceBindCallBack; this.GridDetailModelObjs = GetDetailGrids(); string UnionModule = this.GridDetailModelObjs.Count > 0 ? this.GridDetailModelObjs[0].UnionModule : string.Empty; if (!string.IsNullOrEmpty(UnionModule)) { DynamicModuleModel dmoudelModel = new DynamicModuleModel(new string[] { "0", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", UnionModule + "", "0" }); this.MoudleBottomObj = new ModuleModel(MainImpl.GetSystemdllTab(dmoudelModel.ModuleCode)); DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(UnionModule); this.gcBottom.Model = dmoudelModel; this.gcBottom.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleBottomObj.FormKey); if (Ispower) { this.gcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(dmoudelModel.ModuleCode), dmoudelModel, OnGridViewRightCallBack, this.ControlObj, null); } if (this.MoudleBottomObj.GridObjIsCheck == 1)//主表加载复选框 { GridDragGrid.GridAddCheckBox(this.gcBottom.GridView); } } this._dtFields = BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.moudelModel.ModuleCode); } /// /// 数据绑定完成后触发事件 /// /// /// private void OnDataSourceBindCallBack(object sender, EventArgs e) { DataRow rowArray = this.gcLeft.GetViewFocusedDataRow(); SetCodeHeader(rowArray); } #endregion #region 初始化属性 /// /// 说明:隐藏搜索 /// 创建人:王一帆 /// 创建日期:2020-01-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void HideControls() { foreach (System.Windows.Forms.Control control in this.pl_top_main.Controls) { if (control is SimpleButton) { SimpleButton simpleButton = control as SimpleButton; simpleButton.Visible = false; } } } #endregion #region 获取明细 /// /// 说明:获取报表明细 /// 创建人:龚宇超 /// 创建日期:2018-02-27 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private List GetDetailGrids() { List details = new List(); DataTable moduleDetailBottomTable = BaseModuleImpl.GetBaseDetailPages(this.moudelModel.ModuleCode); if (moduleDetailBottomTable.Rows.Count == 0) { moduleDetailBottomTable = BaseModuleImpl.GetBaseAddTabDetail(this.moudelModel.ModuleCode); } foreach (DataRow item in moduleDetailBottomTable.Rows) { DataTable dtGridColumns = ReportImpl.GetReportDetailColumns(this.moudelModel.ModuleCode, item["id"] + ""); details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.BaseDetailGridView)); } return details; } #endregion /// /// 创建条码控件 /// private void InitControls() { this._drBillInfo = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId); BillStatus = _drBillInfo[this.BillModelObj.RtagidKey] + ""; this._controlTable = BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.moudelModel.ModuleCode); this.ControlObj.InitControl(this._controlTable, this.pl_top_main, BaseModuleImpl.GetAddGroupData(this.MoudleObj.FormKey)); this.ControlObj.SetReadOnlyAllControl(false); this.moduleGridEx.VisibleSearchPanel = false; this.gcLeft.Model = this.SysModel; this.gcLeft.ParentControl = this.ControlObj; this.moduleGridEx.InitializeControl(this.MoudleObj, moudelModel); _detailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode); this.moduleGridEx.LeftGridEx = this.gcLeft; this.moduleGridEx.ParentGridEx = this.gcLeft; // 方便右侧添加数据自动带出相同字段值 this.moduleGridEx.AfterDeleteGridCallBack += ModuleGridExAfterDeleteGridCallBack;//点击删除后刷新上下表数据源 DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.moudelModel.ModuleCode); this.GridControlObj.SetEditColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleObj.FormKey); this.GridControlObj.Model = this.moudelModel; string detailSql = ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql + " " + SysModel.LeftCondition, this.SysModel.BillDocumentId); if (this.LeftRowObj != null) { DataTable table = BaseModuleImpl.GetCustomQueryFields(this.LeftRowObj["fieldKey"] + ""); string searchSql = detailSql + " "; if (table != null && table.Rows.Count > 0) { // 自定义查询条件 this._leftGridSearchObj = new MyControl(searchSql, this.gcLeft); // this._leftGridSearchObj.OtherParams = Model.OtherParams(); this.pl_left_top.Height = this._leftGridSearchObj.InitSearchControl(table, this.pl_left_top); this._leftGridSearchObj.OnDataSourceBindCallBack += new EventHandler(OnLeftControlObjDataSourceBindCallBack); } else { this.pl_left_top.Visible = false; this.gcLeft.SetGridViewDataSource(BaseImpl.GetDataTableResult(detailSql)); } } else { this.gcLeft.SetGridViewDataSource(BaseImpl.GetDataTableResult(detailSql)); } if (Ispower) { this.GridControlObj.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.moudelModel.ModuleCode), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null); } if (!(this.SysModel.isRedFlag.Equals("1"))) { if ("0".Equals(BillStatus)) { this.splitRightControl.PanelVisibility = SplitPanelVisibility.Panel1; } else { this.pl_top_main.Visible = false; this.but_CreatBarCode.Visible = false; } } else { if ("1".Equals(BillStatus)) { this.splitRightControl.PanelVisibility = SplitPanelVisibility.Panel1; } //else //{ // this.pl_top_main.Visible = false; // this.but_CreatBarCode.Visible = false; //} } if (this.SysModel.isVisibelFlag.Equals("1")) { this.pl_top.Visible = false; this.but_CreatBarCode.Visible = false; } this.moduleGridEx.GridControlObj.OnParseGridDataCallBack += new GridControlEx.ParseGridDataEventHandler(OnGridViewParseGridDataCallBack); } /// /// 说明:粘贴表格后更新树结构关联字段 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The row item. protected void OnGridViewParseGridDataCallBack(DataRow rowItem) { if (rowItem != null && rowItem.Table.Columns.Contains(this.moduleGridEx.ParentKeyField)) { if (this.gcLeft != null) { rowItem[this.moduleGridEx.ParentKeyField] = this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + ""; } } else { if (this.gcLeft != null) { DataTable table = moduleGridEx.GridControlObj.GridView.GridControl.DataSourceTable(); moduleGridEx.GridControlObj.GridView.SetRowCellValue(this.moduleGridEx.GridControlObj.GridView.GetFocusedDataSourceRowIndex(), this.moduleGridEx.ParentUnionField, this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + ""); //rowItem[this.moduleGridEx.ParentUnionField] = this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + ""; } } } #region 修改表头 /// /// 说明:获取配置条件头属性设置 /// 创建人:王一帆 /// 创建日期:2021-09-07 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// System.String. private void SetCodeHeader(DataRow newRow) { StringBuilder updateBuilder = new StringBuilder(); foreach (ControlModel model in this.ControlObj.ControlModels) { if (!string.IsNullOrEmpty(model.DefaultValue)) { bool isStart = model.DefaultValue.StartsWith("{"); string fieldName = model.DefaultValue.Replace("{", "").Replace("}", ""); if (newRow!=null&&newRow.Table.Columns.Contains(fieldName)) { this.ControlObj.SetControlValue(model.FieldName, newRow[fieldName] + ""); } else { this.ControlObj.SetControlValue(model.FieldName, isStart ? string.Empty : model.DefaultValue); } } } } #endregion /// /// 说明:条码点击加载详细条码 /// 创建人:王一帆 /// 创建日期:2020-01-07 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. private void OnGridViewRowClick(object sender, EventArgs e) { try { DataRow rowArray = this.gcLeft.GetViewFocusedDataRow(); if (!string.IsNullOrWhiteSpace(SysModel.DefaultEnabled) && rowArray.Table.Columns.Contains(SysModel.DefaultEnabled)) { string varlue = rowArray[SysModel.DefaultEnabled] + ""; if (varlue.Equals("0")) { this.but_CreatBarCode.Enabled = true; this.Ispower = true; this.gcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.gcBottom.Model.ModuleCode), this.gcBottom.Model, OnGridViewRightCallBack, this.ControlObj, null); this.GridControlObj.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.moudelModel.ModuleCode), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null); } else if (varlue.Equals("1")) { this.but_CreatBarCode.Enabled = false; this.Ispower = false; this.gcBottom.SetGridRightMenus(new DataTable(), this.gcBottom.Model, OnGridViewRightCallBack, this.ControlObj, null); this.GridControlObj.SetGridRightMenus(new DataTable(), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null); } } SetCodeHeader(rowArray); string detailSql = ReplaceHelper.ReplaceRowParam(rowArray, this.MoudleObj.MenuSql); string BatchBarCodeViewSql = ReplaceHelper.ReplaceRowParam(rowArray, this.MoudleBottomObj.MenuSql); BatchBarCodeViewSql = ReplaceHelper.ReplaceRowParam(_drBillInfo, BatchBarCodeViewSql); this.GridControlObj.LastSearchSql = detailSql; this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); //this.moduleGridEx.OnDelCallBack += OnDelCallBackEven; this.gcBottom.LastSearchSql = BatchBarCodeViewSql; this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 说明:删除主程序后刷新所有界面 /// 创建人:王一帆 /// 创建日期:2020-01-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnDelCallBackEven(object sender, EventArgs e) { try { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); MessageUtil.Show("刷新成功!"); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新 /// 创建人:王一帆 /// 创建日期:2020-01-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnGridViewRightCallBack(object sender, EventArgs e) { try { if (this.GridControlObj.LastSearchSql != null) { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); if(!this.SysModel.CancelPrompt) MessageUtil.Show("成功!"); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 说明:增加条码后,刷新规则按照上一次查询条件刷新 /// 创建人:王一帆 /// 创建日期:2020-01-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnGridAddCallBack(object sender, EventArgs e) { //if (this.addControl.addbtnSql == null) return; //int refreshTypes = SqlHelper.ExecuteNonQuery(this.addControl.addbtnSql); //if (refreshTypes == 1) //{ // this.gcMain.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcMain.LastSearchSql)); // this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); // MessageUtil.Show("成功!"); //} } /// /// 说明:条码点击需要生产的条码 /// 创建人:王一帆 /// 创建日期:2020-01-07 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. private void OnGridViewDoubleClick(object sender, EventArgs e) { int successQuantity = 0;//执行成功条数 int AllQuantity = 0;//全部条数 string mag = string.Empty; try { string msgs = string.Empty; //DataRow dr = this.gcBottom.GetViewFocusedDataRow(); DataRow[] dataRows = this.gcBottom.GetViewFocusedDataRows(); AllQuantity = dataRows.Length; if (this.SysModel.Required.Equals("1") && dataRows.Length == 0) { return; } foreach (DataRow dr in dataRows) { DataRow rowArray = this.gcLeft.GetViewFocusedDataRow(); string sql = this.ControlObj.ReplaceControlValue(this.SysModel.AddbtnSql); sql = ReplaceHelper.ReplaceRowParam(rowArray, sql); sql = ReplaceHelper.ReplaceRowParam(dr, sql); string result = SqlHelper.ExecuteScalar(sql) + ""; if (result == "1") { successQuantity++; } else { mag += result + "\r\n"; } } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } finally { if (successQuantity > 0) { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); if (AllQuantity == successQuantity && !this.SysModel.CancelPrompt) MessageUtil.Show("成功!"); } if (AllQuantity > successQuantity) { MessageUtil.Show(mag); } } } /// /// 生成条码事件 /// /// /// private void but_CreatBarCode_Click(object sender, EventArgs e) { try { DataRow rowArray = this.gcLeft.GetViewFocusedDataRow(); string sql = this.ControlObj.ReplaceControlValue(this.SysModel.BillbtnSql); sql = ReplaceHelper.ReplaceRowParam(rowArray, sql); string result = SqlHelper.ExecuteScalar(sql) + ""; if (result == "1") { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); if (!this.SysModel.CancelPrompt) MessageUtil.Show("成功!"); } else { MessageUtil.Show(result); } } catch (Exception ex) { LogUtil.WriteError("生成条码事件出错!", ex); //MessageUtil.Show("生成条码事件出错!" + ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 说明:保存表格数据 /// 创建人:龚宇超 /// 创建日期:2017-10-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void btn_save_Click(object sender, EventArgs e) { if (this.GridControlObj.GridView.ValidateNullRequired(this._nullFields)) { bool isExec = true; try { if (this.GridControlObj != null && this.GridControlObj.AdapterObj != null) { int result = this.GridControlObj.AdapterObj.Update(this.GridControlObj.GridControl.DataSource as DataTable); if (result > 0) { isExec = false; MessageUtil.Show(ResourceKeys.SaveSuccess); } } } catch (Exception ex) { LogUtil.WriteError("基础档案明细保存失败", ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } finally { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); } } } private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { try { DataRow rowArray = this.gcLeft.GetViewFocusedDataRow(); string sql = ReplaceHelper.ReplaceRowParam(rowArray, this.SysModel.ClosebtnSql); string result = SqlHelper.ExecuteScalar(sql) + ""; if (result == "1") { e.Cancel = false;//取消关闭事件 } else { this.DialogResult = MessageUtil.Show(string.Format(result), MessageBoxButtons.YesNo); if (this.DialogResult == DialogResult.No) { e.Cancel = true;//取消关闭事件 } } } catch (Exception) { this.Dispose(); } } /// /// moduleGridEx点击删除后刷新上下表 /// /// /// private void ModuleGridExAfterDeleteGridCallBack(object sender, EventArgs e) { if (this.splitRightControl.PanelVisibility == SplitPanelVisibility.Both) { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql)); } else { this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql)); } } /// ///左侧表格选中设置行 /// /// /// private void SelectSettingsRows() { try { if (!string.IsNullOrWhiteSpace(this.SysModel.SelectionCriteria)) { DataTable dt = this.gcLeft.gridControl.DataSource as DataTable; DataRow[] dataRows = dt.Select(this.SysModel.SelectionCriteria); if (dt.Rows.Count > 0 && dataRows.Length > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i] == dataRows[0]) { this.gcLeft.GridView.SelectRowHandler(i); break; } } } } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show("左侧行选择错误", ex.Message); } } /// /// 说明:数据绑定完成后加载数据 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void OnLeftControlObjDataSourceBindCallBack(object sender, EventArgs e) { try { this._leftGridSearchObj.SearchGrid(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } } }