324 lines
10 KiB
C#
324 lines
10 KiB
C#
using System;
|
||
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using DeiNiu.Wms.CE.Util;
|
||
using System.Net;
|
||
|
||
namespace DeiNiu.Wms.CE
|
||
{
|
||
public partial class TakeOutTask : basicForm
|
||
{
|
||
// WmsOutPickRequestClient client { get; set; }
|
||
//v_stockOutBatchPickOrder4Wince
|
||
//v_stockOutBatchPickDetail4Wince
|
||
public TakeOutTask()
|
||
{
|
||
InitializeComponent();
|
||
//client = new WmsOutPickRequestClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("WmsOutPickRequestService"));
|
||
}
|
||
|
||
|
||
public static string custor_name="";
|
||
public static string taskNo = "";
|
||
private void Tasks_Load(object sender, EventArgs e)
|
||
{
|
||
// initialTimer();
|
||
|
||
Dictionary<int, string> dic = new Dictionary<int, string>();
|
||
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
||
|
||
|
||
if (WmsConstants.partions == null)
|
||
{
|
||
WmsConstants.partions = new List<string>();
|
||
|
||
try
|
||
{
|
||
string[] tmp = client.getPartions(LoginInfo.UserId);
|
||
foreach (string auth in tmp)
|
||
{
|
||
WmsConstants.partions.Add(auth);
|
||
}
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
showErrorMsg(er);
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
// List<string> lines = client.getLines(null);
|
||
dic.Add(0,"全部");
|
||
foreach (string partion in WmsConstants.partions)
|
||
{
|
||
string[] s = partion.Split(WmsConstants.SPLIT.ToCharArray());
|
||
if (s.Length > 0)
|
||
{
|
||
dic.Add(Convert.ToInt16(s[0]),s[3]);
|
||
}
|
||
|
||
}
|
||
|
||
Utils.initialComboBoxs(comPartion, dic);
|
||
Utils.buildCombox(3001, comLines);
|
||
|
||
dic.Clear();
|
||
|
||
dic.Add((int)enumOutOrderType.销售出库, enumOutOrderType.销售出库.ToString());
|
||
dic.Add((int)enumOutOrderType.补货出库, enumOutOrderType.补货出库.ToString());
|
||
|
||
Utils.initialComboBoxs(comOrderType, dic);
|
||
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
// GetTaskData();
|
||
|
||
}
|
||
|
||
public void GetTaskData()
|
||
{
|
||
|
||
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
||
try
|
||
{
|
||
CombItem ciPartion = ( CombItem)comPartion.SelectedItem;
|
||
|
||
CombItem ciLine = ( CombItem)comLines.SelectedItem;
|
||
|
||
CombItem orderType = (CombItem)comOrderType.SelectedItem;
|
||
|
||
DataTable dt = client.getTaskAssigned(LoginInfo.UserId, ciPartion.id,ciLine.id,true,orderType.id);
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
|
||
bindBg1(dt);
|
||
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
showErrorMsg(er);
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
//tb1.SelectedIndex = 1;
|
||
}
|
||
|
||
|
||
|
||
|
||
private void tb1_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void bindBg1(DataTable dt)
|
||
{
|
||
dg1.DataSource = dt;
|
||
|
||
dg1.TableStyles.Clear();
|
||
DataGridTableStyle ts = new DataGridTableStyle();
|
||
ts.MappingName = dt.TableName;
|
||
|
||
dg1.TableStyles.Add(ts);
|
||
|
||
ts.GridColumnStyles[0].Width = 30;
|
||
ts.GridColumnStyles[1].Width = 80;
|
||
ts.GridColumnStyles[2].Width = 25;
|
||
//ts.GridColumnStyles[3].Width = 0;
|
||
ts.GridColumnStyles[3].Width = 20;
|
||
ts.GridColumnStyles[5].Width = 60;
|
||
ts.GridColumnStyles[6].Width = 60;
|
||
ts.GridColumnStyles["线路"].Width = 0;
|
||
}
|
||
|
||
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);
|
||
|
||
|
||
/*
|
||
dg2.TableStyles[0].GridColumnStyles["商品"].Width = 80;
|
||
dg2.TableStyles[0].GridColumnStyles["数量"].Width = 60;
|
||
dg2.TableStyles[0].GridColumnStyles["货位"].Width = 70;
|
||
dg2.TableStyles[0].GridColumnStyles["批号"].Width = 80;
|
||
dg2.TableStyles[0].GridColumnStyles["厂家"].Width = 150;
|
||
*/
|
||
// dg2.TableStyles[0].GridColumnStyles["pickOrderNo"].Width = 0;
|
||
// dg2.TableStyles[0].GridColumnStyles["state"].Width = 0;
|
||
// dg2.TableStyles[0].GridColumnStyles["状态"].Width = 70;
|
||
|
||
|
||
}
|
||
|
||
|
||
private void initialTimer()
|
||
{
|
||
int intTime = 5*60*1000;
|
||
timer1.Interval = intTime;//设置间隔时间,为毫秒;
|
||
timer1.Tick += new EventHandler(loadTasks);//到达时间的时候执行事件;
|
||
|
||
timer1.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
|
||
|
||
}
|
||
delegate void loadNewCurrentWave();
|
||
private void loadTasks(object source, EventArgs e)
|
||
{
|
||
if (InvokeRequired)
|
||
{
|
||
this.Invoke(new loadNewCurrentWave(delegate()
|
||
{
|
||
// bindBg1();
|
||
}));
|
||
|
||
}
|
||
else
|
||
{
|
||
// bindBg1();
|
||
}
|
||
|
||
}
|
||
|
||
|
||
void clear()
|
||
{
|
||
// lbStatus.Text = lbTask.Text ="";
|
||
// dg2.DataSource =null;
|
||
|
||
}
|
||
|
||
private void TaskList_Closing(object sender, CancelEventArgs e)
|
||
{
|
||
timer1.Enabled = false;
|
||
timer1.Dispose();
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
||
try
|
||
{
|
||
CombItem ciPartion = ( CombItem)comPartion.SelectedItem;
|
||
|
||
CombItem ciLine = ( CombItem)comLines.SelectedItem;
|
||
CombItem orderType = (CombItem)comOrderType.SelectedItem;
|
||
|
||
DataTable dt = client.taskAssign(ciPartion.id, ciLine.id, true,orderType.id, LoginInfo.UserId, LoginInfo.Token);
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
|
||
// bindBg1(dt);
|
||
GetTaskData();
|
||
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
showErrorMsg(er);
|
||
|
||
}
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
}
|
||
|
||
private void btnQuery_Click(object sender, EventArgs e)
|
||
{
|
||
GetTaskData();
|
||
}
|
||
|
||
private void comOrderType_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
CombItem orderType = (CombItem)comOrderType.SelectedItem;
|
||
if (orderType.id == (int)enumOutOrderType.补货出库)
|
||
{
|
||
comLines.SelectedIndex = 0;
|
||
comPartion.SelectedIndex = 0;
|
||
}
|
||
|
||
}
|
||
|
||
private void txtPrint_GotFocus(object sender, EventArgs e)
|
||
{
|
||
txtPrint.Text = "";
|
||
// txtPrint.Text = "192.168.0.102:9996;5";
|
||
txtPrint.SelectAll();
|
||
}
|
||
|
||
private void txtPrint_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
string ip = "";
|
||
string partion = "";
|
||
string input = txtPrint.Text;
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
if (input.Length < 10 || !input.Contains(";"))
|
||
{
|
||
MessageBox.Show("请扫描打印条码"); return;
|
||
}
|
||
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
||
try
|
||
{
|
||
char split = ';';
|
||
string[] s = input.Split(split);
|
||
if (s.Length > 1)
|
||
{
|
||
txtPrint.Enabled = false;
|
||
ip = s[0];
|
||
partion = s[1];
|
||
// CombItem ciPartion = (CombItem)comPartion.SelectedItem;
|
||
CombItem ciLine = (CombItem)comLines.SelectedItem;
|
||
CombItem orderType = (CombItem)comOrderType.SelectedItem;
|
||
printTasks(ip, partion, ciLine.id, orderType.id);
|
||
|
||
}
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
showErrorMsg(er);
|
||
|
||
}
|
||
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
||
txtPrint.Enabled = true;
|
||
}
|
||
}
|
||
|
||
void printTasks(string ip, string partion, int lineId, int orderType)
|
||
{
|
||
string svrMethod = getMethodUrl();
|
||
svrMethod = string.Format(svrMethod,LoginInfo.UserId, partion,lineId,orderType,ip);
|
||
HttpWebRequest webReq;
|
||
webReq = (HttpWebRequest)WebRequest.Create(new Uri( 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();
|
||
txtPrint.Text = responseText.Equals("1") ? "请求成功" : "请求失败";
|
||
// MessageBox.Show(responseText);
|
||
// logMsg(responseText);
|
||
|
||
}
|
||
string getMethodUrl()
|
||
{
|
||
return "http://{4}/DNPrintSvc/printOutTaskCode?userId={0}&partion={1}&lineId={2}&orderType={3}";
|
||
|
||
|
||
}
|
||
}
|
||
} |