/****************************** * 说明:基础档案明细添加 * 创建人:龚宇超 * 创建日期:2018-04-03 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ******************************/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Lskj.Model; using Lskj.Control.Model; using Lskj.Business.Impl; using Lskj.Util; using Lskj.Data; using Lskj.Control; using DevExpress.XtraTab; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using System.Threading; namespace Lskj.PubModuleDetailInfo2 { /// /// 基础档案明细添加 /// public partial class FrmMain : BaseForm { private ModulePanelEx _modulePanel; public DynamicModuleDetailInfo2 Model; public FrmMain() { InitializeComponent(); } /// /// 说明:窗口加载 /// 创建人:龚宇超 /// 创建日期:2018-04-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 一个包含事件数据的 。 protected override void OnLoad(EventArgs e) { WaitForm.ShowForm(); try { this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + ""; List details = this.GetDetails(); this.mControl.Details = details;//拿到底部表格数据 this.mControl.InitControls(Model); //this.mControl.OnLeftGridViewRowClickCallBack += new EventHandler(OnLeftGridViewRowClickCallBack); //this.mControl.OnLeftTreeViewRowClickCallBack += new EventHandler(OnLeftTreeViewRowClickCallBack); //this.mControl.ModuleGridDetailObj.OnGridViewRowClickCallBack += new EventHandler(OnLeftTreeViewRowClickCallBack); if (details.Count > 0) { this.mControl.ModuleGridDetailObj.ModuleGridObj.GridControlObj.GridView.FocusedRowObjectChanged += GridView_FocusedRowObjectChanged; } else { this.mControl.ModuleGridDetailObj.OnGridViewRowClickCallBack += new EventHandler(OnLeftTreeViewRowClickCallBack); } this.InitDetailAddPanelControl(); } catch (Exception ex) { LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule); //MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); // 加载完统一显示控件 this.mControl.Visible = true; } WaitForm.HideForm(); } /// /// 说明:初始化底部控件 /// 创建人:龚宇超 /// 创建日期:2018-04-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitDetailAddPanelControl() { this._modulePanel = new ModulePanelEx(); this._modulePanel.Dock = DockStyle.Fill; this._modulePanel.ControlSql = Model.ControlSql; this._modulePanel.PrimaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode); // DynamicModel dyncModel = new DynamicModuleDetailInfo2(new string[] { this.Model.FormText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, this.Model.BottomModuleCode, "0" }); this._modulePanel.InitializeControl(new ModuleModel(MainImpl.GetSystemdllTab(this.Model.ModuleCode)), this.Model); this._modulePanel.OnAddRecordCallBack += new EventHandler(OnAddRecordCallBack); this._modulePanel.ControlObj.OnAddCallBack += new EventHandler(OnAddCallBack); this._modulePanel.OnCloseCallback += new EventHandler(OnAddRecordCallBack); this._modulePanel.OperatePanelControlObj.Visible = false; this._modulePanel.SpeciesPanelControlObj.Visible = false; this.mControl.ModuleGridDetailObj.BottomPanel.Visible = true; this.mControl.ModuleGridDetailObj.BottomPanel.Height = this._modulePanel.ControlHeight; this.mControl.ModuleGridDetailObj.BottomPanel.Controls.Add(this._modulePanel); this.pl_buttom.Height = this.mControl.ModuleGridObj.ObjPanel.Height + 6; PanelControl newPanelControl = new PanelControl(); newPanelControl = this.mControl.ModuleGridObj.ObjPanel; newPanelControl.Dock = DockStyle.Fill; newPanelControl.BorderStyle = BorderStyles.NoBorder; this.pl_buttom.Controls.Add(newPanelControl); } /// /// 扫码数据回车保存事件 /// /// /// protected void OnAddCallBack(object sender, EventArgs e) { try { BaseUserControl baseControl = null; var ctr = sender as System.Windows.Forms.Control; if (ctr != null && ctr.Parent != null && ctr.Parent.Parent != null) baseControl = ctr.Parent.Parent as BaseUserControl; bool isSaveSkip = false; BaseUserControl nextControl = this._modulePanel.ControlObj.FindNextControl(baseControl,out isSaveSkip); if (nextControl != null && !isSaveSkip) { nextControl.Focus();//存在跳转控件则直接跳转 } else { this._modulePanel.AddControlRecord(true, false); this.mControl.SearchObj.SearchLastGrid(); if(baseControl!=null) baseControl.EditText = ""; //this._modulePanel.ControlObj.ResetControlValue(); //if (this._modulePanel.ScanEdit != null) //{ // // 保存成功后重新设置值. // BaseUserControl control = this._modulePanel.ControlObj.FindControl(this._modulePanel.PrimaryKey); // if (control != null) // { // this._modulePanel.PrimaryValue = MainImpl.GetDefaultValue(control.Model.Default); // this._modulePanel.ControlObj.SetControlValue(control.Model, this._modulePanel.PrimaryValue); // } // SynchronizationContext.Current.Post(o => // { // this._modulePanel.ScanEdit.Focus(); // this._modulePanel.ScanEdit.TextEdit.Focus(); // }, null); //} //if (nextControl != null && isSaveSkip) //{ // nextControl.Focus(); //} } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:添加数据回调 /// 创建人:龚宇超 /// 创建日期:2018-04-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void OnAddRecordCallBack(object sender, EventArgs e) { try { this.mControl.SearchObj.SearchLastGrid(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:左侧树结构节点点击后 /// 创建人:龚宇超 /// 创建日期:2018-05-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnLeftTreeViewRowClickCallBack(object sender, EventArgs e) { try { string parentUnionField = this.mControl.ModuleGridObj.ParentUnionField; if (this._modulePanel.ControlObj != null && !string.IsNullOrEmpty(parentUnionField)) { // 点击树节点后关联右侧添加面板值 TreeViewEx treeView = sender as TreeViewEx; BaseUserControl unionControl = this._modulePanel.ControlObj.FindControl(parentUnionField); this._modulePanel.ControlObj.SetControlValue(unionControl.Model, treeView.GetSelectValue()); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:左侧表格点击后 /// 创建人:龚宇超 /// 创建日期:2018-05-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnLeftGridViewRowClickCallBack(object sender, EventArgs e) { try { string parentUnionField = this.mControl.ModuleGridObj.ParentUnionField; if (this._modulePanel.ControlObj != null && this.mControl.LeftGridViewObj != null && !string.IsNullOrEmpty(parentUnionField)) { // 点击表格后后关联右侧添加面板值 DataRow rowItem = this.mControl.LeftGridViewObj.GridView.GetFocusedDataRow(); BaseUserControl unionControl = this._modulePanel.ControlObj.FindControl(parentUnionField); this._modulePanel.ControlObj.SetControlValue(unionControl.Model, rowItem[parentUnionField] + ""); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:关闭 /// 创建人:龚宇超 /// 创建日期:2018-05-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnFormClosed(object sender, FormClosedEventArgs e) { try { if (this._modulePanel != null && this._modulePanel.IsCard) { this._modulePanel.CloseIDCardThread(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:拿到底部表格数据 /// 创建人:龚宇超 /// 创建日期:2017-11-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// List<GridDetailModel>. private List GetDetails() { List details = new List();//表格明细对象的集合 DataTable table = BaseModuleImpl.GetBaseDetailPages(Model.ModuleCode);// 根据传入的模块编号获得基础档案底部标签的数据 foreach (DataRow item in table.Rows) { DataTable gridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");//获取报表明细列 details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView)); } return details; } /// /// 主表焦点行改变后 /// /// /// private void GridView_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e) { try { DataRow rowItem = this.mControl.ModuleGridObj.GridControlObj.GetViewFocusedDataRow(); this._modulePanel.ControlObj.CurrentData = rowItem; this._modulePanel.ControlObj.SetAllControlValue(rowItem); this._modulePanel.ControlObj.SyncLocalModel(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:主表选中行改变时 /// 创建人:龚宇超 /// 创建日期:2018-05-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. protected void OnMainRowClickCallBack(object sender, EventArgs e) { try { DataRow rowItem = this.mControl.ModuleGridObj.GridControlObj.GetViewFocusedDataRow(); this._modulePanel.ControlObj.CurrentData = rowItem; this._modulePanel.ControlObj.SetAllControlValue(rowItem); this._modulePanel.ControlObj.SyncLocalModel(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } } }