1861 lines
		
	
	
		
			62 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1861 lines
		
	
	
		
			62 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.ComponentModel;
 | ||
| using System.Data;
 | ||
| using System.Drawing;
 | ||
| using System.Text;
 | ||
| using System.Linq;
 | ||
| using System.Windows.Forms;
 | ||
| using DevExpress.XtraBars;
 | ||
| using DevExpress.XtraBars.Ribbon;
 | ||
| //using DeiNiu.wms.win.utils;
 | ||
| using DevExpress.XtraEditors;
 | ||
| using DevExpress.XtraEditors.Controls;
 | ||
| using DeiNiu.wms.Data.Model;
 | ||
| using DevExpress.XtraGrid.Views.Grid;
 | ||
| using DeiNiu.Utils;
 | ||
| using System.Data.OleDb;
 | ||
| using System.Speech.Synthesis;
 | ||
| using DevExpress.XtraGrid.Views.Grid.ViewInfo;
 | ||
| using DeiNiu.wms.win.portalService;
 | ||
| using DeiNiu.wms.win.utils;
 | ||
| using DevExpress.XtraGrid.Columns;
 | ||
|  
 | ||
|  
 | ||
| 
 | ||
| namespace DeiNiu.wms.win
 | ||
| {
 | ||
|     public partial class BasicRibbonForm : FormBase //DevExpress.XtraBars.Ribbon.RibbonForm
 | ||
|     {
 | ||
|             public BasicRibbonForm()
 | ||
|             {
 | ||
|                 InitializeComponent();
 | ||
|           
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             
 | ||
| 
 | ||
|          protected void showWaitForm(string desc=null)
 | ||
|         { 
 | ||
|             if (this.splashScreenManager1.IsSplashFormVisible)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             closeWaitForm();
 | ||
|             try
 | ||
|             {
 | ||
|                 this.splashScreenManager1.ShowWaitForm();
 | ||
|             }
 | ||
|             catch { }
 | ||
| 
 | ||
|            
 | ||
|            if (!string.IsNullOrEmpty(desc))
 | ||
|            {
 | ||
|                splashScreenManager1.SetWaitFormDescription(desc);
 | ||
|            }
 | ||
|           //  WaitFormService.Show(this);
 | ||
|         }
 | ||
| 
 | ||
|         protected void closeWaitForm()
 | ||
|         { 
 | ||
|             if (!this.splashScreenManager1.IsSplashFormVisible)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 this.splashScreenManager1.CloseWaitForm();
 | ||
|             }
 | ||
|             catch { }
 | ||
|            // WaitFormService.Close();
 | ||
|         }
 | ||
|       protected  struct Colitem
 | ||
|         {
 | ||
|           public  int key ;
 | ||
|           public string value  ;
 | ||
|           public string code;
 | ||
| 
 | ||
|           public override string ToString()
 | ||
|           {
 | ||
|               return value;
 | ||
|           }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|       protected void initialComboBoxs(ComboBoxEdit combo, Dictionary<int, string> dic, bool isForQuery = true)
 | ||
|       {
 | ||
|           combo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | ||
|           combo.Properties.Items.Clear();
 | ||
|           ComboBoxItemCollection col = combo.Properties.Items; 
 | ||
|           col.BeginUpdate();
 | ||
|           if (isForQuery)
 | ||
|           {
 | ||
|               Colitem c = new Colitem();
 | ||
|               c.key = 0;
 | ||
|               c.value = "请选择";
 | ||
|               col.Add(c); 
 | ||
|               
 | ||
|           }
 | ||
|           try
 | ||
|           {
 | ||
|               foreach (int key in dic.Keys)
 | ||
|               {
 | ||
| 
 | ||
|                   Colitem c = new Colitem();
 | ||
|                   c.key = key;
 | ||
|                   c.value = dic[key];
 | ||
|                   col.Add(c); 
 | ||
| 
 | ||
|               }
 | ||
|           }
 | ||
|           finally
 | ||
|           {
 | ||
|               col.EndUpdate();
 | ||
|           }
 | ||
| 
 | ||
|           combo.SelectedIndex = 0;
 | ||
|       }
 | ||
|       protected void initialComboBoxs(ComboBoxEdit combo, Dictionary<string, string> dic, bool isForQuery = true)
 | ||
|       {
 | ||
|           combo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | ||
|           combo.Properties.Items.Clear();
 | ||
|           ComboBoxItemCollection col = combo.Properties.Items;
 | ||
|           col.BeginUpdate();
 | ||
|           if (isForQuery)
 | ||
|           {
 | ||
|               Colitem c = new Colitem();
 | ||
|               c.code = "";
 | ||
|               c.value = "请选择";
 | ||
|               col.Add(c); 
 | ||
|           }
 | ||
|           try
 | ||
|           {
 | ||
|               foreach (string key in dic.Keys)
 | ||
|               {
 | ||
| 
 | ||
|                   Colitem c = new Colitem();
 | ||
|                   c.code = key;
 | ||
|                   c.value = dic[key];
 | ||
|                   col.Add(c);
 | ||
| 
 | ||
|               }
 | ||
|           }
 | ||
|           finally
 | ||
|           {
 | ||
|               col.EndUpdate();
 | ||
|           }
 | ||
| 
 | ||
|           combo.SelectedIndex = 0;
 | ||
|       }
 | ||
| 
 | ||
| 
 | ||
|         protected void initialComboBoxs(ComboBoxEdit combo, DataRow[] drss,bool isForQuery =true,string title ="请选择")
 | ||
|         {
 | ||
|             combo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;   
 | ||
|             combo.Properties.Items.Clear();
 | ||
|             List<Node> nds = new List<Node>();
 | ||
|           
 | ||
|             foreach (DataRow dr in drss)
 | ||
|             {
 | ||
|                 nds.Add(new Node(dr));
 | ||
|             }
 | ||
| 
 | ||
|             ComboBoxItemCollection coll = combo.Properties.Items;
 | ||
|             coll.BeginUpdate();
 | ||
|             if (isForQuery)
 | ||
|             {
 | ||
|                 coll.Add(title);
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 foreach (Node nd in nds)
 | ||
|                 {
 | ||
|                     coll.Add(nd);
 | ||
|                 }
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 coll.EndUpdate();
 | ||
|             }
 | ||
|             combo.SelectedIndex = 0;
 | ||
| 
 | ||
|         }
 | ||
|         protected void initialComboBoxs(ComboBoxEdit combo, string[] items, string title ="")
 | ||
|         {
 | ||
|             combo.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | ||
|             combo.Properties.Items.Clear();
 | ||
|            
 | ||
| 
 | ||
|             ComboBoxItemCollection coll = combo.Properties.Items;
 | ||
|             coll.BeginUpdate();
 | ||
|             if (title.Length == 0)
 | ||
|             {
 | ||
|              //   coll.Add("全部");
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 coll.Add(title);
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 foreach (string nd in items)
 | ||
|                 {
 | ||
|                     coll.Add(nd);
 | ||
|                 }
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 coll.EndUpdate();
 | ||
|             }
 | ||
|             combo.SelectedIndex = 0;
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected void setDatePiker(DateEdit deFrom,DateEdit deTo)
 | ||
|         {
 | ||
|             deFrom.EditValue = DateTime.Now.AddDays(-1 * WmsConstants.DAYS_QUERY_BEFORE).Date.AddHours(0).AddMinutes(0);
 | ||
|             deTo.EditValue = DateTime.Now.Date.AddDays(0).AddHours(23).AddMinutes(59);
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         protected void showErrorMsg(Exception e, string message=null)
 | ||
|         {
 | ||
|             closeWaitForm();
 | ||
| 
 | ||
|             string title = e==null || e.InnerException == null ? "出错啦" : e.InnerException.Message;
 | ||
|             if (e != null)
 | ||
|             {
 | ||
|                 LogHelper.WriteLog(this.GetType(), e);
 | ||
|                 message = string.IsNullOrEmpty(message) ? title+ "\n" + e.Message  : message + ": " + title+ "\n" + e.Message   ;
 | ||
|             }
 | ||
|             showErrorMsg(message);
 | ||
|            /* if (message.Equals(WmsConstants.WCF_UN_AUTH_MESSAGE))
 | ||
|             {
 | ||
|                 LoginInfo.UserId = -1;
 | ||
|                 if (this.ParentForm != null)
 | ||
|                 {
 | ||
|                     ((main)this.ParentForm).showLogin();
 | ||
|                 }
 | ||
|                 else if (this is main)
 | ||
|                 {
 | ||
|                     ((main)this).showLogin();
 | ||
|                 }
 | ||
|                 return;
 | ||
|             }
 | ||
|             
 | ||
|             MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
 | ||
|            */ 
 | ||
|         }
 | ||
|         protected void showErrorMsg( string message)
 | ||
|         {
 | ||
|             closeWaitForm();
 | ||
| 
 | ||
|             debug(message);
 | ||
|            
 | ||
|             if (message.Equals(WmsConstants.WCF_UN_AUTH_MESSAGE))
 | ||
|             {
 | ||
|                 LoginInfo.UserId = -1;
 | ||
| 
 | ||
|                 if (this.ParentForm != null)
 | ||
|                 {
 | ||
|                     ((main)this.ParentForm).showLogin();
 | ||
|                 }
 | ||
|                 else if (this is main)
 | ||
|                 {
 | ||
|                     ((main)this).showLogin();
 | ||
|                 }
 | ||
|                 return;
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 foreach (string s in WmsConstants.EXCEPTION_IGNORE_LST)
 | ||
|                 {
 | ||
|                     if (message.Contains(s))
 | ||
|                     {  
 | ||
|                         LogHelper.WriteLog(this.GetType(), message);
 | ||
|                         
 | ||
|                         return;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 // showErrorMsg("操作未成功,麻烦再做一次吧");
 | ||
|               
 | ||
|             }
 | ||
|          
 | ||
|            MessageBox.Show(message, "出错了", MessageBoxButtons.OK, MessageBoxIcon.Error);
 | ||
|         }
 | ||
|      
 | ||
|         protected void showInfoMsg(string message)
 | ||
|         {
 | ||
|             closeWaitForm();
 | ||
|         
 | ||
|             MessageBox.Show(message, "通知", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | ||
|         }
 | ||
|          
 | ||
|         protected void setupGridView(GridView gridview, bool canMultiSelect,bool showGroupPannel = true,bool canFocus = true)
 | ||
|         {
 | ||
|              
 | ||
|             gridview.OptionsView.EnableAppearanceEvenRow = true;  //偶数行颜色变化
 | ||
|             gridview.OptionsView.EnableAppearanceOddRow = false;  //奇数行颜色变化
 | ||
|             gridview.OptionsSelection.MultiSelect = true;// canMultiSelect;// true;// canMultiSelect; //多选模式下,可以高亮选中cell
 | ||
|             gridview.OptionsView.ShowGroupPanel =   showGroupPannel;
 | ||
|             gridview.OptionsClipboard.CopyColumnHeaders = DevExpress.Utils.DefaultBoolean.False;
 | ||
|             gridview.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;
 | ||
|             gridview.OptionsBehavior.Editable = false;
 | ||
|             gridview.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus; 
 | ||
|             gridview.OptionsSelection.EnableAppearanceHideSelection = false;
 | ||
|          //   gridview.OptionsSelection.EnableAppearanceFocusedCell = canFocus;
 | ||
|          //   gridview.OptionsSelection.EnableAppearanceFocusedRow = canFocus;
 | ||
|           //  gridview.OptionsSelection.EnableAppearanceHideSelection = true;
 | ||
|         }
 | ||
|         //private void GridView_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 | ||
|         //{
 | ||
|         //    if (e.Control & e.KeyCode == Keys.C)
 | ||
|         //    {
 | ||
|         //        Clipboard.SetDataObject(AdvBandedGridView1.GetFocusedRowCellValue(AdvBandedGridView1.FocusedColumn));
 | ||
|         //        e.Handled = true;
 | ||
|         //    }
 | ||
|         //}
 | ||
|         //显示行的序号    
 | ||
|         protected void gridView_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
 | ||
|         {
 | ||
|             if (e.Info.IsRowIndicator && e.RowHandle >= 0)
 | ||
|             {
 | ||
|                 e.Info.DisplayText = (e.RowHandle + 1).ToString();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         protected void speak(string msg){
 | ||
|            
 | ||
|          SpeechSynthesizer voice = new SpeechSynthesizer();   //创建语音实例
 | ||
|                voice.Rate = -1; //设置语速,[-10,10]
 | ||
|                voice.Volume = 100; //设置音量,[0,100]
 | ||
|                voice.SpeakAsync(msg);  //播放指定的字符串,这是异步朗读
 | ||
|         }
 | ||
| 
 | ||
|         protected void debug(string msg)
 | ||
|         {
 | ||
| 
 | ||
|             DeiNiu.Utils.LogHelper.debug(this.GetType(), msg);
 | ||
|         }
 | ||
|     
 | ||
|         /// <summary>
 | ||
|         /// 获取GridView过滤或排序后的数据集  
 | ||
|         /// </summary>
 | ||
|         /// <param name="view"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public System.Collections.IList GetGridViewFilteredAndSortedData(DevExpress.XtraGrid.Views.Grid.GridView view)  
 | ||
|          {  
 | ||
|              return view.DataController.GetAllFilteredAndSortedRows();             
 | ||
|          }
 | ||
| 
 | ||
| 
 | ||
|         protected void gridview_LostFocus(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|             switchGridViewRowSelection((GridView)sender, false);
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected void switchGridViewRowSelection(GridView gridView, bool isOn)
 | ||
|         {
 | ||
|             // gridView.OptionsSelection.EnableAppearanceFocusedCell = isOn;
 | ||
|             gridView.OptionsSelection.EnableAppearanceFocusedRow = isOn;
 | ||
|             gridView.OptionsSelection.EnableAppearanceHideSelection = !isOn;
 | ||
| 
 | ||
|         }
 | ||
|         protected void gridview_GotFocus(object sender, EventArgs e)
 | ||
|         {
 | ||
|             switchGridViewRowSelection((GridView)sender, true);
 | ||
|         }
 | ||
|         
 | ||
|         private Dictionary<int, string> _pickDetailStatus = null;
 | ||
|         private Dictionary<int, string> _pickRequestStatus = null;
 | ||
|         private Dictionary<int, string> _pickStatus = null;
 | ||
|         private Dictionary<int, string> _locVolType = null;
 | ||
|         private Dictionary<int, string> _pickOrNot = null;
 | ||
|         private Dictionary<int, string> _inRequestStatus = null;
 | ||
|         private Dictionary<int, string> _whType = null;
 | ||
|         private Dictionary<int, string> _outRequestType = null;
 | ||
|         private Dictionary<int, string> _stockRecordtype = null;
 | ||
|           protected Dictionary<int, string> enumStockRecordtype
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_stockRecordtype == null)
 | ||
|                 {
 | ||
|                     _stockRecordtype = Utils.Util.convertEnumToDic(typeof(enumStockRecordType));
 | ||
|                 }
 | ||
|                 return _stockRecordtype;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|        private Dictionary<int, string> _receiveDetailStatus = null;
 | ||
|        protected Dictionary<int, string> enumReceiveDetailStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_receiveDetailStatus == null)
 | ||
|                 {
 | ||
|                     _receiveDetailStatus = Utils.Util.convertEnumToDic(typeof(enumReceiveStockDetailStatus));
 | ||
|                 }
 | ||
|                 return _receiveDetailStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|   
 | ||
|         private Dictionary<int, string> _colors = null;
 | ||
|         protected Dictionary<int, string>  enumColors
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_colors == null)
 | ||
|                 {
 | ||
|                     _colors = Utils.Util.convertEnumToDic(typeof(enumColors));
 | ||
|                 }
 | ||
|                 return _colors;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<int, string> _viechleTranStatus = null;
 | ||
|         protected Dictionary<int, string>  viechleTranStatus  
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_viechleTranStatus == null)
 | ||
|                 {
 | ||
|                     _viechleTranStatus = Utils.Util.convertEnumToDic(typeof(enumViechleTransStatus));
 | ||
|                 }
 | ||
|                 return _viechleTranStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|          private Dictionary<int, string> _viechleStatus = null;
 | ||
|          protected Dictionary<int, string> viechleStatus  
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_viechleStatus == null)
 | ||
|                 {
 | ||
|                     _viechleStatus = Utils.Util.convertEnumToDic(typeof(enumViechleStatus));
 | ||
|                 }
 | ||
|                 return _viechleStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|              private Dictionary<int, string> _goodsCollection = null;
 | ||
|              protected Dictionary<int, string> goodsCollection  
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_goodsCollection == null)
 | ||
|                 {
 | ||
|                     _goodsCollection = Utils.Util.convertEnumToDic(typeof(enumGoodsCollectionStatus));
 | ||
|                 }
 | ||
|                 return _goodsCollection;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<int, string> _pickPriority = null;
 | ||
|         protected Dictionary<int, string> pickPriority  
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_pickPriority == null)
 | ||
|                 {
 | ||
|                     _pickPriority = Utils.Util.convertEnumToDic(typeof(enumPickPriority));
 | ||
|                 }
 | ||
|                 return _pickPriority;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private Dictionary<int, string> _mainTainType = null;  
 | ||
|         protected Dictionary<int, string> mainTainType  
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_mainTainType == null)
 | ||
|                 {
 | ||
|                     _mainTainType = Utils.Util.convertEnumToDic(typeof(enumMainType));
 | ||
|                 }
 | ||
|                 return _mainTainType;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private Dictionary<int, string> _stockState = null; 
 | ||
|         protected Dictionary<int, string>  stockState 
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_stockState == null)
 | ||
|                 {
 | ||
|                     _stockState = Utils.Util.convertEnumToDic(typeof(enumStockLocationStatus));
 | ||
|                 }
 | ||
|                 return _stockState;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<int, string> _maintainResult = null;  
 | ||
|         protected Dictionary<int, string>  maintainResult
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_maintainResult == null)
 | ||
|                 {
 | ||
|                     _maintainResult = Utils.Util.convertEnumToDic(typeof(enumStockMaintainResult));
 | ||
|                 }
 | ||
|                 return _maintainResult;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         private Dictionary<int, string> _stkdiff = null;
 | ||
|         protected Dictionary<int, string> stkdiff
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_stkdiff == null)
 | ||
|                 {
 | ||
|                     _stkdiff = Utils.Util.convertEnumToDic(typeof(enumStockDiff));
 | ||
|                 }
 | ||
|                 return _stkdiff;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         /*
 | ||
|        private Dictionary<int, string> _whVlo = null;
 | ||
|        protected Dictionary<int, string>  whVlo
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_whVlo == null)
 | ||
|                 {
 | ||
|                     _whVlo = Utils.Util.convertEnumToDic(typeof(enumWhVlo));
 | ||
|                 }
 | ||
|                 return _whVlo;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }*/
 | ||
|         
 | ||
|         private Dictionary<int, string> _enumPandianStatus = null;
 | ||
|         protected Dictionary<int, string> enmPandianStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_enumPandianStatus == null)
 | ||
|                 {
 | ||
|                     _enumPandianStatus = Utils.Util.convertEnumToDic(typeof(enumPandianStatus));
 | ||
|                 }
 | ||
|                 return _enumPandianStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }  
 | ||
|         
 | ||
|         private Dictionary<int, string> _customerTypes = null;
 | ||
|         protected Dictionary<int, string>  customerTypes
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_customerTypes == null)
 | ||
|                 {
 | ||
|                     _customerTypes = Utils.Util.convertEnumToDic(typeof(enumCustomerType));
 | ||
|                 }
 | ||
|                 return _customerTypes;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }   
 | ||
|         
 | ||
|            private Dictionary<int, string> _enumPandianType = null;
 | ||
|            protected Dictionary<int, string> enumPandianType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_enumPandianType == null)
 | ||
|                 {
 | ||
|                     _enumPandianType = Utils.Util.convertEnumToDic(typeof(enumPandianType));
 | ||
|                 }
 | ||
|                 return _enumPandianType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }   
 | ||
|         
 | ||
| 
 | ||
| 
 | ||
|        private Dictionary<int, string> _tranStatus = null;
 | ||
|        protected Dictionary<int, string>  tranStatus
 | ||
|        {
 | ||
|            get
 | ||
|            {
 | ||
|                if (_tranStatus == null)
 | ||
|                {
 | ||
|                    _tranStatus = Utils.Util.convertEnumToDic(typeof(enumTranStatus));
 | ||
|                }
 | ||
|                return _tranStatus;
 | ||
| 
 | ||
|            }
 | ||
| 
 | ||
|        }
 | ||
| 
 | ||
|        private Dictionary<int, string> _tranType = null;
 | ||
|        protected Dictionary<int, string>  tranType
 | ||
|        {
 | ||
|            get
 | ||
|            {
 | ||
|                if (_tranType == null)
 | ||
|                {
 | ||
|                    _tranType = Utils.Util.convertEnumToDic(typeof(enumTranType));
 | ||
|                }
 | ||
|                return _tranType;
 | ||
| 
 | ||
|            }
 | ||
| 
 | ||
|        }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|        private Dictionary<int, string> _dicValueType = null;
 | ||
|        protected Dictionary<int, string> dicValueType
 | ||
|        {
 | ||
|            get
 | ||
|            {
 | ||
|                if (_dicValueType == null)
 | ||
|                {
 | ||
|                    _dicValueType = Utils.Util.convertEnumToDic(typeof(enumDicValueType));
 | ||
|                }
 | ||
|                return _dicValueType;
 | ||
| 
 | ||
|            }
 | ||
| 
 | ||
|        }
 | ||
| 
 | ||
|          
 | ||
|         protected Dictionary<int, string>   outStoreType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_outRequestType == null)
 | ||
|                 {
 | ||
|                     _outRequestType = Utils.Util.convertEnumToDic(typeof(enumOutStoreType));
 | ||
|                 }
 | ||
|                 return _outRequestType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         Dictionary<int, string> _outOrderType;
 | ||
|         protected Dictionary<int, string> outOrderType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_outOrderType == null)
 | ||
|                 {
 | ||
|                     _outOrderType = Utils.Util.convertEnumToDic(typeof(enumOrderType));
 | ||
|                 }
 | ||
|                 return _outOrderType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         protected Dictionary<int, string>  whType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_whType == null)
 | ||
|                 {
 | ||
|                     _whType = Utils.Util.convertEnumToDic(typeof(enumWhType));
 | ||
|                 }
 | ||
|                 return _whType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|          
 | ||
|         protected Dictionary<int, string> inRequestStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_inRequestStatus == null)
 | ||
|                 {
 | ||
|                     _inRequestStatus = Utils.Util.convertEnumToDic(typeof(enumInStockOrderStatus));
 | ||
|                 }
 | ||
|                 return _inRequestStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected Dictionary<int, string> pickOrNot
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_pickOrNot == null)
 | ||
|                 {
 | ||
|                     _pickOrNot = Utils.Util.convertEnumToDic(typeof(enumPickState));
 | ||
|                 }
 | ||
|                 return _pickOrNot;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         protected Dictionary<int, string> locVolType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_locVolType == null)
 | ||
|                 {
 | ||
|                     _locVolType = Utils.Util.convertEnumToDic(typeof(enumWhLocVol));
 | ||
|                 }
 | ||
|                 return _locVolType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
|         private Dictionary<int, string> _enumLotAttType = null;
 | ||
|         protected Dictionary<int, string> enLotAttType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_enumLotAttType == null)
 | ||
|                 {
 | ||
|                     _enumLotAttType = Utils.Util.convertEnumToDic(typeof(enumLotAttType));
 | ||
|                 }
 | ||
|                 return _enumLotAttType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<int, string> _stockInLocationStatus = null;
 | ||
|         protected Dictionary<int, string> stockInLocationStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_stockInLocationStatus == null)
 | ||
|                 {
 | ||
|                     _stockInLocationStatus = Utils.Util.convertEnumToDic(typeof(enumInStockDetailStatus));
 | ||
|                 }
 | ||
|                 return _stockInLocationStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         Dictionary<int, string> _waveRuleType;
 | ||
|         protected Dictionary<int, string> waveRuleType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_waveRuleType == null)
 | ||
|                 {
 | ||
|                     _waveRuleType = Utils.Util.convertEnumToDic(typeof(enumWaveRuleType));
 | ||
|                 }
 | ||
|                 return _waveRuleType;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected Dictionary<int, string> pickStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_pickStatus == null)
 | ||
|                 {
 | ||
|                     _pickStatus = Utils.Util.convertEnumToDic(typeof(enumOutStockPickStatus));
 | ||
|                 }
 | ||
|                 return _pickStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected Dictionary<int, string> pickDetailStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_pickDetailStatus == null)
 | ||
|                 {
 | ||
|                     _pickDetailStatus = Utils.Util.convertEnumToDic(typeof(enumOutStockDetailStatus));
 | ||
|                 }
 | ||
|                 return _pickDetailStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected Dictionary<int, string> pickRequestStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_pickRequestStatus == null)
 | ||
|                 {
 | ||
|                     _pickRequestStatus = Utils.Util.convertEnumToDic(typeof(enumOutStockRequestStatus));
 | ||
|                 }
 | ||
|                 return _pickRequestStatus;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<int, string> _plateStatus = null;
 | ||
|         protected Dictionary<int, string>  plateStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_plateStatus == null)
 | ||
|                 {
 | ||
|                     _plateStatus = Utils.Util.convertEnumToDic(typeof(enumPlateStatus));
 | ||
|                 }
 | ||
|                 return _plateStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private Dictionary<int, string> _plateLevel = null;
 | ||
|         protected Dictionary<int, string>  plateLevel
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_plateStatus == null)
 | ||
|                 {
 | ||
|                     _plateStatus = Utils.Util.convertEnumToDic(typeof(enumPlateLevel));
 | ||
|                 }
 | ||
|                 return _plateStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private Dictionary<int, string> _taskType = null;
 | ||
|         protected Dictionary<int, string>  taskType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_taskType == null)
 | ||
|                 {
 | ||
|                     _taskType = Utils.Util.convertEnumToDic(typeof(EnumFlowTaskType));
 | ||
|                 }
 | ||
|                 return _taskType;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         private Dictionary<int, string> _taskStatus = null;
 | ||
|         protected Dictionary<int, string>  taskStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_taskStatus == null)
 | ||
|                 {
 | ||
|                     _taskStatus = Utils.Util.convertEnumToDic(typeof(enumFlowTaskStatus));
 | ||
|                 }
 | ||
|                 return _taskStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         
 | ||
| 
 | ||
|         private Dictionary<int, string> _orderType = null;
 | ||
|         protected Dictionary<int, string>  orderType
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_orderType == null)
 | ||
|                 {
 | ||
|                     _orderType = Utils.Util.convertEnumToDic(typeof(enumOrderType));
 | ||
|                 }
 | ||
|                 return _orderType;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|        private Dictionary<int, string> _orderStatus = null;
 | ||
|        protected Dictionary<int, string>  orderStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_orderStatus == null)
 | ||
|                 {
 | ||
|                     _orderStatus = Utils.Util.convertEnumToDic(typeof(enumOrderStatus));
 | ||
|                 }
 | ||
|                 return _orderStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         
 | ||
| 
 | ||
|          private Dictionary<int, string> _waveStatus = null;
 | ||
|          protected Dictionary<int, string>  waveStatus
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_waveStatus == null)
 | ||
|                 {
 | ||
|                     _waveStatus = Utils.Util.convertEnumToDic(typeof(enumWaveStatus));
 | ||
|                 }
 | ||
|                 return _waveStatus;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         
 | ||
|          private Dictionary<int, string> _enumWhLocBatch = null;
 | ||
|          protected Dictionary<int, string> enWhLocBatch
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_enumWhLocBatch == null)
 | ||
|                 {
 | ||
|                     _enumWhLocBatch = Utils.Util.convertEnumToDic(typeof(enumWhLocStoreType));
 | ||
|                 }
 | ||
|                 return _enumWhLocBatch;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         Login lg ;
 | ||
|         protected void showLogin()
 | ||
|         {
 | ||
|             if (lg == null)
 | ||
|             {
 | ||
|                 lg = new Login();
 | ||
|             }
 | ||
| 
 | ||
|             IntPtr devHwnd = WinAPI.FindWindow(null, "得牛仓储管理系统");
 | ||
|             if (devHwnd != IntPtr.Zero)
 | ||
|             {
 | ||
|                 lg.Focus();
 | ||
|                 return;
 | ||
|             } 
 | ||
| 
 | ||
|            
 | ||
|             if (!lg.Focused)
 | ||
|             {
 | ||
|                 lg.ShowDialog();
 | ||
|             }
 | ||
|            // createMenus();
 | ||
|         }
 | ||
|         protected bool checkPermission(string permision)
 | ||
|         {
 | ||
|             if (WmsConstants.SPECIAL_AUTHS != null)
 | ||
|             {
 | ||
|                 return WmsConstants.SPECIAL_AUTHS.Contains(permision);
 | ||
|             }
 | ||
|             return false;
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|          protected int checkPermission(string userId,string passwd,string permision)
 | ||
|         { 
 | ||
|                 int id=   pclient.validUser(userId, Util.Encrypt(passwd));
 | ||
|                 bool rt = pclient.haveSpecialAuth(userId, Util.Encrypt(passwd), permision);
 | ||
|                 closeClient();
 | ||
|               return rt? id:-1;
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|          protected int validUser(string userId, string passwd)
 | ||
|          {
 | ||
|              int id = pclient.validUser(userId, Util.Encrypt(passwd));
 | ||
|               closeClient();
 | ||
|               return id;
 | ||
|          }       
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         protected bool isSuper()
 | ||
|         {
 | ||
|             return checkPermission(WmsConstants.SPECIAL_AUTHS_SUPER);
 | ||
|         }
 | ||
| 
 | ||
|         protected string filtRiskChar(string str) //过滤非法字符
 | ||
|         {
 | ||
|             string s = "";
 | ||
| 
 | ||
|             s = str.Replace("'", " ");
 | ||
|             s = s.Replace(";", " ");
 | ||
|             s = s.Replace("1=1", " ");
 | ||
|             s = s.Replace("|", " ");
 | ||
|             s = s.Replace("<", " ");
 | ||
|             s = s.Replace(">", " ");
 | ||
|             s = s.Replace("#", " ");
 | ||
|             s = s.Replace("insert", " ");
 | ||
|             s = s.Replace("update", " ");
 | ||
|             s = s.Replace("delete", " ");
 | ||
|             s = s.Replace("drop", " ");
 | ||
|             s = s.Replace("truncate", " ");
 | ||
|             s = s.Replace("alter", " ");
 | ||
|             s = s.Replace("create", " "); 
 | ||
|             return s.Trim();
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         //private string[] owners;
 | ||
|         private Dictionary<string,string> owners;
 | ||
|         protected Dictionary<string,string>  getOwners(bool isforce=false)
 | ||
|         {
 | ||
|             if (owners == null || isforce)
 | ||
|             {
 | ||
| 
 | ||
|                 DataTable dt = Park.getOwners(isforce);
 | ||
|                  owners = new  Dictionary<string,string>();
 | ||
| 
 | ||
|                 for (int i = 0; i < dt.Rows.Count; i++)
 | ||
|                 {
 | ||
|                     owners.Add( dt.Rows[i]["ownerCode"].ToString(), dt.Rows[i]["ownerName"].ToString());
 | ||
|                     
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             return owners;
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private Dictionary<string, string> venders;
 | ||
|         protected Dictionary<string, string> getVenders(bool isforce = false)
 | ||
|         {
 | ||
|             if (venders == null || isforce)
 | ||
|             {
 | ||
| 
 | ||
|                 DataTable dt = Park.getOwners(isforce);
 | ||
|                 owners = new Dictionary<string, string>();
 | ||
| 
 | ||
|                 for (int i = 0; i < dt.Rows.Count; i++)
 | ||
|                 {
 | ||
|                     owners.Add(dt.Rows[i]["ownerCode"].ToString(), dt.Rows[i]["ownerName"].ToString());
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             return owners;
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| /*
 | ||
|         #region EXCEL导出
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// EXCEL导出
 | ||
|         /// </summary>
 | ||
|         /// <param name="saveFileName">文件名称</param>
 | ||
|         /// <param name="gridView">待导出的gridView数据</param>
 | ||
|         public void ExportToExcel(string saveFileName, DevExpress.XtraGrid.Views.Base.BaseView gridView)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 SaveFileDialog saveDialog = new SaveFileDialog();
 | ||
|                 saveDialog.DefaultExt = "xls";
 | ||
|                 saveDialog.Filter = "导出Excel(*.xls)|*.xls";
 | ||
|                 saveDialog.FileName = saveFileName + DateTime.Now.ToString("yyyyMMddHHmmss");
 | ||
|                 if (saveDialog.ShowDialog() != DialogResult.OK)
 | ||
|                     return;
 | ||
|                 saveFileName = saveDialog.FileName;
 | ||
|                 Cursor.Current = Cursors.WaitCursor;
 | ||
|                 DevExpress.XtraExport.IExportXlsProvider provider = new DevExpress.XtraExport.ExportXlsProvider(saveFileName);
 | ||
|                 this.FindForm().Refresh();
 | ||
|                 DevExpress.XtraGrid.Export.BaseExportLink link = gridView.CreateExportLink(provider);
 | ||
|                 link.ExportAll = true;
 | ||
|                 link.Progress += new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress);//进度条事件           
 | ||
|                 link.ExportTo(true);
 | ||
|                 provider.Dispose();
 | ||
|                 link.Progress -= new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress);
 | ||
|                 Cursor.Current = Cursors.Default;
 | ||
|                 showErrorMsg("导出成功!");
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 showErrorMsg("导出失败!");
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 进度条事件      
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void Export_Progress(object sender, DevExpress.XtraGrid.Export.ProgressEventArgs e)
 | ||
|         {
 | ||
|             if (e.Phase == DevExpress.XtraGrid.Export.ExportPhase.Link)
 | ||
|             {
 | ||
|                 //  progressBarControl1.Position = e.Position;
 | ||
|                 this.Update();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         #endregion
 | ||
|         */
 | ||
| 
 | ||
|          
 | ||
|          
 | ||
|         DataSet ExcelDS = new DataSet();
 | ||
|         DataSet lblSelectDs = new DataSet();
 | ||
|          
 | ||
|         // <summary>
 | ||
|         /// 导出按钮
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void exportExcel(GridView gvSelectedItems,string strTitle="报表")
 | ||
|         {
 | ||
|             string strName = "";
 | ||
|             try
 | ||
|             {
 | ||
|                 if (gvSelectedItems.RowCount == 0)
 | ||
|                 {
 | ||
|                    showErrorMsg("Grid表格中没有数据,不能导出为Excel");
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 DateTime MMSDate = DateTime.Now;
 | ||
|                 using (SaveFileDialog saveFileDialog = new SaveFileDialog())
 | ||
|                 {
 | ||
|                     saveFileDialog.Filter = "导出Excel(*.xls)|*.xls";
 | ||
|                     saveFileDialog.FilterIndex = 0;
 | ||
|                     saveFileDialog.RestoreDirectory = true;
 | ||
|                     saveFileDialog.CreatePrompt = true;
 | ||
|                     saveFileDialog.Title = "导出文件保存路径";
 | ||
|                     //默认的文件名
 | ||
|                     saveFileDialog.FileName = this.Text + strTitle + " - " + MMSDate.ToString("yyyyMMdd");
 | ||
|                     //saveFileDialog.ShowDialog();
 | ||
|                     if (saveFileDialog.ShowDialog() == DialogResult.OK)
 | ||
|                     {
 | ||
|                         strName = saveFileDialog.FileName;
 | ||
|                         if (strName.Length != 0)
 | ||
|                         {
 | ||
|                           // gridColumn2.Visible = false;
 | ||
|                           //  gridItemID2.Visible = true;
 | ||
|                           //  gridItemID2.VisibleIndex = 0;
 | ||
|                             gvSelectedItems.ExportToXls(strName);
 | ||
|                            // gridColumn2.Visible = true;
 | ||
|                           //  gridItemID2.Visible = false;
 | ||
|                             showInfoMsg("导出Excel成功");
 | ||
|                             //关闭操作
 | ||
|                             System.Reflection.Missing miss = System.Reflection.Missing.Value;
 | ||
|                             Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
 | ||
|                             Microsoft.Office.Interop.Excel.Workbook objWorkBook = objExcel.Workbooks.Add(miss);
 | ||
|                             Microsoft.Office.Interop.Excel.Worksheet objSheet = (Microsoft.Office.Interop.Excel.Worksheet)objWorkBook.ActiveSheet;
 | ||
|                             objWorkBook.Close(null, null, null);
 | ||
|                             objExcel.Workbooks.Close();
 | ||
|                             objExcel.Quit();
 | ||
|                             System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcel);
 | ||
|                             System.Runtime.InteropServices.Marshal.ReleaseComObject(objWorkBook);
 | ||
|                             System.Runtime.InteropServices.Marshal.ReleaseComObject(objSheet);
 | ||
|                             objSheet = null;
 | ||
|                             objWorkBook = null;
 | ||
|                             objExcel = null;
 | ||
|                         }
 | ||
|                         else
 | ||
|                         {
 | ||
|                             showErrorMsg("保存的Excel名称不能为空");
 | ||
|                         }
 | ||
| 
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (System.Exception msg)
 | ||
|             {
 | ||
|                 showErrorMsg(msg.ToString());
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 GC.Collect();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         //---------------------------
 | ||
|         //导入Excel
 | ||
|         /// <summary>
 | ||
|         /// 导入按钮
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void importExcel()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 showWaitForm();
 | ||
|                 OpenFileDialog ofd = new OpenFileDialog();
 | ||
|                 ofd.Title = "Excel文件";
 | ||
|                 ofd.FileName = "";
 | ||
|                 ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 | ||
|                 ofd.Filter = "Excel文件(*.xls)|*.xls";
 | ||
|                 ofd.ValidateNames = true; //文件有效性验证ValidateNames,验证用户输入是否是一个有效的Windows文件名
 | ||
|                 ofd.CheckFileExists = true; //验证路径有效性
 | ||
|                 ofd.CheckPathExists = true; //验证文件有效性
 | ||
|                 string strName = string.Empty;
 | ||
|                 if (ofd.ShowDialog() == DialogResult.OK)
 | ||
|                 {
 | ||
|                     strName = ofd.FileName;
 | ||
|                 }
 | ||
|                 if (strName == "")
 | ||
|                 {
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 if (ReadExcel(strName))
 | ||
|                 {
 | ||
|                     showInfoMsg("数据导入结束");
 | ||
|                     //isChanged = true;
 | ||
|                 }
 | ||
|                 else
 | ||
|                     showErrorMsg("数据导入失败,请检查导入的Excel格式与数据是否正确");
 | ||
|                 this.Cursor = Cursors.Default;
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
|             catch (System.Exception Msg)
 | ||
|             {
 | ||
|                 showErrorMsg("数据导入失败,请检查导入的Excel格式与数据是否正确");
 | ||
|                 //MessageBoxShow.ShowErrMessage(Msg.ToString()+"数据导入失败,请检查导入的Excel格式与数据是否正确");
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// Excel数据导入方法
 | ||
|         /// </summary>
 | ||
|         /// <param name="filePath"></param>
 | ||
|         /// <param name="dgv"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public bool ReadExcel(string filePath)
 | ||
|         {
 | ||
|             bool isVailed = false;
 | ||
| 
 | ||
|             //根据路径打开一个Excel文件并将数据填充到ds中
 | ||
|             try
 | ||
|             {
 | ||
|                 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + filePath + ";Extended Properties ='Excel 8.0;HDR=YES;IMEX=1'";
 | ||
|                 OleDbConnection conn = new OleDbConnection(strConn);
 | ||
|                 conn.Open();
 | ||
|                 string strExcel = "";
 | ||
|                 OleDbDataAdapter myCommand = null;
 | ||
|                 //获取Excel中的sheet的名称
 | ||
|                 string SheetName = GetExcelSheetNames(filePath)[0];
 | ||
|                 //strExcel = "select * from [sheet1$]";
 | ||
|                 strExcel = "select * from [" + SheetName + "$]";
 | ||
|                 myCommand = new OleDbDataAdapter(strExcel, strConn);
 | ||
|                 // RealSailing.DataSet.SlipInfo.SLPD010_SLIPSUMHDS ds = new RealSailing.DataSet.SlipInfo.SLPD010_SLIPSUMHDS();
 | ||
|                 System.Data.DataSet ds = new System.Data.DataSet();
 | ||
|                 myCommand.Fill(ds, "table1");
 | ||
|                 conn.Close();
 | ||
|                 if (ds.Tables["table1"].Rows.Count == 0)
 | ||
|                 {
 | ||
|                     showErrorMsg("要导入的Excel没有数据");
 | ||
|                 }
 | ||
|                 ExcelDS.Clear();
 | ||
|                 showWaitForm();
 | ||
|                 clearOldData();
 | ||
|                 int testK = 0;
 | ||
|                 for (int j = 0; j < ds.Tables["table1"].Rows.Count; j++)
 | ||
|                 {
 | ||
|                     testK++;
 | ||
|                     //把数据填充到ds中
 | ||
|                     try
 | ||
|                     {
 | ||
|                         FillDataToDs(ds.Tables["table1"].Rows[j]);
 | ||
|                         isVailed = true;
 | ||
|                     }
 | ||
|                     catch (Exception e)
 | ||
|                     {
 | ||
|                         showErrorMsg(e.Message);
 | ||
|                         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
 | ||
|                         DialogResult dr =
 | ||
|                             MessageBox.Show("导入数据发生错误,是否继续?", "发生错误", messButton);
 | ||
|                         if (dr == DialogResult.OK)
 | ||
|                         {
 | ||
|                             continue;
 | ||
|                         }
 | ||
|                         else
 | ||
|                         {
 | ||
|                             break;
 | ||
|                         }
 | ||
| 
 | ||
|                     }
 | ||
|                 }
 | ||
|                 closeWaitForm();
 | ||
| 
 | ||
|             }
 | ||
|             catch (System.Data.OleDb.OleDbException ex)
 | ||
|             {
 | ||
|                 showErrorMsg(ex.Message);
 | ||
|                 if (ex.Message.IndexOf("不是一个有效名称。请确认它不包含无效的字符或标点,且名称不太长") != -1)
 | ||
|                 {
 | ||
|                     return false;
 | ||
|                 }
 | ||
|                 return false;
 | ||
|             }
 | ||
|             return true;
 | ||
|         }
 | ||
| 
 | ||
|         protected virtual void clearOldData()
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 获取获得当前你选择的Excel Sheet的所有名字
 | ||
|         /// </summary>
 | ||
|         /// <param name="filePath"></param>
 | ||
|         /// <returns></returns>
 | ||
|       /*  public static string[] GetExcelSheetNames(string filePath)
 | ||
|         {
 | ||
|             Microsoft.Office.Interop.Excel.ApplicationClass excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
 | ||
|             Microsoft.Office.Interop.Excel.Workbooks wbs = excelApp.Workbooks;
 | ||
|             Microsoft.Office.Interop.Excel.Workbook wb = wbs.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
 | ||
|             Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
 | ||
|             Type.Missing, Type.Missing, Type.Missing, Type.Missing);
 | ||
|             int count = wb.Worksheets.Count;
 | ||
|             string[] names = new string[count];
 | ||
|             for (int i = 1; i <= count; i++)
 | ||
|             {
 | ||
|                 names[i - 1] = ((Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[i]).Name;
 | ||
|             }
 | ||
|             wb.Close(null, null, null);
 | ||
|             excelApp.Quit();
 | ||
|             wbs.Close();
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs);
 | ||
|             excelApp = null;
 | ||
|             wbs = null;
 | ||
|             wb = null;
 | ||
|             return names;
 | ||
|         }
 | ||
|         */
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 处理具体数据
 | ||
|         /// 将在各子form重写逻辑
 | ||
|         /// </summary>
 | ||
|         /// <param name="dr"></param>
 | ||
|         protected virtual void FillDataToDs(DataRow dr) //string itemid, string itemplu, string itemName)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         //---------------------------
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         //导入Excel
 | ||
|         /// <summary>
 | ||
|         /// 导入按钮
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void importExcel(GridView gvSelectedItems)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 OpenFileDialog ofd = new OpenFileDialog();
 | ||
|                 ofd.Title = "Excel文件";
 | ||
|                 ofd.FileName = "";
 | ||
|                 ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 | ||
|                 ofd.Filter = "Excel文件(*.xls)|*.xls";
 | ||
|                 ofd.ValidateNames = true; //文件有效性验证ValidateNames,验证用户输入是否是一个有效的Windows文件名
 | ||
|                 ofd.CheckFileExists = true; //验证路径有效性
 | ||
|                 ofd.CheckPathExists = true; //验证文件有效性
 | ||
|                 string strName = string.Empty;
 | ||
|                 if (ofd.ShowDialog() == DialogResult.OK)
 | ||
|                 {
 | ||
|                     strName = ofd.FileName;
 | ||
|                 }
 | ||
|                 if (strName == "")
 | ||
|                 {
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 if (EcxelToGridView(strName, gvSelectedItems))
 | ||
|                 {
 | ||
|                     showErrorMsg("数据导入成功" );
 | ||
|                     //isChanged = true;
 | ||
|                 }
 | ||
|                 else
 | ||
|                     showErrorMsg("数据导入失败,请检查导入的Excel格式与数据是否正确" );
 | ||
|                 this.Cursor = Cursors.Default;
 | ||
|             }
 | ||
|             catch (System.Exception Msg)
 | ||
|             {
 | ||
|                 showErrorMsg("数据导入失败,请检查导入的Excel格式与数据是否正确" );
 | ||
|                 //MessageBoxShow.ShowErrMessage(Msg.ToString()+"数据导入失败,请检查导入的Excel格式与数据是否正确");
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// Excel数据导入方法
 | ||
|         /// </summary>
 | ||
|         /// <param name="filePath"></param>
 | ||
|         /// <param name="dgv"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public bool EcxelToGridView(string filePath, DevExpress.XtraGrid.Views.Grid.GridView dgv)
 | ||
|         {
 | ||
|             bool isVailed = false;
 | ||
|             string itemid = string.Empty;
 | ||
|             string itemplu = string.Empty;
 | ||
|             string itemName = string.Empty;
 | ||
|             //根据路径打开一个Excel文件并将数据填充到ds中
 | ||
|             try
 | ||
|             {
 | ||
|                 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + filePath + ";Extended Properties ='Excel 8.0;HDR=YES;IMEX=1'";
 | ||
|                 OleDbConnection conn = new OleDbConnection(strConn);
 | ||
|                 conn.Open();
 | ||
|                 string strExcel = "";
 | ||
|                 OleDbDataAdapter myCommand = null;
 | ||
|                 //获取Excel中的sheet的名称
 | ||
|                 string SheetName= GetExcelSheetNames(filePath)[0];
 | ||
|                 //strExcel = "select * from [sheet1$]";
 | ||
|                 strExcel = "select * from [" + SheetName + "$]";
 | ||
|                 myCommand = new OleDbDataAdapter(strExcel, strConn);
 | ||
|                 // RealSailing.DataSet.SlipInfo.SLPD010_SLIPSUMHDS ds = new RealSailing.DataSet.SlipInfo.SLPD010_SLIPSUMHDS();
 | ||
|                 System.Data.DataSet ds = new System.Data.DataSet();
 | ||
|                 myCommand.Fill(ds, "table1");
 | ||
|                 conn.Close();
 | ||
|                 if (ds.Tables["table1"].Rows.Count == 0)
 | ||
|                 {
 | ||
|                     showErrorMsg("要导入的Excel没有数据");
 | ||
|                 }
 | ||
|                 ExcelDS.Clear();
 | ||
|                 for (int j = 0; j < ds.Tables["table1"].Rows.Count; j++)
 | ||
|                 {
 | ||
|                     if (ds.Tables["table1"].Rows[j]["商品id"].ToString().Trim() != string.Empty)
 | ||
|                         itemid = ds.Tables["table1"].Rows[j]["商品id"].ToString().Trim();
 | ||
|                     if (ds.Tables["table1"].Rows[j]["商品货号"].ToString().Trim() != string.Empty)
 | ||
|                         itemplu = ds.Tables["table1"].Rows[j]["商品货号"].ToString().Trim();
 | ||
|                     else
 | ||
|                         itemplu = " ";
 | ||
|                     if (ds.Tables["table1"].Rows[j]["商品名称"].ToString().Trim() != string.Empty)
 | ||
|                         itemName = ds.Tables["table1"].Rows[j]["商品名称"].ToString().Trim();
 | ||
|                     //把数据填充到ds中
 | ||
|                     FillDataToDs(itemid, itemplu, itemName);
 | ||
|                     isVailed = true;
 | ||
|                 }
 | ||
|                 
 | ||
|             }
 | ||
|             catch (System.Data.OleDb.OleDbException ex)
 | ||
|             {
 | ||
|                 if (ex.Message.IndexOf("不是一个有效名称。请确认它不包含无效的字符或标点,且名称不太长") != -1)
 | ||
|                 {
 | ||
|                     return false;
 | ||
|                 }
 | ||
|                 return false;
 | ||
|             }
 | ||
|             return true;
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 获取获得当前你选择的Excel Sheet的所有名字
 | ||
|         /// </summary>
 | ||
|         /// <param name="filePath"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public static string[] GetExcelSheetNames(string filePath)
 | ||
|         {
 | ||
|            // Microsoft.Office.Interop.Excel.ApplicationClass excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
 | ||
|             Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
 | ||
|             Microsoft.Office.Interop.Excel.Workbooks wbs = excelApp.Workbooks;
 | ||
|             Microsoft.Office.Interop.Excel.Workbook wb = wbs.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
 | ||
|             Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
 | ||
|             Type.Missing, Type.Missing, Type.Missing, Type.Missing);
 | ||
|             int count = wb.Worksheets.Count;
 | ||
|             string[] names = new string[count];
 | ||
|             for (int i = 1; i <= count; i++)
 | ||
|             {
 | ||
|                 names[i - 1] = ((Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[i]).Name;
 | ||
|             }
 | ||
|             wb.Close(null, null, null);
 | ||
|             excelApp.Quit();
 | ||
|             wbs.Close();
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
 | ||
|             System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs);
 | ||
|             excelApp = null;
 | ||
|             wbs = null;
 | ||
|             wb = null;
 | ||
|             return names;
 | ||
|         }
 | ||
|         private void FillDataToDs(string itemid, string itemplu, string itemName)
 | ||
|         {
 | ||
|             DataRow[] rows = lblSelectDs.Tables["MSTM150_ITEM"].Select(string.Format("MSTM150_ITEMID='{0}'", itemid));
 | ||
|             if (rows.Length == 0)
 | ||
|             {
 | ||
|                 if (itemid.Trim() != string.Empty && itemplu.Trim() != string.Empty && itemName != string.Empty)
 | ||
|                 {
 | ||
|                     DataRow dr;
 | ||
|                     dr = lblSelectDs.Tables["MSTM150_ITEM"].NewRow();
 | ||
|                    // dr[MSTM150_ITEM.MSTM150_ITEMID] = itemid;
 | ||
|                     dr["MSTM151_PLUCD"] = itemplu;
 | ||
|                     dr["MSTM150_ITEMCNM"] = itemName;
 | ||
|                     dr["CheckRemove"] = "0";
 | ||
|                     lblSelectDs.Tables["MSTM150_ITEM"].Rows.Add(dr);
 | ||
|                 }
 | ||
|                 //else if (itemid.Trim() == string.Empty)
 | ||
|                 //{
 | ||
|                 //    string st = "导入的商品id不允许为空";
 | ||
|                 //    sb.Append(st);
 | ||
|                 //    sb.Append("\r\n");
 | ||
|                 //}
 | ||
|                 //else if (itemplu.Trim() == string.Empty)
 | ||
|                 //{
 | ||
|                 //    string st = "导入的商品编码不允许为空";
 | ||
|                 //    sb.Append(st);
 | ||
|                 //    sb.Append("\r\n");
 | ||
|                 //}
 | ||
|                 //else if (itemName.Trim() == string.Empty)
 | ||
|                 //{
 | ||
|                 //    string st = "导入的商品名称不允许为空";
 | ||
|                 //    sb.Append(st);
 | ||
|                 //    sb.Append("\r\n");
 | ||
|                 //}
 | ||
|             }
 | ||
|             else if(rows.Length>0)
 | ||
|             {
 | ||
|                 ExcelDS.Tables["MSTM150_ITEM"].ImportRow(rows[0]);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         //------------------------------------------------checkbox------------------------------
 | ||
| 
 | ||
|         #region GridControl checkbox
 | ||
|         /// <summary>
 | ||
|         /// 是否选中
 | ||
|         /// </summary>
 | ||
|         public const string CheckBoxField = "选择";
 | ||
|         private static bool chkState = false;
 | ||
| 
 | ||
|         public static bool ChkState
 | ||
|         {
 | ||
|             get { return BasicRibbonForm.chkState; }
 | ||
|             set { BasicRibbonForm.chkState = value; }
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
|         //复选框列名称
 | ||
|         private static string chkFileName = "选择";
 | ||
| 
 | ||
|         protected string chkKey = "";
 | ||
| 
 | ||
|        protected GridColumn colChk = new GridColumn() { Caption = CheckBoxField, Visible = true, FieldName = CheckBoxField };
 | ||
|     
 | ||
|         //复选框列宽
 | ||
|         private static int chkWidth = 30;
 | ||
|         //GridView 
 | ||
|         public static DevExpress.XtraGrid.Views.Grid.GridView GView = null;
 | ||
|         public void addCheckField(DataTable dt,bool isChecked=true)
 | ||
|         {
 | ||
|             if (!dt.Columns.Contains(CheckBoxField))
 | ||
|             {
 | ||
|                 dt.Columns.Add(CheckBoxField, System.Type.GetType("System.Boolean"));
 | ||
|                 dt.Columns[CheckBoxField].DefaultValue = Boolean.TrueString;
 | ||
|                 for (int i = 0; i < dt.Rows.Count; i++)
 | ||
|                 { 
 | ||
|                     dt.Rows[i][CheckBoxField] = isChecked;
 | ||
|                 }
 | ||
|                 calculateSelectedValue();
 | ||
|             }
 | ||
|         }
 | ||
|         private DevExpress.XtraGrid.Views.Grid.GridView gView
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (GView == null)
 | ||
|                 {
 | ||
|                     GView = new DevExpress.XtraGrid.Views.Grid.GridView();
 | ||
|                 }
 | ||
|                 return GView;
 | ||
|             }
 | ||
|             set
 | ||
|             {
 | ||
|                 this.gView = value;
 | ||
|             }
 | ||
|         }
 | ||
|         public DataTable DtGv = null;
 | ||
|        
 | ||
|         private DataTable dtGv
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (DtGv == null)
 | ||
|                 {
 | ||
|                     DtGv = new DataTable();
 | ||
|                 }
 | ||
|                 return DtGv;
 | ||
|             }
 | ||
|             set
 | ||
|             {
 | ||
|                 this.DtGv = value;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         public void GridCheckEdit(DevExpress.XtraGrid.Views.Grid.GridView gv , string checkFileName, int checkWidth)
 | ||
|         {
 | ||
|             if (gv != null)
 | ||
|             {
 | ||
|                 chkFileName = checkFileName;
 | ||
|                 chkWidth = checkWidth;
 | ||
|                 GView = gv;
 | ||
|                
 | ||
|                 //不显示复选框的列标题
 | ||
|                 gv.Columns[chkFileName].OptionsColumn.ShowCaption = false;
 | ||
|                 DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryItemCheckEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
 | ||
| 
 | ||
|                 //复选框的形状   gv.Columns[chkFileName].ColumnEdit 实例是 repositoryItemCheckEdit1              
 | ||
|                 repositoryItemCheckEdit1.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
 | ||
|                 ////复选框加载的状态     实心   空心   空心打勾
 | ||
|                 repositoryItemCheckEdit1.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
 | ||
|                 gv.Columns[chkFileName].ColumnEdit = repositoryItemCheckEdit1;
 | ||
|                 //点击事件
 | ||
|                 gv.Click += new System.EventHandler(gv_Click);
 | ||
|                 //画列头CheckEdit
 | ||
|                 gv.CustomDrawColumnHeader += new DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventHandler(gv_CustomDrawColumnHeader);
 | ||
|                 //gv.DataSourceChanged += new EventHandler(gv_DataSourceChanged);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|         private void gv_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
 | ||
|         {
 | ||
|             if (e.Column != null && e.Column.FieldName == chkFileName)
 | ||
|             {
 | ||
|                 e.Info.InnerElements.Clear();
 | ||
|                 e.Painter.DrawObject(e.Info);
 | ||
|                 DrawCheckBox(e, chkState);
 | ||
|                 e.Handled = true;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private static void gv_DataSourceChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             DevExpress.XtraGrid.Columns.GridColumn column = GView.Columns.ColumnByFieldName(chkFileName);
 | ||
|             if (column != null)
 | ||
|             {
 | ||
|               //  column.Width = chkWidth;
 | ||
|               //  column.OptionsColumn.ShowCaption = false;
 | ||
|                // column.ColumnEdit = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
 | ||
|                 GView.Columns[chkFileName].OptionsColumn.ShowCaption = false;
 | ||
|                 DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryItemCheckEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
 | ||
| 
 | ||
|                 //复选框的形状   gv.Columns[chkFileName].ColumnEdit 实例是 repositoryItemCheckEdit1              
 | ||
|                 repositoryItemCheckEdit1.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
 | ||
|                 ////复选框加载的状态     实心   空心   空心打勾
 | ||
|                 repositoryItemCheckEdit1.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
 | ||
|                 GView.Columns[chkFileName].ColumnEdit = repositoryItemCheckEdit1;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void DrawCheckBox(DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e, bool chk)
 | ||
|         {
 | ||
|             DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryCheck = e.Column.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit;
 | ||
|             if (repositoryCheck != null)
 | ||
|             {
 | ||
|                 System.Drawing.Graphics g = e.Graphics;
 | ||
|                 System.Drawing.Rectangle r = e.Bounds;
 | ||
| 
 | ||
|                 DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo info;
 | ||
|                 DevExpress.XtraEditors.Drawing.CheckEditPainter painter;
 | ||
|                 DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs args;
 | ||
|                 info = repositoryCheck.CreateViewInfo() as DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo;
 | ||
| 
 | ||
|                 painter = repositoryCheck.CreatePainter() as DevExpress.XtraEditors.Drawing.CheckEditPainter;
 | ||
|                 info.EditValue = chk;
 | ||
|                 info.Bounds = r;
 | ||
|                 info.CalcViewInfo(g);
 | ||
|                 args = new DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs(info, new DevExpress.Utils.Drawing.GraphicsCache(g), r);
 | ||
|                 painter.Draw(args);
 | ||
|                 args.Cache.Dispose();
 | ||
|             }
 | ||
|         }
 | ||
|         private void gv_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 if (ClickGridCheckBox(GView, chkFileName, chkState))
 | ||
|                 {
 | ||
|                     chkState = !chkState;
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
|         private bool ClickGridCheckBox(DevExpress.XtraGrid.Views.Grid.GridView gridView, string fieldName, bool currentStatus)
 | ||
|         {
 | ||
|          //   debug(string.Format("grid view clicked! fieldName is {0}, currentStatus is {1}",fieldName,currentStatus));
 | ||
| 
 | ||
|             bool result = false;
 | ||
|             if (gridView != null)
 | ||
|             {
 | ||
|                 if (dtGv.Rows.Count == 0)
 | ||
|                 {
 | ||
|                    // debug(string.Format("dtGv.Rows.Count == 0, return"));
 | ||
|                     return true;  
 | ||
|                 }
 | ||
|                 //禁止排序 
 | ||
|                 gridView.ClearSorting();
 | ||
|                  
 | ||
|                 gridView.PostEditor();
 | ||
|                 DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo info;
 | ||
|                 System.Drawing.Point pt = gridView.GridControl.PointToClient(Control.MousePosition);
 | ||
|                 info = gridView.CalcHitInfo(pt);
 | ||
|                 //info.InColumn 在列标题上
 | ||
|               /*   
 | ||
|                 if (gridView.GetSelectedCells() == null 
 | ||
|                     || gridView.GetSelectedCells().Length== 0)
 | ||
|                 {
 | ||
|                     debug(string.Format("gridView.GetSelectedCells() == null or length is 0, return true"));
 | ||
|                     return true;
 | ||
|                 }*/
 | ||
|                 string nm = "";
 | ||
|                 if (gridView.GetSelectedCells() != null
 | ||
|                    && gridView.GetSelectedCells().Length> 0)
 | ||
|                 {
 | ||
|                     
 | ||
|                     nm = gridView.GetSelectedCells()[0].Column.FieldName;
 | ||
|                    // debug(string.Format(" nm is " +nm));
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                    // debug(string.Format("gridView.GetSelectedCells() == null or length is 0"));
 | ||
|                   //  return true;
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                  
 | ||
|              //   string nm = gridView.GetSelectedRows()[0].;
 | ||
|                int selectRowHandle = gridView.FocusedRowHandle;
 | ||
|               //  debug(string.Format("  gridView.FocusedRowHandle : '{0}', info.RowHandle {1}", gridView.FocusedRowHandle,info.RowHandle));
 | ||
|                 if (gridView.FocusedRowHandle != info.RowHandle)
 | ||
|                 {
 | ||
|                     gridView.FocusedRowHandle = info.RowHandle >0? info.RowHandle: gridView.FocusedRowHandle;
 | ||
|                 }
 | ||
|                
 | ||
|                 //  info.RowHandle
 | ||
|                 if (info.Column != null)
 | ||
|                 {
 | ||
|                   //  debug(string.Format("info.Column.FieldName :'{0}' , fieldName :'{1}', nm :'{2}'", info.Column.FieldName, fieldName, nm));
 | ||
|                 }
 | ||
|                 else {
 | ||
|                    // debug(string.Format("  gridView.GetSelectedCells()[0].Column.FieldName :'{0}'", nm));
 | ||
|                 }
 | ||
|                
 | ||
|                 if (info.Column != null && info.Column.FieldName == fieldName || nm == fieldName)
 | ||
|                 {
 | ||
|                    // debug(string.Format("is point in header info.InColumn? '{0}'", info.InColumn));
 | ||
|                     if (info.InColumn) //全选、全不选
 | ||
|                     {
 | ||
|                         for (int i = 0; i < dtGv.Rows.Count; i++)
 | ||
|                         {
 | ||
|                            // debug(string.Format("SetRowCellValue: row {0},fieldName{1},status{2}", i, fieldName, !currentStatus));
 | ||
|                             gridView.SetRowCellValue(i, fieldName, !currentStatus);
 | ||
|                             dtGv.Rows[i][fieldName] = !currentStatus;
 | ||
|                         }
 | ||
|                           return true;
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         // DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryCheck = info.Column.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit;
 | ||
|                        // info.RowHandle = selectRowHandle;
 | ||
|                      //   debug(string.Format("info.RowHandle:{0},dtGv.Rows.Count:{1} ", info.RowHandle, dtGv.Rows.Count));
 | ||
|                         if (info.RowHandle >= 0 && info.RowHandle < dtGv.Rows.Count)
 | ||
|                         {
 | ||
|                             string v = dtGv.Rows[info.RowHandle][fieldName].ToString();
 | ||
|                             bool b = String.IsNullOrEmpty(v) ? false : Convert.ToBoolean(v);
 | ||
|                           //  debug(string.Format("value of point cell:'{0}'",b));
 | ||
|                             dtGv.Rows[info.RowHandle][fieldName] = !b;
 | ||
|                             gridView.SetRowCellValue(info.RowHandle, fieldName, !b);
 | ||
|                            return true;
 | ||
|                         }
 | ||
|                     }
 | ||
| 
 | ||
|                     calculateSelectedValue();
 | ||
|                     return true;
 | ||
|                 }
 | ||
|             }
 | ||
|             return result;
 | ||
|         }
 | ||
|          
 | ||
|         #endregion
 | ||
| 
 | ||
| 
 | ||
|         protected virtual void calculateSelectedValue()
 | ||
|         {
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>  
 | ||
|         /// 写入配置信息  
 | ||
|         /// </summary>  
 | ||
|         protected void writeConfig(string key, string value)
 | ||
|         {
 | ||
|             //ShowText("正在写入配置文件!请稍等....");
 | ||
| 
 | ||
|             string appConfigPath = Application.StartupPath + "\\" + Application.ProductName + ".exe"; 
 | ||
| 
 | ||
|             ConfigurationOperator co = new ConfigurationOperator(appConfigPath, ConfigType.ExeConfig);
 | ||
| 
 | ||
|             co.AddAppSetting(key, value);
 | ||
| 
 | ||
| 
 | ||
|             co.Save();
 | ||
|         }
 | ||
|         
 | ||
|         protected string getConfigValue(string key)
 | ||
|         {
 | ||
|             return System.Configuration.ConfigurationManager.AppSettings[key];
 | ||
|         }
 | ||
| 
 | ||
|       
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| } |