| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 | 
							- 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 DevComponents.DotNetBar;
 
- using DevComponents.DotNetBar.Layout;
 
- namespace WCS_Client.UC
 
- {
 
-     public partial class FrmLAddEdit : Office2007Form
 
-     {
 
-         public FrmLAddEdit()
 
-         {
 
-             InitializeComponent();
 
-             ErrItem.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;
 
-         }
 
-         ErrorProvider ErrItem = new ErrorProvider();
 
-         internal List<LayoutControlItem> _LCItemList = new List<LayoutControlItem>();
 
-         public delegate DataRow GetDrHandler(int StepQty);
 
-         GetDrHandler _GetDrMethods = null;
 
-         public delegate DataRow EditDataHandler(DataRow dr);
 
-         EditDataHandler _EditDataMethods = null;
 
-         public delegate bool SaveDataHandler(DataRow dr);
 
-         SaveDataHandler _SaveDataMethods = null;
 
-         public delegate void LCItemEditHandler(FrmLAddEdit frm);
 
-         LCItemEditHandler _LCItemEditMethods = null;
 
-         public delegate void LCItemNewHandler(FrmLAddEdit frm);
 
-         LCItemNewHandler _LCItemNewMethods = null;
 
-         public void SetLCItemErr(LayoutControlItem LCItem, string ErrText)
 
-         {
 
-             if (LCItem == null || LCItem.Control == null)
 
-             {
 
-                 return;
 
-             }
 
-             if (!string.IsNullOrEmpty(ErrText))
 
-             {
 
-                 LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 15, 0);
 
-                 LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 15, 0);
 
-             }
 
-             else
 
-             {
 
-                 LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
 
-                 LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
 
-             }
 
-             ErrItem.SetError(LCItem.Control, ErrText);
 
-         }
 
-         public void ClearLCItemErr()
 
-         {
 
-             ErrItem.Clear();
 
-         }
 
-         public void SetLCItemErr(string LCName, string ErrText)
 
-         {
 
-             LayoutControlItem LCItem = GetLCItem(LCName);
 
-             SetLCItemErr(LCItem, ErrText);
 
-         }
 
-         public List<LayoutControlItem> GetLCItemList()
 
-         {
 
-             return _LCItemList;
 
-         }
 
-         public LayoutControlItem GetLCItem(string LCName)
 
-         {
 
-             return _LCItemList.Find(a => a.Name == LCName);
 
-         }
 
-         public void ClearLCItemValue()
 
-         {
 
-             LCItemUtil.ClearValue_LCItem(_LCItemList);
 
-         }
 
-   
 
-         public void LCItemIsEnable(string LCName, bool IsEnable)
 
-         {
 
-             LayoutControlItem item = GetLCItem(LCName);
 
-             if (item == null || item.Control == null)
 
-             {
 
-                 return;
 
-             }
 
-             item.Control.Enabled = IsEnable;
 
-         }
 
-         public void LCItemIsEnable(bool IsEnable)
 
-         {
 
-             foreach (LayoutControlItem item in _LCItemList)
 
-             {
 
-                 if (item == null || item.Control == null)
 
-                 {
 
-                     continue;
 
-                 }
 
-                 item.Control.Enabled = IsEnable;
 
-             }
 
-         }
 
-         public DataRow GetData()
 
-         {
 
-             DataTable dt = new DataTable();
 
-             foreach (LayoutControlItem Item in _LCItemList)
 
-             {
 
-                 dt.Columns.Add(Item.Name, typeof(object));
 
-             }
 
-             DataRow dr = dt.NewRow();
 
-             foreach (LayoutControlItem Item in _LCItemList)
 
-             {
 
-                 dr[Item.Name] = LCItemUtil.GetValue_LCItem(Item);
 
-             }
 
-             return dr;
 
-         }
 
-         public void SetLCItemValue(DataRow dr)
 
-         {
 
-             foreach (LayoutControlItem Item in _LCItemList)
 
-             {
 
-                 LCItemUtil.SetValue_LCItem(Item, dr[Item.Name]);
 
-             }
 
-         }
 
-         public void InitFrm(bool IsBtnNew, bool IsBtnEdit, List<LayoutControlItem> LCItemList, GetDrHandler GetDrMethods, LCItemNewHandler LCItemNewMethods, LCItemEditHandler LCItemEditMethods, EditDataHandler EditDataMethods, SaveDataHandler SaveDataMethods)
 
-         {
 
-             _GetDrMethods = GetDrMethods;
 
-             _EditDataMethods = EditDataMethods;
 
-             _SaveDataMethods = SaveDataMethods;
 
-             _LCItemNewMethods = LCItemNewMethods;
 
-             _LCItemEditMethods = LCItemEditMethods;
 
-             this.Btn_New.Visible = IsBtnNew;
 
-             this.Btn_Edit.Visible = IsBtnEdit;
 
-             this.Btn_Save.Visible = (IsBtnNew || IsBtnEdit);
 
-             _LCItemList = LCItemList;
 
-             //LayoutControl添加控件
 
-             if (_LCItemList != null)
 
-             {
 
-                 foreach (LayoutControlItem LocItem in _LCItemList)
 
-                 {
 
-                     this.layoutControl1.Controls.Add(LocItem.Control);
 
-                     this.layoutControl1.RootGroup.Items.Add(LocItem);
 
-                 }
 
-             }
 
-         }
 
-         public void FrmEditShowDialog(DataRow dr)
 
-         {
 
-             try
 
-             {
 
-                 if (dr == null)
 
-                 {
 
-                     throw new Exception("数据为空,无法进行编辑!!!");
 
-                 }
 
-                 DataRow ndr = _EditDataMethods(dr);
 
-                 if (ndr == null)
 
-                 {
 
-                     throw new Exception("数据为空,无法进行编辑!!!");
 
-                 }
 
-                 ClearLCItemValue();
 
-                 ClearLCItemErr();
 
-                 _LCItemEditMethods(this);
 
-                 SetLCItemValue(dr);
 
-                 this.Btn_Save.Enabled = true;
 
-                 this.Btn_New.Enabled = false;
 
-                 this.Btn_Edit.Enabled = false;
 
-                 this.ShowDialog();
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         public void FrmEditShowDialog(DataRow dr,DataTable dt)
 
-         {
 
-             try
 
-             {
 
-                
 
-                 if (dr == null)
 
-                 {
 
-                     throw new Exception("数据为空,无法进行编辑!!!");
 
-                 }
 
-                 DataRow ndr = _EditDataMethods(dr);
 
-                 if (ndr == null)
 
-                 {
 
-                     throw new Exception("数据为空,无法进行编辑!!!");
 
-                 }
 
-                 ClearLCItemValue();
 
-                 ClearLCItemErr();
 
-                 _LCItemEditMethods(this);
 
-                 SetLCItemValue(dr);
 
-                 Editstatus = 1;
 
-                 dtTable = dt;
 
-                 this.Btn_Save.Enabled = true;
 
-                 this.Btn_New.Enabled = false;
 
-                 this.Btn_Edit.Enabled = false;
 
-                 this.ShowDialog();
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         
 
-         }
 
-         public void FrmNewShowDialog()
 
-         {
 
-             try
 
-             {
 
-                
 
-                 ClearLCItemValue();
 
-                 ClearLCItemErr();
 
-                 _LCItemNewMethods(this);
 
-                 this.Btn_Save.Enabled = true;
 
-                 this.Btn_New.Enabled = false;
 
-                 this.Btn_Edit.Enabled = false;
 
-                 this.ShowDialog();
 
-                 
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         public void FrmViewShowDialog(DataRow dr)
 
-         {
 
-             try
 
-             {
 
-                
 
-                 if (dr == null)
 
-                 {
 
-                     throw new Exception("数据为空,无法进行编辑!!!");
 
-                 }
 
-                 ClearLCItemValue();
 
-                 LCItemIsEnable(false);
 
-                 ClearLCItemErr();
 
-                 SetLCItemValue(dr);
 
-                 this.Btn_Save.Enabled = false;
 
-                 this.Btn_New.Enabled = true;
 
-                 this.Btn_Edit.Enabled = true;
 
-                 this.ShowDialog();
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         private void Btn_New_Click(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 ClearLCItemValue();
 
-                 ClearLCItemErr();
 
-                 _LCItemNewMethods(this);
 
-                 Btn_New.Enabled = false;
 
-                 Btn_Edit.Enabled = false;
 
-                 Btn_Save.Enabled = true;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         private void Btn_Close_Click(object sender, EventArgs e)
 
-         {
 
-             if (IsGiveUpData())
 
-             {
 
-                 this.Close();
 
-             }
 
-         }
 
-         private bool IsGiveUpData()
 
-         {
 
-             if (Btn_Save.Visible && Btn_Save.Enabled && MessageUtil.ShowYesNoAndWarning("是否放弃修改数据!!!") == DialogResult.No)
 
-             {
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         private void Btn_Edit_Click(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 DataRow dr = _EditDataMethods(GetData());
 
-                 if (dr == null)
 
-                 {
 
-                     throw new Exception("数据有可能发生变化!!!");
 
-                 }
 
-                 ClearLCItemValue();
 
-                 ClearLCItemErr();
 
-                 _LCItemEditMethods(this);
 
-                 SetLCItemValue(dr);
 
-                 Btn_New.Enabled = false;
 
-                 Btn_Edit.Enabled = false;
 
-                 Btn_Save.Enabled = true;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         private void Btn_Down_Click(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 if (IsGiveUpData())
 
-                 {
 
-                     ClearLCItemValue(); 
 
-                     ClearLCItemErr();
 
-                     LCItemIsEnable(false);
 
-                     DataRow dr = _GetDrMethods(1);
 
-                     if (dr == null)
 
-                     {
 
-                         throw new Exception("数据为空!!!");
 
-                     }
 
-                     SetLCItemValue(dr);
 
-                     Btn_New.Enabled = true;
 
-                     Btn_Edit.Enabled = true;
 
-                     Btn_Save.Enabled = false;
 
-                 }
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         private void Btn_Up_Click(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 if (IsGiveUpData())
 
-                 {
 
-                     ClearLCItemValue();
 
-                     ClearLCItemErr();
 
-                     LCItemIsEnable(false);
 
-                     DataRow dr = _GetDrMethods(-1);
 
-                     if (dr == null)
 
-                     {
 
-                         throw new Exception("数据为空!!!");
 
-                     }
 
-                     SetLCItemValue(dr);
 
-                     Btn_New.Enabled = true;
 
-                     Btn_Edit.Enabled = true;
 
-                     Btn_Save.Enabled = false;
 
-                 }
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-                 this.Close();
 
-             }
 
-         }
 
-         private void Btn_Save_Click(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 if (_SaveDataMethods(GetData()))
 
-                 {
 
-                     LCItemIsEnable(false);
 
-                     Btn_New.Enabled = true;
 
-                     Btn_Edit.Enabled = true;
 
-                     Btn_Save.Enabled = false;
 
-                 }
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageUtil.ShowError(ex.Message);
 
-             }
 
-         }
 
-         int Editstatus = 0;
 
-         DataTable dtTable = null;
 
-         private void FrmLAddEdit_Load(object sender, EventArgs e)
 
-         {
 
-             if (Editstatus == 1)
 
-             {
 
-                 if (dtTable != null)
 
-                     SetLCItemValue(dtTable.Rows[0]);
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |