306 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			306 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| 
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
|  
 | |
| 
 | |
| namespace DeiNiu.Wms.CE
 | |
| {
 | |
|     public partial class transLoadTrucks   : basicForm 
 | |
|     {
 | |
| 
 | |
|         string transOrder = "";
 | |
|         DataTable dtTrans,dtBulks;
 | |
|         public transLoadTrucks()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             //client = new WmsOutPickRequestClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("WmsOutPickRequestService"));
 | |
|         }
 | |
|   
 | |
| 
 | |
|     
 | |
|         private void transpickbulks_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             GetTransData();
 | |
|         }
 | |
| 
 | |
|         public   void GetTransData()
 | |
|         {
 | |
|             bindBg1();
 | |
|             textTransNo.Focus();
 | |
| 
 | |
|             //tb1.SelectedIndex = 1;
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void dg1_DoubleClick(object sender, EventArgs e)
 | |
|         {
 | |
|             if (dg1.DataSource == null || dg1.CurrentRowIndex < 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             transOrder = dg1[dg1.CurrentRowIndex, 0].ToString();
 | |
|             showTranPickRequests();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         void showTranPickRequests()
 | |
|         {
 | |
| 
 | |
| 
 | |
| 
 | |
|             if (dg1.DataSource == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (dg1.CurrentRowIndex < 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (string.IsNullOrEmpty(transOrder))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             lbTransNo.Text = transOrder;
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|           
 | |
|             try
 | |
|             {
 | |
|                 dtBulks = client.getTransRequestsDetail(transOrder,0);
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                 MessageBox.Show("发生错误:" + er.Message);
 | |
| 
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             bindBg2(dtBulks);
 | |
| 
 | |
|             tb1.SelectedIndex = 1;
 | |
| 
 | |
|             textPickOrderNo.Focus();
 | |
| 
 | |
|             lbTransNo.Text = dtBulks.Rows.Count> 0 ? transOrder :"";
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void tb1_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|             if (tb1.SelectedIndex == 0)
 | |
|             {
 | |
|                 bindBg1();
 | |
|                 textTransNo.Focus();
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 textPickOrderNo.Focus();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void dg1_CurrentCellChanged(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void bindBg1()
 | |
|         {
 | |
|      
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|             
 | |
|             try
 | |
|             {
 | |
|                 dtTrans = client.getTransRequestsByStatus(0);
 | |
|                 dg1.DataSource = dtTrans;
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default; 
 | |
|                 MessageBox.Show("发生错误:" + er.Message);
 | |
| 
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|            
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.Default; 
 | |
|           
 | |
|             dg1.TableStyles.Clear();
 | |
|             DataGridTableStyle ts = new DataGridTableStyle();
 | |
|             ts.MappingName = dtTrans.TableName;
 | |
|             dg1.TableStyles.Add(ts);
 | |
|             // [运单] ,[整箱],[拼箱]  ,[拼袋],[总重],[体积],[温控],[类型]  , [线路] ,[车牌]  ,[联系人] ,nvl([三方],'') as 三方 ,[电话]  ,[司机]  
 | |
|             ts.GridColumnStyles[0].Width = 100;
 | |
|             ts.GridColumnStyles[1].Width = 30;
 | |
|             ts.GridColumnStyles[2].Width = 30;
 | |
|             ts.GridColumnStyles[3].Width = 30;
 | |
|             ts.GridColumnStyles[4].Width = 40;
 | |
|             ts.GridColumnStyles[5].Width = 35;
 | |
|             ts.GridColumnStyles[6].Width = 35;
 | |
|             ts.GridColumnStyles[9].Width = 80; //[车牌] 
 | |
|             ts.GridColumnStyles[11].Width =70;
 | |
|         }
 | |
| 
 | |
|         private void bindBg2(DataTable dt) 
 | |
|         {
 | |
| 
 | |
| 
 | |
|             dg2.DataSource = dt;
 | |
|             dg2.TableStyles.Clear();
 | |
|             DataGridTableStyle dgts = new DataGridTableStyle();
 | |
|             dgts.MappingName = dt.TableName; // 必须用 ds.TableName, dt.TableSpace 不行!!!!
 | |
|             dg2.TableStyles.Add(dgts);
 | |
|             // [id],[分拣单],[整箱] ,[拼箱] ,[拼袋] ,[体积] ,[重量] ,[客户] ,[客户地址]  ,[状态]
 | |
|             dgts.GridColumnStyles[0].Width = 0;
 | |
|             dgts.GridColumnStyles[1].Width = 100;
 | |
|             dgts.GridColumnStyles[2].Width = 30;
 | |
|             dgts.GridColumnStyles[3].Width = 30;
 | |
|             dgts.GridColumnStyles[4].Width = 30;
 | |
|             dgts.GridColumnStyles[5].Width = 35;//[体积]
 | |
|             dgts.GridColumnStyles[6].Width = 35;
 | |
|             dgts.GridColumnStyles[7].Width = 120;
 | |
|             dgts.GridColumnStyles[8].Width = 180;
 | |
| 
 | |
|             
 | |
|            
 | |
|            // dg2.TableStyles[0].GridColumnStyles["pickOrderNo"].Width = 0;
 | |
|            // dg2.TableStyles[0].GridColumnStyles["state"].Width = 0;
 | |
|          //   dg2.TableStyles[0].GridColumnStyles["状态"].Width = 70;
 | |
| 
 | |
| 
 | |
|             textPickOrderNo.Focus();
 | |
|              
 | |
|         }
 | |
| 
 | |
|         private void button1_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|             bindBg1();
 | |
|         }
 | |
| 
 | |
|         private void textTransNo_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             transOrder = textTransNo.Text;
 | |
| 
 | |
| 
 | |
|             if (string.IsNullOrEmpty(transOrder))
 | |
|             {
 | |
|                 textTransNo.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (e.KeyCode == Keys.Enter || e.KeyCode ==Keys.Space)
 | |
|             {
 | |
| 
 | |
| 
 | |
|                 DataView dv = dtTrans.DefaultView;
 | |
| 
 | |
| 
 | |
|                 dv.RowFilter = string.Format("运单='{0}'", transOrder);
 | |
| 
 | |
| 
 | |
| 
 | |
|                 if (dv.Count == 1)
 | |
|                 {
 | |
|                     showTranPickRequests();
 | |
| 
 | |
|                 }
 | |
|                 else
 | |
|                 { 
 | |
|                     bindBg1();
 | |
|                     dv = dtTrans.DefaultView; 
 | |
|                     dv.RowFilter = string.Format("运单='{0}'", transOrder);
 | |
|                     if (dv.Count == 1)
 | |
|                     {
 | |
|                         showTranPickRequests();
 | |
| 
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         textTransNo.SelectAll();
 | |
|                         textTransNo.Focus();
 | |
|                         dv.RowFilter = "";
 | |
|                         return;
 | |
| 
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 dv.RowFilter = "";
 | |
|                 textTransNo.Text = "";
 | |
|                 textTransNo.Focus();
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void textLocation_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|            string pickRequestNo = textPickOrderNo.Text;
 | |
|            if (dtBulks == null  )
 | |
|            {
 | |
|                MessageBox.Show("请选择运单");
 | |
|                tb1.SelectedIndex = 0;
 | |
|                textTransNo.Focus(); 
 | |
|                return;
 | |
|            }
 | |
|            if (  string.IsNullOrEmpty(pickRequestNo))
 | |
|             {
 | |
|                // MessageBox.Show("请选择运单");
 | |
|                 textPickOrderNo.Focus();
 | |
|                 return;
 | |
|             }
 | |
|         
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|             {
 | |
|                 DataView dv = dtBulks.DefaultView;
 | |
| 
 | |
|                 dv.RowFilter = string.Format("分拣单='{0}'", pickRequestNo);
 | |
| 
 | |
|                 if (dv.Count == 1)
 | |
|                 {
 | |
|                   int id = Convert.ToInt32( dv[0][0].ToString());
 | |
|                   Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|                     try{
 | |
|                         if (string.IsNullOrEmpty(client.loadTrucks(transOrder, pickRequestNo,id, LoginInfo.UserId, LoginInfo.Token)))
 | |
|                         {
 | |
|                             Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                             showTranPickRequests();
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                             MessageBox.Show("发生错误,装车失败");
 | |
|                         }
 | |
|                     }catch(Exception er){
 | |
|                         Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                         MessageBox.Show("发生错误:" + er.Message);
 | |
|                     }
 | |
| 
 | |
| 
 | |
| 
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     textPickOrderNo.SelectAll();
 | |
|                     textPickOrderNo.Focus();
 | |
|                     dv.RowFilter = "";
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 dv.RowFilter = "";
 | |
|                 textPickOrderNo.Text = "";
 | |
|                 textPickOrderNo.Focus();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|     }
 | |
| } |