ldj/wince/DeiNiuWmsWINCE/forms/RegSeedsBox.cs

271 lines
9.0 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
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 RegSeedsBox : basicForm
{
#region
//public int page = 0;
string gooodsid = string.Empty;
DataTable dt = new DataTable();
Dictionary<string, string> partLst = new Dictionary<string, string>();
int partionId = 0;
string svrUrl = "";
string svrMethod = "";
public RegSeedsBox()
{
setTitle();
InitializeComponent();
focusOn(input_txt, " 分区号码");
clearResult();
clearPart();
getSvrUrl();
}
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;
}
clear();
string barcode = input_txt.Text.Trim();
if (barcode.StartsWith("H")) //its box
{
if (partionId == 0)
{
MessageBox.Show("请扫描分区条码 " );
return;
}
lbBox.Text =barcode;
input_txt.Enabled = false;
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
enumRegPlateResult result =(enumRegPlateResult) client.regSeedsPlate(barcode, partionId);
if (result == enumRegPlateResult.)
{
lbResult.Text = "注册成功,开始亮灯...";
try
{
/*
dg1.TableStyles.Clear();
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = dt.TableName; // 必须用 ds.TableName, dt.TableSpace 不行!!!!
dg1.TableStyles.Add(dgts);
dg1.TableStyles[0].GridColumnStyles["货品"].Width = 80;
*/
}
catch (Exception er)
{
showErrorMsg(er);
}
}
lbResult.Text = result.ToString();
DataTable dt = client.getPlatePickList(barcode, partionId);
dg1.DataSource = dt;
lbResult.Text = lightOrder(barcode, partionId);
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
lbResult.Text = er.Message;
showErrorMsg(er);
input_txt.Enabled = true;
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
input_txt.Enabled = true;
focusOn(input_txt, "周转箱编码");
return;
}
else //its part
{
if (partLst.ContainsKey(barcode))
{
clearPart();
lbPartion.Text ="" + partLst[barcode];
try
{
partionId = Convert.ToInt16(barcode);
}
catch (Exception er)
{
input_txt.Enabled = true;
focusOn(input_txt, " 分区号码");
MessageBox.Show("解析分区ID发生错误" + er.Message);
return;
}
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
DataTable dt = client.getPartionRequests(partionId, LoginInfo.UserId, LoginInfo.Token);
dg1.DataSource = dt;
/*dg1.TableStyles.Clear();
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = dt.TableName; // 必须用 ds.TableName, dt.TableSpace 不行!!!!
dg1.TableStyles.Add(dgts);
dg1.TableStyles[0].GridColumnStyles["拣货单"].Width = 0;
// dg1.TableStyles[0].GridColumnStyles["体积"].Width = 80;
// dg1.TableStyles[0].GridColumnStyles["重量"].Width = 80;
// dg1.TableStyles[0].GridColumnStyles["明细"].Width = 30;
dg1.TableStyles[0].GridColumnStyles["color"].Width = 0;
dg1.TableStyles[0].GridColumnStyles["分区"].Width = 0;
dg1.TableStyles[0].GridColumnStyles["分区编号"].Width = 0;
// dg1.TableStyles[0].GridColumnStyles["分播台"].Width = 30;
* */
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
MessageBox.Show("发生错误:" + er.Message);
input_txt.Enabled = true;
focusOn(input_txt, " 分区号码");
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
//to get part pick requests
}
else
{
MessageBox.Show("请扫分区条码或箱子条码");
return;
}
input_txt.Text = "";
input_txt.Enabled = true;
focusOn(input_txt, " 周转箱编号");
}
}
private void clearResult()
{
lbResult.Text = "";
}
private void clearPart()
{
lbBox.Text = "";
partionId = 0;
}
string lightOrder(string plateId, int partion)
{
HttpWebRequest webReq;
webReq = (HttpWebRequest)WebRequest.Create(new Uri(svrUrl + string.Format(svrMethod, plateId, partion)));
lbUrl.Text = svrUrl + string.Format(svrMethod, plateId, partion);
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;
}
void getMethodUrl()
{
svrMethod = "/lightByPlate?plateId={0}&partion={1}";
}
private void getSvrUrl()
{
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
svrUrl = client.getLightService();
lbUrl.Text = svrUrl;
getMethodUrl();
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
// MessageBox.Show("发生错误:" + er.Message);
showErrorMsg(er);
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
}
private void dg1_DoubleClick_1(object sender, EventArgs e)
{
}
void clear()
{
dg1.DataSource = null;
lbUrl.Text = lbResult.Text = "";
}
}
}