1421 lines
		
	
	
		
			46 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1421 lines
		
	
	
		
			46 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.XtraGrid.Views.Base;
 | |
| //using DeiNiu.wms.Logical;
 | |
| using DeiNiu.wms.Data;
 | |
| using DevExpress.XtraGrid.Columns;
 | |
| using DeiNiu.wms.win.utils;
 | |
| using System.Threading;
 | |
| using DevExpress.XtraGrid.Views.Grid;
 | |
| using DevExpress.XtraEditors.DXErrorProvider;
 | |
| using DeiNiu.wms.Data.Model;
 | |
| using DevExpress.XtraEditors;
 | |
| using DevExpress.XtraEditors.Controls;
 | |
| using DeiNiu.Utils;
 | |
| using DeiNiu.wms.win.utils.print;
 | |
| using DeiNiu.wms.Logical;
 | |
| using Microsoft.VisualBasic;
 | |
| 
 | |
| 
 | |
| namespace DeiNiu.wms.win
 | |
| {
 | |
|     public partial class SeedsImport : BasicRibbonForm
 | |
|     {
 | |
| 
 | |
|         lWmsImportSeeds lis = new lWmsImportSeeds();
 | |
|         WmsImportSeeds wis = new WmsImportSeeds();
 | |
|         //  lWmslocation lgt = new lWmslocation();
 | |
|         private string fieldName = Wmslocation.fields.locationId.ToString();
 | |
|         int count,seedscnt,  seedsPlanCnt = 0;  
 | |
|         private string lastQuery = "";
 | |
|         private DataTable dt;
 | |
|         private int selectedRowIndex = -1;
 | |
|         private bool isAdding = true;
 | |
|         private LocStructs locs;
 | |
|         //    private List<Wmslocation> selectedLocations;
 | |
|         private List<int> selectedIds;
 | |
|         public SeedsImport()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             initialControls();
 | |
|             //    loadData();
 | |
|         }
 | |
|         #region initialControls
 | |
|         private void initialControls()
 | |
|         {
 | |
|             initialComboBoxes();
 | |
|             initialPagerControls();
 | |
|             initialDataGrid();
 | |
|             initialQueryInput();
 | |
|             swithOperationType();
 | |
|             setValidationRule();
 | |
|             this.lcgSetup.Expanded = false;
 | |
| 
 | |
|         }
 | |
|         private void initialComboBoxes()
 | |
|         {
 | |
|             //initial combobox of port
 | |
| 
 | |
|             this.dateEditFrom.EditValue = DateTime.Now.AddDays(-1 * 3);
 | |
|             this.dateEditTo.EditValue = DateTime.Now.AddDays(1);
 | |
| 
 | |
|             this.comStatus.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | |
|             ComboBoxItemCollection col2 = comStatus.Properties.Items;
 | |
|             col2.BeginUpdate(); 
 | |
|             try
 | |
|             {
 | |
|                 col2.Add("全部数据");
 | |
|                 col2.Add("初始导入");
 | |
|                 col2.Add("等待分播");
 | |
|                 col2.Add("正在分播");
 | |
|                 col2.Add("完成分播");
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 col2.EndUpdate();
 | |
|             }
 | |
|             comStatus.SelectedIndex = 0;
 | |
| 
 | |
| 
 | |
|             //initial comboboxedits with dic
 | |
|           //  Node[] nds = { };
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void setValidationRule()
 | |
|         {
 | |
|             // dxValidationProvider1.SetValidationRule(comWarehouseQuery, ValidationRules.notEmptyValidationRule);
 | |
|             //txtGoodType.Properties.MaxLength = 40;
 | |
|             //txtGoodDesc.Properties.MaxLength = 250;
 | |
|             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength;
 | |
|         }
 | |
| 
 | |
|         private void initialQueryInput()
 | |
|         {
 | |
|             oDeskId = System.Configuration.ConfigurationManager.AppSettings["partionId"];
 | |
|             if (!string.IsNullOrEmpty(oDeskId))
 | |
|             {
 | |
|                 txtPartion.Text = oDeskId;
 | |
| 
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 oDeskId = "";
 | |
|             }
 | |
|         }
 | |
|         private void initialPagerControls()
 | |
|         {
 | |
| 
 | |
|             pager1.MaximumSize = new Size(0, 20);
 | |
|             pager1.EventPaging += new DeiNiu.Controls.pager.EventPagingHandler(pager_EventPaging);
 | |
|             #region DataGridView与Pager控件绑定
 | |
|             this.pager1.PageCurrent = 1;//当前页为第一页  
 | |
|             pager1.PageSize = 200;//每页行数  
 | |
|             this.pager1.Bind();//绑定  
 | |
|             #endregion
 | |
| 
 | |
|         }
 | |
|         private void initialDataGrid()
 | |
|         {
 | |
| 
 | |
|             this.gridView1.OptionsBehavior.AutoPopulateColumns = false;
 | |
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | |
|             this.gridView1.OptionsBehavior.Editable = false;
 | |
|             this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
 | |
| 
 | |
|             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | |
|             this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | |
|             gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText;
 | |
|             //show line number
 | |
|             this.gridView1.IndicatorWidth = 60;
 | |
|             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator);
 | |
|              gridView1.RowCellStyle += gridView1_RowCellStyle ;
 | |
|             gridView1.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | |
|         }
 | |
|         //显示行的序号    
 | |
|         private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
 | |
|         {
 | |
|             if (e.Info.IsRowIndicator && e.RowHandle >= 0)
 | |
|             {
 | |
|                 e.Info.DisplayText = (e.RowHandle + 1).ToString();
 | |
|             }
 | |
|         }
 | |
|         private void initialDataGridColumns()
 | |
|         {
 | |
|             setupGridView(gridView1, true);
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridView1.Columns.Clear();
 | |
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | |
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | |
|             myCol0.Visible = false;
 | |
|             this.gridView1.Columns.Add(myCol0);
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "播种单号", Visible = true, FieldName = WmsImportSeeds.fields.seedsNo.ToString(), MinWidth = 100 };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "商品编号", Visible = true, FieldName = WmsImportSeeds.fields.barcode.ToString(), MinWidth = 100 };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsImportSeeds.fields.itemName.ToString(), MaxWidth = 300 };
 | |
|           //  GridColumn myCol4 = new GridColumn() { Caption = "大类名", Visible = true, FieldName = WmsImportSeeds.fields.category1.ToString(), MaxWidth = 100 };
 | |
|           //  GridColumn myCol5 = new GridColumn() { Caption = "中类名", Visible = true, FieldName = WmsImportSeeds.fields.category2.ToString(), MaxWidth = 100 };
 | |
|            // GridColumn myCol6 = new GridColumn() { Caption = "小类名", Visible = true, FieldName = WmsImportSeeds.fields.category3.ToString(), MaxWidth = 100 };
 | |
|             GridColumn myCol7 = new GridColumn() { Caption = "门店名称", Visible = true, FieldName = WmsImportSeeds.fields.custName.ToString(), MaxWidth = 200 };
 | |
|             GridColumn myCol8 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsImportSeeds .fields.unit.ToString(), MaxWidth = 80};
 | |
|             GridColumn myCol9 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsImportSeeds.fields.spec.ToString(), MaxWidth = 120 };
 | |
|             GridColumn myCol10 = new GridColumn() { Caption = "计划数量", Visible = true, FieldName = WmsImportSeeds.fields.count.ToString(), MaxWidth = 80 };
 | |
| 
 | |
|             GridColumn myCol11 = new GridColumn() { Caption = "实发数量", Visible = true, FieldName = WmsImportSeeds.fields.countOut.ToString(), MaxWidth = 80 };
 | |
|          //   GridColumn myCol12 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsImportSeeds.fields.state.ToString(), MinWidth = 80 };
 | |
|             GridColumn myCol13 = new GridColumn() { Caption = "分播员ID", Visible = true, FieldName = WmsImportSeeds.fields.operater.ToString(), MaxWidth = 80 };
 | |
|             GridColumn myCol12 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "statedesc", MinWidth = 80 };
 | |
|             GridColumn myCol14 = new GridColumn() { Caption = "分播时间", Visible = true, FieldName = WmsImportSeeds.fields.picktime.ToString(),MinWidth = 150 , MaxWidth = 250};
 | |
|             GridColumn myCol15 = new GridColumn() { Caption = "导入时间", Visible = true, FieldName = "createtime", MinWidth = 150, MaxWidth = 250 };
 | |
|             GridColumn myCol16 = new GridColumn() { Caption = "分区", Visible = true, FieldName = WmsImportSeeds.fields.partion.ToString(),   MaxWidth =  50 };
 | |
|             GridColumn myCol17 = new GridColumn() { Caption = "分播台", Visible = true, FieldName = WmsImportSeeds.fields.deskId.ToString(), MaxWidth = 80 };
 | |
|             GridColumn myCol18 = new GridColumn() { Caption = "店铺排序", Visible = true, FieldName = WmsImportSeeds.fields.port.ToString(), MaxWidth = 80 };
 | |
|            
 | |
| 
 | |
| 
 | |
| 
 | |
|             this.gridView1.Columns.Add(myCol1);            
 | |
|             this.gridView1.Columns.Add(myCol3);
 | |
|             this.gridView1.Columns.Add(myCol16);
 | |
|             this.gridView1.Columns.Add(myCol17);
 | |
|             this.gridView1.Columns.Add(myCol18);
 | |
| 
 | |
|             this.gridView1.Columns.Add(myCol7);
 | |
|             this.gridView1.Columns.Add(myCol10);
 | |
|             this.gridView1.Columns.Add(myCol11);
 | |
|             this.gridView1.Columns.Add(myCol8); 
 | |
| 
 | |
|             this.gridView1.Columns.Add(myCol2);
 | |
|            
 | |
|            
 | |
|              this.gridView1.Columns.Add(myCol9);
 | |
|         
 | |
|              
 | |
|            
 | |
|             this.gridView1.Columns.Add(myCol12);
 | |
|             this.gridView1.Columns.Add(myCol13);
 | |
|             this.gridView1.Columns.Add(myCol14);
 | |
|             
 | |
|             this.gridView1.Columns.Add(myCol7); 
 | |
|          
 | |
|            // this.gridView1.Columns.Add(myCol4);
 | |
|          //   this.gridView1.Columns.Add(myCol5);
 | |
|          //   this.gridView1.Columns.Add(myCol6);
 | |
|             this.gridView1.Columns.Add(myCol15);
 | |
| 
 | |
|             gridView1.BestFitColumns();
 | |
|             //gridView1.Focus();
 | |
|             gridView1.OptionsView.ColumnAutoWidth = false;
 | |
| 
 | |
|             //自动列宽
 | |
|             //gridView1.OptionsView.ColumnAutoWidth = false;
 | |
|             //this.gridView1.BestFitColumns();
 | |
|             //this.gridView1.Columns[2].MinWidth = 500;
 | |
|             //this.gridView1.Columns[1].BestFit();
 | |
|             //for (int I = 0; I < gridView1.Columns.Count; I++)
 | |
|             //{
 | |
| 
 | |
|             //     this.gridView1.Columns[I].BestFit()
 | |
|             //}
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 设置列表数据的日期格式
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         public static void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 | |
|         {
 | |
| 
 | |
|             if (e.Column.FieldName == "createtime" || e.Column.FieldName ==   "picktime")
 | |
|             {
 | |
|                 e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
 | |
|             }
 | |
| 
 | |
|         }
 | |
|         private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrEmpty(e.DisplayText))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|              
 | |
|           if (e.Column.FieldName == "state")
 | |
|             {
 | |
|                if ("0".Equals(e.DisplayText))
 | |
|                 {
 | |
|                     e.DisplayText = "初始导入";
 | |
|                 }
 | |
|                 else if   ("1".Equals(e.DisplayText))
 | |
|                 {
 | |
|                     e.DisplayText = "等待分播";
 | |
|                 }
 | |
|                 else if ("2".Equals(e.DisplayText))
 | |
|                 {
 | |
|                     e.DisplayText = "正在分播";
 | |
|                 }
 | |
|                 else if ("3".Equals(e.DisplayText))
 | |
|                 {
 | |
|                     e.DisplayText = "完成分播";
 | |
|                 }
 | |
|             }
 | |
|           else if (e.Column.FieldName == "operater")
 | |
|           {
 | |
|               if ("0".Equals(e.DisplayText))
 | |
|               {
 | |
|                   e.DisplayText = "";
 | |
|               }
 | |
|           }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// loading data
 | |
|         /// </summary>  
 | |
|         private int loadData()
 | |
|         {
 | |
|             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 clearInputs();
 | |
|                 showWaitForm();
 | |
|                 string query = "";
 | |
| 
 | |
|                 query = (txtSeedsNo.Text.Trim().Length > 1 ? string.Format("{0} =#'{1}';", WmsImportSeeds.fields.seedsNo.ToString(), filtRiskChar(txtSeedsNo.Text)) : "");
 | |
|                   
 | |
|                 if(!this.checkDone.Checked){
 | |
|                     query +=  (this.dateEditFrom.Text.Trim().Length == 0 ? "" : string.Format("{0} >= # '{1}';", "createtime", dateEditFrom.DateTime))                   
 | |
|                     + (this.dateEditTo.Text.Trim().Length == 0 ? "" : string.Format("{0} <= # '{1}';", "createtime", dateEditTo.DateTime));
 | |
|                 }else{
 | |
| 
 | |
|                     query += (this.dateEditFrom.Text.Trim().Length == 0 ? "" : string.Format("{0} >=#'{1}';", WmsImportSeeds.fields.picktime.ToString(), dateEditFrom.Text.Trim()))
 | |
|                    + (this.dateEditTo.Text.Trim().Length == 0 ? "" : string.Format("{0} <=#'{1}';", WmsImportSeeds.fields.picktime.ToString(), dateEditTo.Text.Trim()));
 | |
|                 }
 | |
|                   query += 
 | |
|                      (this.txtOperater.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.operater.ToString(), txtOperater.Text.Trim()))
 | |
|             
 | |
|                   + (this.txtBarcode.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.barcode.ToString(), txtBarcode.Text.Trim()))
 | |
|                  + (this.comStatus.SelectedIndex == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.state.ToString(), this.comStatus.SelectedIndex-1))
 | |
|                  + (this.chkDiff.Checked ? string.Format("{0} !=#{1};", WmsImportSeeds.fields.count.ToString(), WmsImportSeeds.fields.countOut.ToString()) : "")
 | |
|                  + (this.txtCustNm.Text.Trim().Length == 0 ? "" : string.Format("{0} like #'%{1}%';", WmsImportSeeds.fields.custName.ToString(), txtCustNm.Text.Trim()))
 | |
|                  + (this.txtItemNmq.Text.Trim().Length == 0 ? "" : string.Format("{0} like #'%{1}%';", WmsImportSeeds.fields.itemName.ToString(), txtItemNmq.Text.Trim()))
 | |
|                     + (this.txtPartionQ.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.partion.ToString(), txtPartionQ.Text.Trim()))
 | |
|                  + (this.txtDeskId.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.deskId.ToString(), txtDeskId.Text.Trim()))
 | |
|               
 | |
|                    ;
 | |
|                  
 | |
|                 this.pager1.PageCurrent = lastQuery.Equals(query) ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | |
| 
 | |
|                 this.pager1.PageCurrent = this.pager1.PageCurrent > 0 ? this.pager1.PageCurrent : 1;
 | |
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | |
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | |
|                 lastQuery = query;
 | |
|                 DataSet ds = lis.Query(query, start, end);
 | |
| 
 | |
|                 dt = ds.Tables[0];
 | |
|                 int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
 | |
|                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g;
 | |
| 
 | |
|                 
 | |
|                 this.gridControl1.DataSource = dt.DefaultView;
 | |
|                 initialDataGridColumns();
 | |
|                 //update selected row index to the last updated one.
 | |
|                 try
 | |
|                 {
 | |
|                     if (wis.ID > 0)
 | |
|                     {
 | |
|                         dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
 | |
|                         DataRow dr = dt.Rows.Find(wis.ID);
 | |
|                         if (dr != null)
 | |
|                         {
 | |
|                             selectedRowIndex = dt.Rows.IndexOf(dr);
 | |
|                         }
 | |
| 
 | |
|                         if (selectedRowIndex > 0 && dt.Rows.Count > selectedRowIndex)
 | |
|                         {
 | |
|                             // gridView1.SelectRow(selectedRowIndex);
 | |
|                             gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                             //  gridView1.MakeRowVisible(selectedRowIndex);
 | |
| 
 | |
|                         }
 | |
| 
 | |
|                         //gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                     }
 | |
|                 }
 | |
|                 catch { }
 | |
| 
 | |
|                 setDetailCnt(txtSeedsNo.Text.Trim(), this.txtBarcode.Text.Trim());
 | |
| 
 | |
|                 closeWaitForm();
 | |
| 
 | |
|                 return cnt;// lgt.getRowCount(query);
 | |
|                 // return lgt.GetGoodType.QueryCount(); 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 closeWaitForm();
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
|             return 0;
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// 分页控件产生的事件  
 | |
|         /// </summary>  
 | |
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | |
|         {
 | |
|             selectedRowIndex = 0; //reset currentRowIndex
 | |
|             return loadData();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void gridView_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         {
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void bindDetail()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|         private void setDataBack()
 | |
|         {
 | |
| 
 | |
| 
 | |
|         }
 | |
|         private bool validData()
 | |
|         {
 | |
|             bool isvalid = dxValidationProvider1.Validate();
 | |
| 
 | |
|             // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid);
 | |
| 
 | |
|             return isvalid;
 | |
|             //String gdtype = txtGoodType.Text.Trim();
 | |
|             //if (gdtype.Length == 0)
 | |
|             //{
 | |
| 
 | |
|             //    dxValidationProvider.Validate();
 | |
|             //    return false;
 | |
|             //} 
 | |
| 
 | |
|             //return true;
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!getCurrentObject())
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (!validData())
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (true)
 | |
|             {
 | |
|                 MessageBox.Show("没有数据更新");
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             Thread th = new Thread(new ThreadStart(this.updateWis));
 | |
|             th.Start();
 | |
| 
 | |
|             // btnSave.Enabled = false;
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void updateWis()
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             //WaitFormService.Show(this);
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 //update the goodtype 
 | |
|                 setDataBack();
 | |
|                 // lgt.GetGoodType.Update();
 | |
|                 //get updated data 
 | |
|                 query();// loadData();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|                 //  btnSave.Enabled = true;
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | |
|             {
 | |
|                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     //  setCurrentRequestDetail();
 | |
|                 }
 | |
| 
 | |
|                 return; ;
 | |
| 
 | |
|             }
 | |
|            
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void clearInputs()
 | |
|         {
 | |
|             txtActCnt.Text=  lbGoodsName.Text =   lbCustname.Text =
 | |
|             this.lbTotalOut.Text =  
 | |
|             this.lbTotalPlan.Text =this.lbTotalPlan2.Text =
 | |
|             lbSeedsNo.Text=lbSeedsBarcode.Text = this.lbSeedsGoodsName.Text = 
 | |
|             this.txtOutCnt.Text = this.txtPlanCount.Text = this.txtActuralCount.Text = this.txtDesc.Text = "";
 | |
| 
 | |
|             count = seedscnt = seedsPlanCnt=0;
 | |
|            
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private bool getCurrentObject()
 | |
|         {
 | |
|             if (selectedRowIndex < 0 || dt.Rows.Count <= selectedRowIndex)
 | |
|             {
 | |
|                 MessageBox.Show("请在列表里选择数据");
 | |
|                 return false;
 | |
|             }
 | |
|             // DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
 | |
|             wis.getModel(dr.Row);
 | |
| 
 | |
| 
 | |
|             return true;
 | |
|         }
 | |
| 
 | |
|         private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void gridView1_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (selectedRowIndex > 0 && dt.Rows.Count > selectedRowIndex)
 | |
|             {
 | |
|                 gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                 gridView1.MakeRowVisible(selectedRowIndex);
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnDelete_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             //if (!getCurrentObject())
 | |
|             //{
 | |
|             //    return;
 | |
|             //}
 | |
|             //MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
 | |
|             //DialogResult dr = MessageBox.Show(String.Format("确定要删除 {0} 吗?",lgt.GetGoodType.goodsName), "删除记录", messButton);
 | |
|             //if (dr == DialogResult.OK)
 | |
|             //{
 | |
|             //    lgt.GetGoodType.Delete() ;
 | |
|             //    lgt.Initialize();
 | |
|             //    query();//loadData();
 | |
|             //}
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         protected void query()
 | |
|         {
 | |
|             pager1.Bind();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void startQuery()
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                 query();// loadData();  
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 MessageBox.Show(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm(); 
 | |
|                 btnQuery.Enabled = true;
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void txtQuery_KeyDown(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyValue == 13)
 | |
|             {
 | |
|                 query();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             swithOperationType();
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void swithOperationType()
 | |
|         {
 | |
|             /*
 | |
|             isAdding = tabControl1.SelectedIndex == 0;
 | |
| 
 | |
|            
 | |
|             if (isAdding)
 | |
|             {
 | |
|                 clearInputs();
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 gridView1_FocusedRowObjectChanged(null, null);
 | |
| 
 | |
|             }
 | |
|  
 | |
|             btnNew.Enabled = isAdding;
 | |
|             btnSave.Enabled = !isAdding;
 | |
|             btnDelete.Enabled = !isAdding;
 | |
|         
 | |
|         }*/
 | |
|         }
 | |
| 
 | |
|         private void bbQuery_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             //Thread th = new Thread(new ThreadStart(this.queryGoodType));
 | |
|             //th.Start();
 | |
|             
 | |
|             startQuery();
 | |
|         }
 | |
| 
 | |
|         private void bbCreateLocations_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             startLocations();
 | |
|         }
 | |
|         void startLocations()
 | |
|         {
 | |
| 
 | |
|             if (!validNewLocations())
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|             //Thread th = new Thread(new ThreadStart(this.newLocations));
 | |
|             //th.Start();
 | |
| 
 | |
|             newWis();
 | |
| 
 | |
|         }
 | |
| 
 | |
|         bool isNewLocationQuery = false;
 | |
| 
 | |
|         private void newWis()
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                 // setLocs();
 | |
| 
 | |
|                // lwmsLoc.addLocations(locs);
 | |
| 
 | |
|                 // lgt.addLocations(locs);
 | |
| 
 | |
|                 isNewLocationQuery = true;
 | |
| 
 | |
|                 query();// loadData();   
 | |
|                 isNewLocationQuery = false;
 | |
|                 // initialize and clear object and inputs, prepare for adding more. 
 | |
|                 // lgt.initialize();
 | |
|                 //  clearInputs();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|                 
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private bool setLocs()
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 locs = new LocStructs();
 | |
|                 //   locs.warehouse = ((Node)comWarehouse.SelectedItem).ID;
 | |
|                 locs.channel1 = Convert.ToInt32(txtChannelFrom.Text);
 | |
|                 locs.channel2 = Convert.ToInt32(txtChannelTo.Text);
 | |
|                 locs.shelf1 = Convert.ToInt32(this.txtShelfFrom.Text);
 | |
|                 locs.shelf2 = Convert.ToInt32(txtShelfTo.Text);
 | |
|                 locs.layer1 = Convert.ToInt32(this.txtLayerFrom.Text);
 | |
|                 locs.layer2 = Convert.ToInt32(txtLayerTo.Text);
 | |
|                 locs.col1 = Convert.ToInt32(this.txtColumFrom.Text);
 | |
|                 locs.col2 = Convert.ToInt32(txtColumTo.Text);
 | |
| 
 | |
| 
 | |
|                 //  locs.eleid2 = Convert.ToInt32(this.txtLabelTo.Text);
 | |
|                 locs.port = this.comport.SelectedIndex + 1;
 | |
|                 /*
 | |
|                 locs.whType = ((Colitem)this.comWhType.SelectedItem).key; // ((Node)this.comWhType.SelectedItem).ID;  
 | |
| 
 | |
|                 //locs.whGoodsType = ((Node)this.comw.SelectedItem).ID;
 | |
|                 locs.goodsType = ((Node)this.comGoodType.SelectedItem).ID;
 | |
|                 //locs.whVolume= ((Node)this.comWhVoType.SelectedItem).ID;
 | |
|                 locs.whVoltype = this.comWhVoType.SelectedIndex;
 | |
|                 locs.volType = this.comLocationVolType.SelectedIndex;
 | |
| 
 | |
|                 if (comboLines.SelectedIndex > 0)
 | |
|                 {
 | |
|                     locs.transLine = ((Node)this.comboLines.SelectedItem).ID;
 | |
|                 }*/
 | |
|                 locs.whVoltype = locs.whVoltype > 0 ? locs.whVoltype : 0;
 | |
|                 locs.volType = locs.volType > 0 ? locs.volType : 0;
 | |
| 
 | |
|                 //   locs.part = ((Node)this.comPart.SelectedItem).ID;
 | |
|                 locs.operater = LoginInfo.UserId;
 | |
|                 //    locs.warehouseName = ((Node)comWarehouse.SelectedItem).name;
 | |
| 
 | |
|                 locs.elecol = Convert.ToInt32(this.txtLabelColum.Text);
 | |
|                 locs.elelayer = Convert.ToInt32(this.txtLabelLayer.Text);
 | |
|                 locs.eleid1 = Convert.ToInt32(this.txtLbStartId.Text);
 | |
|                 /*
 | |
|                 locs.height = txtHeight.Text.Length > 0 ? Convert.ToDecimal(txtHeight.Text) : 0;
 | |
|                 locs.width = txtWidth.Text.Length > 0 ? Convert.ToDecimal(txtWidth.Text) : 0;
 | |
|                 locs.length = txtLength.Text.Length > 0 ? Convert.ToDecimal(txtLength.Text) : 0;
 | |
|                 locs.weight = txtWeight.Text.Length > 0 ? Convert.ToDecimal(txtWeight.Text) : 0;
 | |
|                 */
 | |
|             }
 | |
|             catch
 | |
|             {
 | |
|                 showErrorMsg("请检查输入的数字是否正确");
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private bool validNewLocations()
 | |
|         {
 | |
|             return setLocs();
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void comWarehouse_Properties_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void simpleButton5_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnQuery_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.btnQuery.Enabled = false;
 | |
|             startQuery();
 | |
|         }
 | |
| 
 | |
|         private void btnCreate_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             startLocations();
 | |
|         }
 | |
| 
 | |
|         private void btnLock_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void bbLock_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void simpleButton1_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnPrint_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             printLocations(dt);
 | |
| 
 | |
|         }
 | |
| 
 | |
|         void printLocations(DataTable dt)
 | |
|         {
 | |
|             if (dt == null || dt.Rows.Count == 0)
 | |
|             {
 | |
|                 showErrorMsg("请先查询需要打印的数据,然后才能打印。");
 | |
|                 return;
 | |
|             }
 | |
|             MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
 | |
|             DialogResult dr = MessageBox.Show(String.Format("确定要打印 {0}个标签吗?", dt.Rows.Count), "删除记录", messButton);
 | |
|             if (dr == DialogResult.OK)
 | |
|             {
 | |
|                 //lgt.printLocations(dt);
 | |
|                 string reportName = "wmsLocationCode.rdlc";
 | |
|                 BillPrint.Run(dt, reportName, PrinterType.code);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void bbPrint_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             printLocations(dt);
 | |
|         }
 | |
| 
 | |
|         private void SeedsImport_FormClosing(object sender, FormClosingEventArgs e)
 | |
|         {
 | |
|             //  client.Close();
 | |
|         }
 | |
| 
 | |
|         private bool getCurrentObjects()
 | |
|         {
 | |
|             int[] selectedRows = gridView1.GetSelectedRows();
 | |
|             // selectedLocations = new List<Wmslocation>();
 | |
| 
 | |
|             selectedIds = new List<int>();
 | |
| 
 | |
|             foreach (int i in selectedRows)
 | |
|             {
 | |
|                 DataRow currentRow = dt.Rows[i];
 | |
| 
 | |
|                 selectedIds.Add(Convert.ToInt32(currentRow["ID"].ToString()));
 | |
| 
 | |
|             }
 | |
|             if (selectedRows.Length == 0)
 | |
|             {
 | |
|                 showErrorMsg("请选择一条数据");
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|             DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条货位信息吗?", selectedRows.Length), "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
 | |
| 
 | |
|             return r == DialogResult.Yes;
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         
 | |
| 
 | |
| 
 | |
|         
 | |
| 
 | |
|         private void lcgQuery_Showing(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void lcgSetup_Showing(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void lcgQuery_CustomButtonChecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | |
|         {
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void lcgSetup_CustomButtonChecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void lcgQuery_CustomButtonUnchecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 // lcgSetup.Expanded = false;
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void lcgSetup_CustomButtonUnchecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | |
|         {
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 // lcgQuery.Expanded = false;
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnUpdateLable_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
| 
 | |
|             if (getCurrentObjects())
 | |
|             {
 | |
|                 showWaitForm();
 | |
|                 try
 | |
|                 {
 | |
|                     int labelId = Convert.ToInt16(txtLabelId.Text);
 | |
|                     if (labelId <= 0 || labelId > 9999)
 | |
|                     {
 | |
|                         showErrorMsg("标签编号应该在1-9999之间的整数");
 | |
|                         return;
 | |
|                     }
 | |
| 
 | |
|                     int address = Convert.ToInt16(txtPosition.Text);
 | |
|                     if (address <= 0 || address > 200)
 | |
|                     {
 | |
|                         showErrorMsg("货位坐标应该在1-81之间的整数");
 | |
|                         return;
 | |
|                     }
 | |
| 
 | |
|                     locs = new LocStructs();
 | |
|                     locs.elabId = labelId;
 | |
|                     locs.elabAddress = address;
 | |
|                     locs.operater = LoginInfo.UserId;
 | |
| 
 | |
| 
 | |
|                  //   if (lwmsLoc.updateLocationLabelId(selectedIds.ToArray(), locs))
 | |
|                     {
 | |
|                         MessageBox.Show("更新成功!");
 | |
|                         query();
 | |
|                     }
 | |
|                   //  else
 | |
|                     {
 | |
|                         closeWaitForm();
 | |
|                         showErrorMsg("更新失败!");
 | |
|                     }
 | |
|                     //  client.Close();
 | |
|                 }
 | |
|                 catch (Exception er)
 | |
|                 {
 | |
|                     closeWaitForm();
 | |
|                     showErrorMsg(er.Message);
 | |
|                 }
 | |
|                 finally
 | |
|                 {
 | |
| 
 | |
|                     closeWaitForm();
 | |
| 
 | |
|                 }
 | |
| 
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void bbiExport_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             exportExcel("",gridView1);
 | |
|         }
 | |
| 
 | |
|        // DataTable dtLocs = null;
 | |
|       //  DataView dvLocs = null;
 | |
|         private void bbiImport_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|            // dtLocs = new Wmslocation().QueryActived().Tables[0];
 | |
|           //  dvLocs = dtLocs.DefaultView;
 | |
|             importExcel();
 | |
|             query();
 | |
|         }
 | |
| 
 | |
|         
 | |
| 
 | |
| 
 | |
|   
 | |
|         protected override void FillDataToDs(DataRow dr) //string itemid, string itemplu, string itemName)
 | |
|         {
 | |
|          
 | |
|             string seedsNo = string.Empty;
 | |
|             string goodsName = string.Empty;
 | |
|             string cate1 = string.Empty;
 | |
|             string cate2 = string.Empty;
 | |
|             string cate3 = string.Empty;
 | |
|             string custName = string.Empty;
 | |
|             string unit = string.Empty;
 | |
|             string spec = string.Empty;
 | |
|             string barcode =   string.Empty;
 | |
|            // int partion = 0;
 | |
|             int count=0;
 | |
| 
 | |
|             if (dr["任务波次"].ToString().Trim() != string.Empty)
 | |
|                 seedsNo = dr["任务波次"].ToString().Trim();
 | |
|             if (dr["门店名称"].ToString().Trim() != string.Empty)
 | |
|                 custName = dr["门店名称"].ToString().Trim();
 | |
|             if (dr["商品条码"].ToString().Trim() != string.Empty)
 | |
|                 barcode = dr["商品条码"].ToString().Trim();
 | |
|             if (dr["商品名称"].ToString().Trim() != string.Empty)
 | |
|                 goodsName = dr["商品名称"].ToString().Trim();
 | |
|             if (dr["单位名称"].ToString().Trim() != string.Empty)
 | |
|                 unit = dr["单位名称"].ToString().Trim();
 | |
|             if (dr["规格"].ToString().Trim() != string.Empty)
 | |
|                 spec = dr["规格"].ToString().Trim();
 | |
| 
 | |
|             if (dr["发货数量"].ToString().Trim() != string.Empty)
 | |
|             {
 | |
|                 try
 | |
|                 {
 | |
|                     count = Convert.ToInt16(dr["发货数量"].ToString().Trim());
 | |
|                 }
 | |
|                 catch {
 | |
|                    // count = Convert.ToDecimal(dr["发货数量"].ToString().Trim());
 | |
|                 }
 | |
|             }
 | |
|           //  if (dr["分区"].ToString().Trim() != string.Empty)
 | |
|            //     partion = Convert.ToInt16(dr["分区"].ToString().Trim());
 | |
| 
 | |
|          //   dvLocs.RowFilter = string.Format("ownerCode='{0}'",custName) ;
 | |
|           //  if (dvLocs.Count != 1)
 | |
|             {
 | |
|               //  showErrorMsg("店铺" + custName +" 货位维护错误");
 | |
|               //  return;
 | |
|             }
 | |
|              
 | |
|             if ( barcode != string.Empty && custName != string.Empty)
 | |
|             {
 | |
|                
 | |
|                 WmsImportSeeds wis = new WmsImportSeeds();
 | |
| 
 | |
| 
 | |
|                 wis.itemName = goodsName;
 | |
|                 wis.count = count;
 | |
|                 wis.unit = unit;
 | |
|                 wis.spec = spec; 
 | |
|                 wis.barcode = barcode;  
 | |
|                 wis.seedsNo = seedsNo;  
 | |
|                 wis.countOut = wis.count;
 | |
|                 wis.custName = custName;
 | |
|                 wis.elabAddress = Convert.ToInt16(barcode.Substring(barcode.Length-2));
 | |
|                // wis.partion = partion;
 | |
|                 try
 | |
|                 {
 | |
|                     wis.Add();
 | |
| 
 | |
|                 }
 | |
|                 catch (Exception e)
 | |
|                 {
 | |
|                   //  showErrorMsg(e.Message);
 | |
|                 } 
 | |
| 
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|               //   if(seedsNo =="10445")
 | |
|                 // showErrorMsg(count+"c...."+barcode+"..."+custName);
 | |
|             }
 | |
|             
 | |
|         }
 | |
| 
 | |
|         private void btnDel_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (getCurrentObjects())
 | |
|             {
 | |
|                 showWaitForm();
 | |
|                 try
 | |
|                 {
 | |
|                     int cnt = 0;// lwmsLoc.deleteLocations(selectedIds.ToArray());
 | |
| 
 | |
|                     if (cnt > 0)
 | |
|                     {
 | |
|                         MessageBox.Show(string.Format("成功删除{0}条记录", cnt));
 | |
|                         query();
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         closeWaitForm();
 | |
|                         showErrorMsg("删除失败!");
 | |
|                     }
 | |
|                     //client.Close();
 | |
| 
 | |
|                 }
 | |
|                 catch (Exception er)
 | |
|                 {
 | |
|                     closeWaitForm();
 | |
|                     showErrorMsg(er.Message);
 | |
|                 }
 | |
|                 finally
 | |
|                 {
 | |
| 
 | |
|                     closeWaitForm();
 | |
| 
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnPortsetup_Click(object sender, EventArgs e)
 | |
|         { 
 | |
| 
 | |
|             if (!validCount())
 | |
|             {
 | |
|                 return;
 | |
|             } 
 | |
| 
 | |
|             DialogResult r = MessageBox.Show(string.Format("确定要更新{0}发货数量信息吗?", wis.itemName), "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
 | |
|  
 | |
|             
 | |
|             if (r == DialogResult.No)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
| 
 | |
|            
 | |
|  
 | |
|             this.btnPortsetup.Enabled = false;
 | |
|             showWaitForm();
 | |
|             setupCount(); 
 | |
|             this.btnPortsetup.Enabled = true;
 | |
|             query();
 | |
|         }
 | |
| 
 | |
|         private void setupCount()
 | |
|         {
 | |
|             if (validCount())
 | |
|             {
 | |
|              //  int cnt = 0;// lwmsDc.setupPort(deskId, portNo, startId, endId);
 | |
|                int cnt = lis.updateCount(count, wis.ID, wis.state,txtDesc.Text);
 | |
|                closeWaitForm();
 | |
|                showInfoMsg("共更新了 " + cnt + " 条记录");
 | |
|             }
 | |
|             closeWaitForm();
 | |
|         }
 | |
|         
 | |
|         private bool validCount()
 | |
|         {
 | |
|             int planCnt = 0;
 | |
|             try
 | |
|             {
 | |
|                 count = 0;
 | |
|                 planCnt = Convert.ToInt16(this.txtPlanCount.Text.Trim());
 | |
|                 count = Convert.ToInt16(this.txtActuralCount.Text.Trim()); 
 | |
| 
 | |
|             }
 | |
|             catch
 | |
|             {
 | |
|                 showErrorMsg("请输入正确的发货数量");
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             return count>=0 && count!=planCnt;
 | |
|         }
 | |
|         private bool validCountSeeds()
 | |
|         {
 | |
|             
 | |
|             try
 | |
|             {
 | |
|                 seedscnt = 0;
 | |
|                 seedsPlanCnt = Convert.ToInt16(this.lbTotalPlan2.Text);
 | |
|                 seedscnt = Convert.ToInt16(this.txtActCnt.Text);
 | |
| 
 | |
|             }
 | |
|             catch
 | |
|             {
 | |
|                 showErrorMsg("请输入正确的发货数量");
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             return seedscnt >= 0 ;//&& seedscnt != seedsPlanCnt;
 | |
|         }
 | |
|         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | |
|         {
 | |
|              
 | |
|             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | |
|             {
 | |
|              //   return;
 | |
|             }
 | |
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | |
| 
 | |
|             clearInputs();
 | |
|           
 | |
|             if (selectedRowIndex < 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             getCurrentObject();
 | |
| 
 | |
|             if (wis.ID > 0)
 | |
|             {
 | |
|                 lbGoodsName.Text = wis.itemName;
 | |
|                 lbCustname.Text = wis.custName;
 | |
|                 this.txtPlanCount.Text = wis.count + "";
 | |
|                 this.txtActuralCount.Text = wis.countOut + "";
 | |
|                
 | |
|                 showWaitForm();
 | |
| 
 | |
|                 setDetailCnt(wis.seedsNo, wis.barcode);
 | |
|               closeWaitForm();
 | |
| 
 | |
|             }
 | |
| 
 | |
| 
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|            // setCurrentRequestDetail();
 | |
|         
 | |
|         }
 | |
|         private void setDetailCnt(string seedsNo,string barcode)
 | |
|         {
 | |
|             if (string.IsNullOrEmpty(seedsNo) || string.IsNullOrEmpty(barcode))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             DataTable dt = lis.getSumCount(seedsNo, barcode);
 | |
|             if (dt.Rows.Count > 0)
 | |
|             {
 | |
|                 this.lbTotalOut.Text = dt.Rows[0][0].ToString();
 | |
|                 this.lbTotalPlan.Text = dt.Rows[0][1].ToString();
 | |
|                 lbTotalPlan2.Text = this.lbTotalPlan.Text;
 | |
|                 this.txtOutCnt.Text = this.lbTotalOut.Text;
 | |
|                 this.txtActCnt.Text = this.lbTotalOut.Text;
 | |
|                 this.lbSeedsNo.Text = seedsNo;
 | |
|                 this.lbSeedsGoodsName.Text = dt.Rows[0][2].ToString();
 | |
|                 lbSeedsBarcode.Text = barcode;
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
|         string oDeskId = "";
 | |
|         private void btnCreateOrder_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             int partion = 0;
 | |
|             try
 | |
|             {
 | |
|                 partion = Convert.ToInt16(txtPartion.Text);
 | |
| 
 | |
|                 if (!oDeskId.Equals(this.txtPartion.Text.Trim()))
 | |
|                 {
 | |
|                     WriteConfig("partionId", txtPartion.Text.Trim());
 | |
|                     oDeskId = this.txtPartion.Text.Trim();
 | |
|                 }
 | |
|             }
 | |
|             catch
 | |
|             {
 | |
|                 txtPartion.SelectAll();
 | |
|                 txtPartion.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             int limitCnt = 4000;
 | |
|             int cnt = 0;
 | |
|             if (validSeeds())
 | |
|             {
 | |
|                 int isExceed = 10000;// lis.isExceedLimitCnt(false, limitCnt);
 | |
|                /* 
 | |
|                 if (isExceed == 0)
 | |
|                 {
 | |
|                     string str = Interaction.InputBox("输入得牛使用许可序号", "程序已过期", "", -1, -1);
 | |
|                     string eStr = Encrypt(str); //20190825 
 | |
|                     if(!lis.validLimit(eStr))
 | |
|                     {
 | |
|                         MessageBox.Show("序号错误,请联系供应商。","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
 | |
|                         return;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         MessageBox.Show("已授权,感谢使用得牛软件!","感谢",MessageBoxButtons.OK,MessageBoxIcon.Information);
 | |
|                         lis.isExceedLimitCnt(true, limitCnt);
 | |
|                     }
 | |
|                 }
 | |
|                 else if (-1 < isExceed && isExceed < 140)
 | |
|                 {
 | |
|                     MessageBox.Show("系统许可即将过期,请联系供应商", "警告!即将过期!!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
 | |
|                 }
 | |
|                 */
 | |
| 
 | |
|                 cnt = lis.loadNewSeeds(partion, seedsNo);
 | |
|             }
 | |
|             if (cnt > 0)
 | |
|             {
 | |
|                 query();
 | |
|                 showInfoMsg(String.Format("播种单号{0}已就绪", seedsNo));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 showInfoMsg(String.Format("播种单{0}不存在", seedsNo));
 | |
|                 txtSeedNoNew.SelectAll();
 | |
|                 txtSeedNoNew.Focus();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         String seedsNo = String.Empty;
 | |
|         private bool validSeeds()
 | |
|         {
 | |
| 
 | |
|             seedsNo = this.txtSeedNoNew.Text.Trim();
 | |
| 
 | |
|             if (seedsNo == String.Empty)
 | |
|             {
 | |
|                 showErrorMsg("请输入分播单编号");
 | |
|                 this.txtSeedNoNew.SelectAll();
 | |
|                 this.txtSeedNoNew.Focus();
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             return  seedsNo != String.Empty;
 | |
|         }
 | |
| 
 | |
|         private void btnImport_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             importExcel();
 | |
|             query();
 | |
|         }
 | |
| 
 | |
|         private void btnExport_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             showWaitForm();
 | |
|             int pageSize = pager1.PageSize;
 | |
|             pager1.PageSize =  pager1.NMax;;
 | |
|             query();
 | |
|             exportExcel("分播任务明细-"+comStatus.Text,gridView1);
 | |
|             pager1.PageSize = pageSize;
 | |
|             query();
 | |
|             closeWaitForm();
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnDelOrder_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!validSeeds())
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|           
 | |
|             DialogResult r = MessageBox.Show(string.Format("确定要删除分播单{0}的所有数据吗?",
 | |
|                 seedsNo), "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
 | |
| 
 | |
|             if (r == DialogResult.Yes)
 | |
|             {
 | |
|                 int cnt = lis.deleteOrder(seedsNo);
 | |
|                 if (cnt ==-1 )
 | |
|                 {
 | |
|                     showInfoMsg(String.Format("分播单 {0} 已开始亮灯分播,不能删除。", seedsNo));
 | |
|                 }
 | |
|                 else if(cnt >0)
 | |
|                 {
 | |
|                     showInfoMsg(String.Format("分播单 {0} 已删除", seedsNo)); 
 | |
|                     query();
 | |
|                 }
 | |
|                 else if (cnt == 0)
 | |
|                 {
 | |
|                     showInfoMsg(String.Format("分播单 {0} 不存在", seedsNo));
 | |
|                 }
 | |
| 
 | |
| 
 | |
|             }
 | |
|           
 | |
|            
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnSeedsAdjust_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (isExpiresed())
 | |
|             {
 | |
|               //  MessageBox.Show("程序授权已过期", "请联系供应商", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | |
|               //  return;
 | |
|             }
 | |
|             if (!validCountSeeds())
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             DialogResult r = MessageBox.Show(string.Format("确定要更新{0}发货数量信息吗?", lbSeedsGoodsName.Text),
 | |
|                 "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
 | |
| 
 | |
| 
 | |
|             if (r == DialogResult.No)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|               
 | |
|             this.btnPortsetup.Enabled = false;
 | |
|             showWaitForm();
 | |
|             setupCountSeeds(lbSeedsNo.Text,lbSeedsBarcode.Text);
 | |
|             this.btnPortsetup.Enabled = true;
 | |
|             query();
 | |
|         }
 | |
| 
 | |
|         private void setupCountSeeds(string seedsNo,string barcode)
 | |
|         {
 | |
|             if (validCountSeeds())
 | |
|             {
 | |
|                 //  int cnt = 0;// lwmsDc.setupPort(deskId, portNo, startId, endId);
 | |
|                 int cnt = lis.updateCountSeeds(seedsPlanCnt,seedscnt, seedsNo, barcode);
 | |
|                 closeWaitForm();
 | |
|                 showInfoMsg("更新成功!");
 | |
|             }
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
|         bool isExpiresed()
 | |
|         {
 | |
| 
 | |
|             Wmslocation ws = new Wmslocation();
 | |
| 
 | |
|             string dt2 = ws.getDateTime();
 | |
|             // dt2 = "2022\02\07 12:13:13";
 | |
|             DateTime d = DateTime.Parse(dt2);
 | |
| 
 | |
|             DateTime endate = new DateTime(2022, 4, 1);
 | |
| 
 | |
|             int result = DateTime.Compare(d, endate);
 | |
|             return result > 0; 
 | |
|         }
 | |
|     }
 | |
| } |