947 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			947 lines
		
	
	
		
			31 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 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.win.ServiceReferenceInRequest; 
 | |
| //using DeiNiu.wms.win.ServiceReferenceInRequestLocal;
 | |
|  using DeiNiu.wms.win.ServiceReferenceStockInRequest;//debug 
 | |
| using DNLightSvr;
 | |
| using System.ServiceModel;
 | |
| using System.ServiceModel.Description;
 | |
| 
 | |
| namespace DeiNiu.wms.win
 | |
| {
 | |
|     public partial class GoodsReceivePrint : BasicRibbonForm
 | |
|     {
 | |
| 
 | |
|          
 | |
|         printIn reportPrint = new printIn() ;
 | |
| 
 | |
|       //  lWmsStock ls = new lWmsStock();
 | |
|       //  lWmsInRequest lgt = new lWmsInRequest();
 | |
|         private string fieldName = WmsLocation.fields.locationId.ToString();
 | |
|         private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString();
 | |
|         private string lastQuery = "";
 | |
|        // private DataTable dt;
 | |
|         private DataTable dtship;
 | |
|       //  DataTable dtIndetail;
 | |
|         private int selectedRowIndex = -1;
 | |
|         private Erp_purch selectedRequest;
 | |
|         private bool isShowingInRequest = true;
 | |
| 
 | |
|         int shipid;
 | |
|         public GoodsReceivePrint()
 | |
|         {
 | |
|          
 | |
|             InitializeComponent();
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 initialControls();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
|           //  startHost();
 | |
|         }
 | |
|         #region initialControls
 | |
|         private void initialControls()
 | |
|         {
 | |
|            // setDatePiker(dateEditFrom, dateEditTo);
 | |
|            // initialComboBoxes();
 | |
|             initialPagerControls();
 | |
|             initialDataGrid();
 | |
|             initialQueryInput(); 
 | |
|             setValidationRule();
 | |
|             //   textEditBarcode.GotFocus += new EventHandler(textEditBarcode_GotFocus);
 | |
|             //    textEditBarcode.MouseUp += new MouseEventHandler(textEditBarcode_MouseUp);
 | |
|             txtVenderNO.Focus();
 | |
| 
 | |
|         }
 | |
|         private void initialComboBoxes()
 | |
|         {
 | |
|             this.comboType.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | |
|             comboType.SelectedIndex = 0;
 | |
|             this.comboState.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | |
| 
 | |
|             Dictionary<int, string> dic = new Dictionary<int, string>();
 | |
| 
 | |
|             dic.Add((int)enumInStockOrderStatus.待收货, enumInStockOrderStatus.待收货.ToString());
 | |
|             dic.Add((int)enumInStockOrderStatus.待验收, enumInStockOrderStatus.待验收.ToString());
 | |
|          
 | |
|             initialComboBoxs(comboState, dic, false);
 | |
| 
 | |
|           
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void setValidationRule()
 | |
|         {
 | |
|           //  dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule);
 | |
|             //txtGoodType.Properties.MaxLength = 40;
 | |
|             //txtGoodDesc.Properties.MaxLength = 250;
 | |
|             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength;
 | |
|         }
 | |
| 
 | |
|         private void initialQueryInput()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|       
 | |
|        
 | |
|         private void initialGridView2Columns(GridView gridview)
 | |
|         {
 | |
|             setupGridView(gridview, false, true, false);
 | |
|           //  gridview.OptionsSelection.MultiSelect = false; 
 | |
|              
 | |
|             gridview.FocusRectStyle = DrawFocusRectStyle.RowFocus;
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridview.Columns.Clear();
 | |
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | |
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | |
|             myCol0.Visible = false;
 | |
|             gridview.Columns.Add(myCol0);
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "商品编码", Visible = true, FieldName = WmsGoods.fields.goodsId.ToString()};
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = "goodsName",MinWidth=100};
 | |
|            GridColumn myCol4 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsGoods.exfields.spec.ToString(),MinWidth=80 };
 | |
|             GridColumn myCol5 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
 | |
|  
 | |
|                     GridColumn myCol12 = new GridColumn() { Caption = "食药监码", Visible = true, FieldName = WmsGoods.exfields.regeditCode.ToString() ,MinWidth=80};
 | |
| 
 | |
|          
 | |
|             GridColumn myCol131 = new GridColumn() { Caption = "收货数量", Visible = true, FieldName = "validCount" };
 | |
|             
 | |
|  
 | |
|             GridColumn myCol17 = new GridColumn() { Caption = "单据状态", Visible = true, FieldName = "state",MinWidth=90};
 | |
|           
 | |
|           
 | |
|               GridColumn myCol25 = new GridColumn() { Caption = "验收人", Visible = true, FieldName = "em_name" };
 | |
|       
 | |
|              GridColumn myCol28 = new GridColumn() { Caption = "直通商品", Visible = true, FieldName = WmsGoods.exfields.isZhitong.ToString() };
 | |
|             
 | |
|             GridColumn myCol35 = new GridColumn() { Caption = "单价", Visible = true, FieldName = "price" };
 | |
| 
 | |
|             GridColumn myCol36 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = "productDate" };
 | |
| 
 | |
|             GridColumn myCol38= new GridColumn() { Caption = "到期日期", Visible = true, FieldName = "validDate" };
 | |
|             GridColumn myCol37 = new GridColumn() { Caption = "批次号码", Visible = true, FieldName = "batch" };
 | |
| 
 | |
|         
 | |
|                    // gridview.Columns.Add(colChk); 
 | |
|                   
 | |
|                     gridview.Columns.Add(myCol2); 
 | |
|                      gridview.Columns.Add(myCol131);
 | |
|                      
 | |
|                     gridview.Columns.Add(myCol5);   
 | |
|                 gridview.Columns.Add(myCol36);
 | |
|                 gridview.Columns.Add(myCol38);
 | |
|                 gridview.Columns.Add(myCol37);
 | |
|            
 | |
|                     gridview.Columns.Add(myCol4);
 | |
|                     gridview.Columns.Add(myCol35);   
 | |
|                   //  gridview.Columns.Add(myCol7);
 | |
|                     gridview.Columns.Add(myCol12);
 | |
|                     gridview.Columns.Add(myCol1);
 | |
|                   //  gridview.Columns.Add(myCol17);
 | |
|                 gridview.Columns.Add(myCol25);
 | |
|             
 | |
|            
 | |
| 
 | |
|             //to show bottom scroll bar
 | |
|             gridview.OptionsView.ColumnAutoWidth = false;
 | |
|             gridview.BestFitColumns();
 | |
|           //  gridView2.Focus();
 | |
|         }
 | |
|         private void initialGridView1Columns(GridView gridview)
 | |
|         {
 | |
|             setupGridView(gridview, false, false, false);
 | |
|             gridview.FocusRectStyle = DrawFocusRectStyle.None;
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridview.Columns.Clear();
 | |
|        
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "供应商名称", Visible = true, FieldName ="venderName" };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "联系人", Visible = true, FieldName = "contact", MinWidth = 100 };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "电话", Visible = true, FieldName = "phone", MinWidth = 120 };
 | |
|             gridview.Columns.Add(myCol1);
 | |
|             gridview.Columns.Add(myCol2);
 | |
|             gridview.Columns.Add(myCol3);
 | |
|             gridview.OptionsView.ColumnAutoWidth = false;
 | |
|             gridview.BestFitColumns();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|  
 | |
|        
 | |
|         /// <summary>  
 | |
|         /// loading data
 | |
|         /// </summary>  
 | |
|         private int loadData()
 | |
|         {
 | |
|          
 | |
|              
 | |
|                 return 1;
 | |
|           
 | |
| 
 | |
|         }
 | |
|         DataTable dtVender;
 | |
|         DataView dvVender;
 | |
|          
 | |
|        
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// 分页控件产生的事件  
 | |
|         /// </summary>  
 | |
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | |
|         {
 | |
|             selectedRowIndex = -1; //reset currentRowIndex
 | |
|             return loadData();
 | |
|         }
 | |
| 
 | |
|         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 = Utils.WmsConstants.PAGER_SIZE;//每页行数  
 | |
|             this.pager1.Bind();//绑定  
 | |
|             #endregion
 | |
| 
 | |
|         }
 | |
| 
 | |
|        
 | |
|         private void clearInputs()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|          
 | |
|        
 | |
|         //to show in detail
 | |
|         int selectedInIndex = -1;
 | |
|         string goodsName;
 | |
|         int selectedPdId;
 | |
|         int selectedPurDetailId = -1;
 | |
|         Erp_purch_d currentDetail = null;
 | |
|        
 | |
|         int selectedVenderIndex = -1;
 | |
|         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|            
 | |
| 
 | |
|             if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedVenderIndex)
 | |
|             {
 | |
|                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedVenderIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     pager1.Bind();
 | |
|                 }
 | |
| 
 | |
|                 return;
 | |
| 
 | |
|             }
 | |
|             selectedVenderIndex = gridView1.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             pager1.Bind();
 | |
| 
 | |
|         }
 | |
| 
 | |
|  
 | |
| 
 | |
|         protected void query()
 | |
|         {
 | |
|        
 | |
|             try
 | |
|             {     showWaitForm();
 | |
|                 string vender = txtVenderNO.Text.Trim();
 | |
|                 DtGv = inClient.getPreValidResult(vender);
 | |
|                 closeWaitForm(); 
 | |
| 
 | |
|                 this.gridControl2.DataSource = DtGv.DefaultView;
 | |
|                 gridView2.OptionsView.ColumnAutoWidth = false;
 | |
|                 gridView2.BestFitColumns();
 | |
|                 txtVenderNO.SelectAll();
 | |
|                 txtVenderNO.Focus();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void queryGoods()
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                 query();// loadData();  
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|                 bbQuery.Enabled = true;
 | |
|             }
 | |
| 
 | |
|         }
 | |
|          
 | |
|         private void bbQuery_ItemClick_1(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             this.bbQuery.Enabled = false;
 | |
|             queryGoods();
 | |
|         }
 | |
| 
 | |
|        
 | |
| 
 | |
|         private void updateObjects(List<WmsGoods> goods)
 | |
|         { 
 | |
|             showWaitForm();
 | |
|             //WaitFormService.Show(this); 
 | |
|             try
 | |
|             {
 | |
|              //   lgt.update(goods);
 | |
| 
 | |
|                 //get updated data 
 | |
|                 query();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|              
 | |
|             }
 | |
|              
 | |
| 
 | |
|         }
 | |
|         string lastSelectedPurOrder = "";
 | |
|         string fileLocation = "";
 | |
|         private bool getCurrentObject()
 | |
|         {
 | |
|             fileLocation =lastSelectedPurOrder= "";
 | |
|             if (selectedRowIndex < 0 || selectedRowIndex >= DtGv.Rows.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|            
 | |
|           //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView2)[selectedRowIndex]);
 | |
| 
 | |
|             lastSelectedPurOrder = selectedRequest ==null? "" : selectedRequest.pur_order;
 | |
|             fileLocation =dr["fileLocation"].ToString();
 | |
|             selectedRequest = new Erp_purch(dr.Row);
 | |
|            // lbPhone.Text = dr["phone"].ToString();
 | |
|           //  lbContact.Text = dr["contact"].ToString();
 | |
|                 // this.gridControl2.DataSource = null;
 | |
|              //btnIn.Enabled = false; 
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|        
 | |
| 
 | |
| 
 | |
|         private void btnQuery_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryGoods();
 | |
|         }
 | |
| 
 | |
|        
 | |
|         private void initialDataGrid()
 | |
|         {
 | |
|             this.gridView2.IndicatorWidth = 40;
 | |
|             this.gridView2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|             gridView2.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
|             gridView2.CustomDrawCell += gridView_CustomDrawCell;
 | |
|             gridView2.RowCellStyle += gridView_RowCellStyle;
 | |
|             //       this.gridView2.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView2_FocusedRowObjectChanged);
 | |
|            // this.gridviewShip.FocusedRowObjectChanged +=
 | |
|            //     new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewship_FocusedRowObjectChanged);
 | |
|             initialGridView2Columns(gridView2);
 | |
| 
 | |
|             this.gridView1.IndicatorWidth = 20;
 | |
|             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | |
|            
 | |
| 
 | |
| 
 | |
|           // GridCheckEdit(gridView2, CheckBoxField, 50);
 | |
|            
 | |
|         }
 | |
|         int[] ids;
 | |
|         protected override   void calculateSelectedValue()
 | |
|         {
 | |
|             List<int> lst = new List<int>();
 | |
|             decimal money = 0m;
 | |
|             for (int i = 0; i < gridView2.RowCount && i<DtGv.Rows.Count; i++)
 | |
|             {
 | |
|                 if (!string.IsNullOrEmpty( DtGv.Rows[i][CheckBoxField].ToString())&& Convert.ToBoolean(DtGv.Rows[i][CheckBoxField].ToString()))
 | |
|                 {
 | |
|                     money += Convert.ToDecimal(DtGv.Rows[i]["money"].ToString());
 | |
|                     lst.Add(Convert.ToInt32(DtGv.Rows[i]["id"].ToString()));
 | |
|                 }
 | |
| 
 | |
|             }
 | |
| 
 | |
|             lbSumMoney.Text = money+"";
 | |
|            // btnIn.Enabled = money > 0;
 | |
|             ids = lst.ToArray();
 | |
|         }
 | |
| 
 | |
| 
 | |
|        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         {
 | |
| 
 | |
|          //   if (sender == gridView2)
 | |
|             { 
 | |
|                 if (e.Column.FieldName == "wms_state")
 | |
|                 {
 | |
| 
 | |
|                     if (!stockInLocationStatus.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt32(e.DisplayText);
 | |
|                             if (sender == gridView2)
 | |
|                             {
 | |
|                                 e.DisplayText = this.enumReceiveDetailStatus[display];
 | |
|                             }
 | |
|                             else
 | |
|                             {
 | |
|                                 e.DisplayText = this.inRequestStatus[display];
 | |
|                             }
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
| 
 | |
|                    // return;
 | |
|                    // e.DisplayText = stockInLocationStatus.ContainsKey(display) ? stockInLocationStatus[display] : display+"";
 | |
| 
 | |
|                 }else
 | |
| 
 | |
|                 if (e.Column.FieldName == "isQc" || e.Column.FieldName == "isZhitong")
 | |
|                 {
 | |
|                     int display = -100;
 | |
|                     string disTxt = e.DisplayText;
 | |
| 
 | |
|                     try
 | |
|                     {
 | |
|                         display = Convert.ToInt32(e.DisplayText);
 | |
|                         if (sender == gridView2)
 | |
|                         {
 | |
|                             e.DisplayText = (display == 1) ? "是" : "否";
 | |
|                         }
 | |
| 
 | |
|                     }
 | |
|                     catch
 | |
|                     {
 | |
|                         return;
 | |
|                     }
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == "shipDate")
 | |
|                 {
 | |
|                     e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
 | |
|                 }
 | |
|                  
 | |
|                     
 | |
|                  
 | |
|                
 | |
|             }
 | |
|         }
 | |
|        void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 | |
|        {
 | |
|            //var currentView = sender as GridView;
 | |
|            //if (currentView != null && e.RowHandle == currentView.FocusedRowHandle) return;
 | |
|            Rectangle r = e.Bounds;
 | |
|            if (e.Column.FieldName == "wms_state" && e.CellValue !=null)
 | |
|            {
 | |
|                string a = e.CellValue.ToString();
 | |
|                string b = e.DisplayText;
 | |
|                if (b.Equals("待收货"))
 | |
|                {
 | |
|                    e.Appearance.ForeColor = Color.Red;
 | |
|                    e.Appearance.DrawString(e.Cache, e.DisplayText, r);
 | |
|                    e.Handled = true;
 | |
|                }
 | |
|                else if(b.Equals("已收货"))
 | |
|                {
 | |
|                    e.Appearance.ForeColor = Color.Gray;
 | |
|                    e.Appearance.DrawString(e.Cache, e.DisplayText, r);
 | |
|                    e.Handled = true;
 | |
|                }
 | |
| 
 | |
|            }
 | |
|        }
 | |
| 
 | |
|        void gridView_RowCellStyle(object sender,DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 | |
|        {
 | |
| 
 | |
|             var currentView = sender as GridView;
 | |
|            if( currentView == null){return;}
 | |
|            if (!currentView.GetDataRow(e.RowHandle).Table.Columns.Contains("wms_state"))
 | |
|            {
 | |
|                return;
 | |
|            }
 | |
| 
 | |
|            int state = Convert.ToInt32( currentView.GetDataRow(e.RowHandle)["wms_state"].ToString().Trim());
 | |
|            
 | |
|            if (state == 0)
 | |
|            {
 | |
|                return;
 | |
|            }
 | |
| 
 | |
|            bool isFocused = e.RowHandle == currentView.FocusedRowHandle;
 | |
|            DevExpress.Utils.AppearanceDefault rowStyle = null;
 | |
|             DevExpress.Utils.AppearanceDefault appBlueRed = 
 | |
|                new DevExpress.Utils.AppearanceDefault (Color.White, Color.Red, Color.Empty, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
 | |
|            DevExpress.Utils.AppearanceDefault appYB =
 | |
|             new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green);
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green,  Color.Yellow);
 | |
|            DevExpress.Utils.AppearanceDefault alert  = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Gray);
 | |
|            DevExpress.Utils.AppearanceDefault passed = new DevExpress.Utils.AppearanceDefault(Color.Gray, Color.White);
 | |
| 
 | |
|            if (state >=  (int) enumReceiveStockDetailStatus.已验收  )
 | |
|            {
 | |
|                rowStyle = isFocused ? passedFocus : passed;
 | |
|            }
 | |
|            else if (state == (int)enumReceiveStockDetailStatus.拒收  )
 | |
|            {
 | |
|                rowStyle = isFocused ? alertFocus : alert;
 | |
|            }
 | |
| 
 | |
| 
 | |
|            DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, rowStyle);
 | |
|            /*
 | |
|            if (sender == this.gridView2)
 | |
|            {
 | |
|                if (this.gridView2.GetDataRow(e.RowHandle)["state"].ToString().Trim() == "2")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                }
 | |
|            }else if(sender == this.gridView1){
 | |
|                 
 | |
|                if ( state == "2")
 | |
|                {
 | |
|                    if (currentView != null && e.RowHandle == currentView.FocusedRowHandle)
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alertFocus);
 | |
|                    }
 | |
|                    else
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                    }
 | |
|                }
 | |
|                else if (state == "1")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, passed);
 | |
|                } 
 | |
|            }
 | |
|            */
 | |
|        }
 | |
|          
 | |
|         string currentPreNo="";
 | |
|         void setCurrentVenderPreIn()
 | |
|         {
 | |
|             currentPreNo = "";
 | |
|             DataTable dt2 = inClient.getReceivePreSumByVenderNotValided(selectedRequest.vender);
 | |
|             closeClient(); 
 | |
|             initialGridView2Columns(gridView3);
 | |
|              DataView dv = dt2.DefaultView;
 | |
|              if (dv.Count > 0)
 | |
|              {
 | |
|                  currentPreNo = dv[0]["preInOrderNo"].ToString();
 | |
|              }
 | |
|              dv.RowFilter = "preInOrderNo is not null";
 | |
|             
 | |
|              //btnPrint.Enabled = !btnPreOk.Enabled;
 | |
|              //this.btnShipIn .Enabled = shipid==0;
 | |
| 
 | |
| 
 | |
|              //dv.RowFilter = "";
 | |
|              this.gridControl3.DataSource = dt2 ;
 | |
|              setBtnPreEnable();
 | |
|         }
 | |
| 
 | |
|         void setBtnPreEnable()
 | |
|         {
 | |
|             btnPreOk.Enabled = (gridView3.DataRowCount > 0) ;//&& shipid > 0;
 | |
|         }
 | |
|         void clearShipInfo()
 | |
|         {
 | |
|             /*
 | |
|             if (selectedRequest ==null || lastSelectedPurOrder.Equals(selectedRequest.pur_order))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             */
 | |
|           //  gridcontrolShip.DataSource = null;
 | |
| 
 | |
|            
 | |
|              
 | |
| 
 | |
|            lbSumMoney.Text= lbShipId.Text = txtShipNo.Text = txtCompany.Text = txtDriverPhone.Text = txtTemp.Text = txtVeNumber.Text = "";
 | |
| 
 | |
|                
 | |
|           // lbShipInfo.Text = ""; 
 | |
| 
 | |
|         }
 | |
|         private void btnIn_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 doPrint();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
| 
 | |
|         }
 | |
|         void doPrint()
 | |
|         { 
 | |
|             printPreOrder(txtVenderNO.Text.ToString());
 | |
|             //txtVenderNO.Text = "";
 | |
|             clearInputs();
 | |
|             this.gridControl2.DataSource = null;
 | |
| 
 | |
| 
 | |
|         }
 | |
|          
 | |
|      
 | |
|         void printPreOrder(string preOrder="")
 | |
|         {
 | |
|           
 | |
| 
 | |
|             if (String.IsNullOrEmpty(WmsConstants.PRINTER_NAME_PIN))
 | |
|             {
 | |
|                 string msg = String.Format("没有定义多联打印机,请先设置多联打印机");
 | |
|                 showErrorMsg(msg);
 | |
|                 
 | |
| 
 | |
|             }
 | |
| 
 | |
|             if (string.IsNullOrEmpty(preOrder) && string.IsNullOrEmpty(currentPreNo))
 | |
|             { 
 | |
|                 showErrorMsg("没有到货通知打印");
 | |
|                 return;
 | |
|             } 
 | |
|             string toPrintNo = currentPreNo;
 | |
|             if (!string.IsNullOrEmpty(preOrder))
 | |
|             {
 | |
|                 toPrintNo = preOrder;
 | |
|             }
 | |
| 
 | |
|             
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             { //只打印未完成收货的明细,一张预到可对应一个采购单的多次收货
 | |
|                 printIn.printStockReceiveMulti(toPrintNo);
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
|         private ServiceHost host = null;
 | |
|       
 | |
|         string svrUrl = WmsConstants.LIGHT_SVR_ADDRESS;
 | |
|         delegate void showStatus();
 | |
|         void startHost()
 | |
|         {
 | |
|             //  lbStatus.Text = "服务启动失败";
 | |
|             try
 | |
|             {
 | |
|                 //   svrUrl = System.Configuration.ConfigurationManager.AppSettings["BaseUri"];
 | |
|                 //  wmsUrl = System.Configuration.ConfigurationManager.AppSettings["WMSuri"];
 | |
|                 svrUrl = "http://127.0.0.1:9997/DNLight";
 | |
| 
 | |
|                 Uri baseAddress = new Uri(svrUrl);
 | |
|                 LightService service = new LightService();
 | |
|                
 | |
|                 service.printPreInd += this.printPreInNo;
 | |
|                 service.prinOutTransd += this.prinOutTrans;
 | |
|                 //  service.lightUp += this.lightUp;
 | |
| 
 | |
|                 host = new ServiceHost(service, baseAddress);
 | |
|                 //  elelab.DNLights.lightOffEvent += testPicked;
 | |
| 
 | |
|                 WebHttpBinding binding = new WebHttpBinding();
 | |
|                 ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(ILightService), binding, baseAddress);
 | |
|                 WebHttpBehavior httpBehavior = new WebHttpBehavior();
 | |
|                 endpoint.Behaviors.Add(httpBehavior);
 | |
|                 List<string> lstIp = Util.GetLocalIpAddress("InterNetwork");
 | |
|                 string showSvr = "127.0.0.1:9997";
 | |
|                 if (lstIp.Count > 0)
 | |
|                 {
 | |
|                     showSvr = showSvr.Replace("127.0.0.1", lstIp[0]);
 | |
|                 }
 | |
|                 lbUrl.Text = "打印服务未启动 " ;
 | |
|                 host.Opened += delegate
 | |
| 
 | |
|                 {
 | |
| 
 | |
|                     if (InvokeRequired)
 | |
|                     {
 | |
|                         this.Invoke(new showStatus(delegate ()
 | |
|                         { 
 | |
|                             lbUrl.Text = "服务已启动 " + showSvr;
 | |
| 
 | |
|                             ;
 | |
|                         }));
 | |
| 
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                     
 | |
|                         lbUrl.Text = "服务已启动 " + showSvr; 
 | |
|                      
 | |
|                     
 | |
|                     }
 | |
|                 };
 | |
| 
 | |
| 
 | |
|                 host.Open();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 // addLog("启动服务失败:  " + e.Message);
 | |
|                 MessageBox.Show("启动服务失败:  " + e.Message);
 | |
|             }
 | |
| 
 | |
| 
 | |
|         }
 | |
|         delegate void showLog();
 | |
|         private string printPreInNo(int userId, string preInNo)
 | |
|         {
 | |
|             if (String.IsNullOrEmpty(WmsConstants.PRINTER_NAME_PIN))
 | |
|             {
 | |
|                 string msg = String.Format("没有定义多联打印机");
 | |
|                 //  showErrorMsg(msg);
 | |
|                 return msg;
 | |
| 
 | |
|             }
 | |
| 
 | |
|             if (InvokeRequired)
 | |
|             {
 | |
|                 this.Invoke(new showLog(delegate ()
 | |
|                 {
 | |
|                     lbInfo.Text = String.Format("用户 {0}, 到货单 {1}", userId, preInNo);
 | |
|                 }));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 lbInfo.Text = String.Format("用户 {0}, 到货单 {1}", userId, preInNo);
 | |
|             }
 | |
| 
 | |
|   
 | |
| 
 | |
|             if (string.IsNullOrEmpty(preInNo.ToString()))
 | |
|             {
 | |
|                 // showErrorMsg("车辆为空,打印失败");
 | |
|                 return " 请输入到货单,打印失败";
 | |
|             }
 | |
| 
 | |
|             Thread threadPreProcess = new Thread(new ParameterizedThreadStart(doPrint));
 | |
|             threadPreProcess.IsBackground = true;
 | |
|             threadPreProcess.Start(preInNo);
 | |
| 
 | |
|             return "打印命令已发送";
 | |
|         }
 | |
| 
 | |
|         private void doPrint(Object preInNo)
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             { //只打印未完成收货的明细,一张预到可对应一个采购单的多次收货
 | |
|                 printIn.printStockReceiveMulti(preInNo.ToString());
 | |
| 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
|             closeWaitForm(); 
 | |
|         }
 | |
| 
 | |
|         private void btnPreOk_Click(object sender, EventArgs e)
 | |
|         {
 | |
|          
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                 string preNo = inClient.postPreIn(selectedRequest.vender, shipid);
 | |
|                 closeClient();
 | |
|                // printPreOrder(preNo);
 | |
|                 setCurrentVenderPreIn();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {              
 | |
|                 showErrorMsg(er);
 | |
|                 closeClient();
 | |
|             }
 | |
|             closeWaitForm(); 
 | |
|             
 | |
|             shipid = 0;
 | |
|             clearShipInfo();
 | |
|         }
 | |
| 
 | |
|         
 | |
|         private void txtVender_KeyDown(object sender, KeyEventArgs e)
 | |
|         {
 | |
|           if (e.KeyCode != Keys.Enter)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (string.IsNullOrEmpty(txtVenderNO.Text))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|            // queryVender();
 | |
|             query();
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnTestService_Click(object sender, EventArgs e)
 | |
|         {
 | |
|           //  DataTable dt = testClient.taskAssign(0, 0, true, 3, LoginInfo.UserId, LoginInfo.Token);
 | |
| 
 | |
|             
 | |
|         }
 | |
|         private string prinOutTrans(string plateId)
 | |
|         {
 | |
|             if (String.IsNullOrEmpty(WmsConstants.PRINTER_NAME_PIN))
 | |
|             {
 | |
|                 string msg = String.Format("没有定义多联打印机");
 | |
|                 //  showErrorMsg(msg);
 | |
|                 return msg;
 | |
| 
 | |
|             }
 | |
| 
 | |
|             if (string.IsNullOrEmpty(plateId))
 | |
|             {
 | |
|                 // showErrorMsg("车辆为空,打印失败");
 | |
|                 return "车辆为空,打印失败";
 | |
|             }
 | |
| 
 | |
| 
 | |
|             Thread threadPreProcess = new Thread(new ParameterizedThreadStart(doPrintTran));
 | |
|             threadPreProcess.IsBackground = true;
 | |
|             threadPreProcess.Start(plateId);
 | |
| 
 | |
|             return "打印命令已发送";
 | |
|         }
 | |
| 
 | |
|         private void doPrintTran(object plateId)
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 DataTable dt = tmsClient.getLatestPickRequestsByViechole(plateId.ToString());
 | |
|                 closeClient();
 | |
|                 foreach (DataRow dr in dt.Rows)
 | |
|                 {
 | |
|                     doPrintEachTran(new WmsOutPickRequest(dr));
 | |
| 
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 debug(er.StackTrace);
 | |
|                 //  showErrorMsg(er);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 closeClient();
 | |
|             }
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
|         void doPrintEachTran(WmsOutPickRequest wpr)
 | |
|         {
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                DataTable dtDetail = tmsClient.queryPickRequests4Report(wpr.pickOrderNo);
 | |
|                 if (dtDetail.Rows.Count == 0)
 | |
|                 {
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 wpr = new WmsOutPickRequest(dtDetail.Rows[0]);
 | |
| 
 | |
|                 wpr.sumPrice = wpr.sumPrice > 0 ? wpr.sumPrice : 100;
 | |
|                 string sumPrice = "壹佰元整";//= Utils.Util.convertToChinese(wpr.sumPrice);// "壹佰贰拾伍元整";
 | |
|                 printIn.printStockOutInvoice(dtDetail, sumPrice);
 | |
|                 tmsClient.updatePickInvoice(wpr.pickOrderNo, wpr.invoiceNo);
 | |
|                 closeClient();
 | |
| 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 debug(er.StackTrace);
 | |
|                 // showErrorMsg(er);
 | |
|                 // continue;
 | |
| 
 | |
| 
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 closeClient();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void GoodsReceivePrint_FormClosing(object sender, FormClosingEventArgs e)
 | |
|         {
 | |
|             host.Close();
 | |
|         }
 | |
|     }
 | |
| } |