218 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			218 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.ComponentModel;
							 | 
						|||
| 
								 | 
							
								using System.Drawing;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Forms;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								using System.Collections.Specialized;
							 | 
						|||
| 
								 | 
							
								using System.Data;
							 | 
						|||
| 
								 | 
							
								 
							 | 
						|||
| 
								 | 
							
								 
							 | 
						|||
| 
								 | 
							
								using System.Collections;
							 | 
						|||
| 
								 | 
							
								using System.Net;
							 | 
						|||
| 
								 | 
							
								namespace DeiNiu.Wms.CE
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class LightOrder : basicForm
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 界面初始化
							 | 
						|||
| 
								 | 
							
								        //public int page = 0;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        string gooodsid = string.Empty;
							 | 
						|||
| 
								 | 
							
								        int ye = 0;
							 | 
						|||
| 
								 | 
							
								        int index = 0;
							 | 
						|||
| 
								 | 
							
								        int skuId = 0;
							 | 
						|||
| 
								 | 
							
								        DataTable dt = new DataTable();
							 | 
						|||
| 
								 | 
							
								        Dictionary<string, string> partLst = new Dictionary<string, string>();
							 | 
						|||
| 
								 | 
							
								        int partionId = 0;
							 | 
						|||
| 
								 | 
							
								        string svrUrl = "";
							 | 
						|||
| 
								 | 
							
								        string svrMethod = "";
							 | 
						|||
| 
								 | 
							
								        public LightOrder()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								            setTitle();
							 | 
						|||
| 
								 | 
							
								            InitializeComponent();
							 | 
						|||
| 
								 | 
							
								            input_txt.Focus();
							 | 
						|||
| 
								 | 
							
								            clearResult();
							 | 
						|||
| 
								 | 
							
								            clearPart(); 
							 | 
						|||
| 
								 | 
							
								            getSvrUrl();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        private void getSvrUrl()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
							 | 
						|||
| 
								 | 
							
								            try
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                svrUrl = client.getLightService();
							 | 
						|||
| 
								 | 
							
								                getMethodUrl();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            catch (Exception er)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Cursor.Current = System.Windows.Forms.Cursors.Default;
							 | 
						|||
| 
								 | 
							
								                MessageBox.Show("发生错误:" + er.Message);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Cursor.Current = System.Windows.Forms.Cursors.Default;  
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        private void BarCodeStorage_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
							 | 
						|||
| 
								 | 
							
								            try
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                DataTable dt = client.getLightPartions(LoginInfo.UserId, LoginInfo.Token );
							 | 
						|||
| 
								 | 
							
								               
							 | 
						|||
| 
								 | 
							
								                foreach (DataRow dr in dt.Rows)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    partLst[dr["flag"].ToString()] = dr["name"].ToString();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                } 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            catch (Exception er)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Cursor.Current = System.Windows.Forms.Cursors.Default;
							 | 
						|||
| 
								 | 
							
								                MessageBox.Show("发生错误:" + er.Message);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Cursor.Current = System.Windows.Forms.Cursors.Default;  
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 扫描商品条码,获取数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        /// 
							 | 
						|||
| 
								 | 
							
								        private void goodscode_txt_KeyUp(object sender, KeyEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (e.KeyCode != Keys.Enter)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            clearResult();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            string barcode = input_txt.Text.Trim();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (barcode.Length>5) //its pickorder
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (partionId == 0)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    MessageBox.Show("请扫描分区条码 " );
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
							 | 
						|||
| 
								 | 
							
								                try
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    barcode = "SALPHJO00000041";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                 lbResult.Text =   lightOrder(barcode, partionId)=="1" ? "亮灯成功":"亮灯失败";
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                catch (Exception er)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Cursor.Current = System.Windows.Forms.Cursors.Default;
							 | 
						|||
| 
								 | 
							
								                    MessageBox.Show("发生错误:" + er.Message);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                Cursor.Current = System.Windows.Forms.Cursors.Default;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                input_txt.SelectAll();
							 | 
						|||
| 
								 | 
							
								                input_txt.Focus();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else //its part
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (partLst.ContainsKey(barcode))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    clearPart();
							 | 
						|||
| 
								 | 
							
								                    lbPartion.Text = partLst[barcode];
							 | 
						|||
| 
								 | 
							
								                    try
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        partionId = Convert.ToInt16(barcode); 
							 | 
						|||
| 
								 | 
							
								                        
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    catch (Exception er)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                        input_txt.SelectAll();
							 | 
						|||
| 
								 | 
							
								                        input_txt.Focus();
							 | 
						|||
| 
								 | 
							
								                        MessageBox.Show("解析分区ID发生错误:" + er.Message);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                        return;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    
							 | 
						|||
| 
								 | 
							
								                    
							 | 
						|||
| 
								 | 
							
								                    //to get part pick requests
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    MessageBox.Show("请扫分区条码或订单号条码");
							 | 
						|||
| 
								 | 
							
								                    return; 
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                input_txt.Text = "";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                input_txt.SelectAll();
							 | 
						|||
| 
								 | 
							
								                input_txt.Focus();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								             
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								       
							 | 
						|||
| 
								 | 
							
								         
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        string lightOrder(string orderNo, int partion)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            svrMethod = string.Format(svrMethod, orderNo, partion);
							 | 
						|||
| 
								 | 
							
								            HttpWebRequest webReq;
							 | 
						|||
| 
								 | 
							
								            webReq = (HttpWebRequest)WebRequest.Create(new Uri(svrUrl + svrMethod));
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            System.Net.HttpWebResponse response;
							 | 
						|||
| 
								 | 
							
								            response = (System.Net.HttpWebResponse)webReq.GetResponse();
							 | 
						|||
| 
								 | 
							
								            System.IO.StreamReader myreader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8);
							 | 
						|||
| 
								 | 
							
								            string responseText = myreader.ReadToEnd();
							 | 
						|||
| 
								 | 
							
								            myreader.Close();
							 | 
						|||
| 
								 | 
							
								            // MessageBox.Show(responseText);
							 | 
						|||
| 
								 | 
							
								           // logMsg(responseText);
							 | 
						|||
| 
								 | 
							
								            return responseText;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private void clearResult()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            lbResult.Text = "";
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        private void clearPart()
							 | 
						|||
| 
								 | 
							
								        { 
							 | 
						|||
| 
								 | 
							
								            lbPartion.Text ="";
							 | 
						|||
| 
								 | 
							
								            partionId = 0;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private void rdsaleorder_CheckedChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            rdpickorder.Checked = !rdsaleorder.Checked;
							 | 
						|||
| 
								 | 
							
								            getMethodUrl();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private void rdpickorder_CheckedChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            rdsaleorder.Checked = !rdpickorder.Checked;
							 | 
						|||
| 
								 | 
							
								            getMethodUrl();
							 | 
						|||
| 
								 | 
							
								           
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        void  getMethodUrl()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								          svrMethod = rdpickorder.Checked ? "/lightByPickOrderNo?orderNo={0}&partion={1}"
							 | 
						|||
| 
								 | 
							
								               : "/lightBySaleOrderNo?orderNo={0}&partion={1}";
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								       
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |