341 lines
10 KiB
C#
341 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;
|
|||
|
|
|||
|
namespace DeiNiu.Wms.CE
|
|||
|
{
|
|||
|
public partial class TaskList : basicForm
|
|||
|
{
|
|||
|
// WmsOutPickRequestClient client { get; set; }
|
|||
|
//v_stockOutBatchPickOrder4Wince
|
|||
|
//v_stockOutBatchPickDetail4Wince
|
|||
|
public TaskList()
|
|||
|
{
|
|||
|
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();
|
|||
|
lbStatus.Text = custor_name;
|
|||
|
lbTask.Text = taskNo;
|
|||
|
// InitDataGridColumnHeader(dg1);未开始 = 0, 进行中, 暂停, 取消, 已完成
|
|||
|
Dictionary<int, string> dic = new Dictionary<int, string>();
|
|||
|
dic[0] = enumFlowTaskStatus.未开始.ToString();
|
|||
|
dic[1] = enumFlowTaskStatus.进行中.ToString(); ;
|
|||
|
dic[2] = enumFlowTaskStatus.暂停.ToString(); ;
|
|||
|
dic[3] = enumFlowTaskStatus.取消.ToString(); ;
|
|||
|
dic[4] = enumFlowTaskStatus.已完成.ToString(); ;
|
|||
|
|
|||
|
Utils.initialComboBoxs(comStatus, dic);
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(taskNo))
|
|||
|
{
|
|||
|
tb1.SelectedIndex =1;
|
|||
|
GetTaskData(lbTask.Text.Trim().ToString());
|
|||
|
}else{
|
|||
|
bindBg1();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void GetTaskData(string taskNo)
|
|||
|
{
|
|||
|
if(taskNo=="")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
|||
|
try
|
|||
|
{
|
|||
|
DataTable dt = client.getTaskDetails(taskNo,LoginInfo.UserId,LoginInfo.Token);
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
dg2.DataSource = dt;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
bindBg2(dt);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception er)
|
|||
|
{
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
showErrorMsg(er);
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//tb1.SelectedIndex = 1;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void dg1_DoubleClick(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
setTaskDetail();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void setTaskDetail()
|
|||
|
{
|
|||
|
if (dg1.DataSource == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
if (dg1.CurrentRowIndex < 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//string sale_order = dg1[dg1.CurrentRowIndex, 0].ToString();
|
|||
|
|
|||
|
//string custor_name = dg1[dg1.CurrentRowIndex, 1].ToString();
|
|||
|
lbTask.Text = dg1[dg1.CurrentRowIndex, 7].ToString();
|
|||
|
lbStatus.Text = dg1[dg1.CurrentRowIndex, 2].ToString();
|
|||
|
// lbFinished.Text = dg1[dg1.CurrentRowIndex, 11].ToString();
|
|||
|
// btnStart.Enabled = (lbStatus.Text == enumFlowTaskStatus.未开始.ToString());
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
|||
|
DataTable dt = null;
|
|||
|
try
|
|||
|
{
|
|||
|
dt = client.getTaskDetails(lbTask.Text, LoginInfo.UserId, LoginInfo.Token);
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
}
|
|||
|
catch (Exception er)
|
|||
|
{
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
showErrorMsg(er);
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
bindBg2(dt);
|
|||
|
|
|||
|
tb1.SelectedIndex = 1;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void tb1_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (tb1.SelectedIndex == 0)
|
|||
|
{
|
|||
|
bindBg1();
|
|||
|
/*
|
|||
|
dg1.TableStyles[0].GridColumnStyles["出库单"].Width = 80;
|
|||
|
dg1.TableStyles[0].GridColumnStyles["客户"].Width = 140;
|
|||
|
dg1.TableStyles[0].GridColumnStyles["状态"].Width = 60;
|
|||
|
*/
|
|||
|
}
|
|||
|
btnStart.Enabled = (lbStatus.Text == enumFlowTaskStatus.未开始.ToString());
|
|||
|
}
|
|||
|
|
|||
|
private void bindBg1()
|
|||
|
{
|
|||
|
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
|||
|
DataTable dt;
|
|||
|
try
|
|||
|
{
|
|||
|
dt = client.getTasks(comStatus.SelectedIndex, -1, LoginInfo.UserId, LoginInfo.UserId, LoginInfo.Token);
|
|||
|
dg1.DataSource = dt;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception er)
|
|||
|
{
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
showErrorMsg(er);
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
|
|||
|
dg1.TableStyles.Clear();
|
|||
|
DataGridTableStyle ts = new DataGridTableStyle();
|
|||
|
ts.MappingName = dt.TableName;
|
|||
|
|
|||
|
dg1.TableStyles.Add(ts);
|
|||
|
ts.GridColumnStyles[0].Width = 0;
|
|||
|
ts.GridColumnStyles[4].Width = 0;
|
|||
|
ts.GridColumnStyles[6].Width = 0;
|
|||
|
ts.GridColumnStyles[11].Width = 0;
|
|||
|
ts.GridColumnStyles[1].Width = 60;
|
|||
|
ts.GridColumnStyles[2].Width = 60;
|
|||
|
ts.GridColumnStyles[3].Width = 90;
|
|||
|
}
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
dgts.GridColumnStyles[0].Width = 80;
|
|||
|
dgts.GridColumnStyles[1].Width = 35;
|
|||
|
dgts.GridColumnStyles[2].Width = 20;
|
|||
|
dgts.GridColumnStyles[3].Width = 0; //状态
|
|||
|
dgts.GridColumnStyles[4].Width = 65;
|
|||
|
dgts.GridColumnStyles[5].Width = 60;
|
|||
|
dgts.GridColumnStyles[6].Width = 140;
|
|||
|
dgts.GridColumnStyles[7].Width = 0;
|
|||
|
dgts.GridColumnStyles[8].Width = 0;
|
|||
|
dgts.GridColumnStyles[9].Width = 0;
|
|||
|
dgts.GridColumnStyles[10].Width = 0;
|
|||
|
dgts.GridColumnStyles[11].Width = 0;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
DataGridTableStyle dts = new DataGridTableStyle();
|
|||
|
//注意:必须加上这一句,否则自定义列格式无法使用
|
|||
|
dts.MappingName = "Table";
|
|||
|
dg.TableStyles.Clear();
|
|||
|
dg.TableStyles.Add(dts);
|
|||
|
dg.TableStyles[0].GridColumnStyles.Clear();
|
|||
|
//========================设置表头栏位===========================
|
|||
|
// DataGridTableStyle dtsLog = new DataGridTableStyle();
|
|||
|
|
|||
|
DataGridTextBoxColumn col1 = new DataGridTextBoxColumn();
|
|||
|
col1.Width = 140;
|
|||
|
col1.HeaderText = "品名";
|
|||
|
col1.MappingName = "goodsname";
|
|||
|
dg.TableStyles[0].GridColumnStyles.Add(col1);
|
|||
|
|
|||
|
DataGridTextBoxColumn col2 = new DataGridTextBoxColumn();
|
|||
|
col2.Width = 60;
|
|||
|
col2.HeaderText = "出库数量";
|
|||
|
col2.MappingName = "count";
|
|||
|
dg.TableStyles[0].GridColumnStyles.Add(col2);
|
|||
|
|
|||
|
DataGridTextBoxColumn col3 = new DataGridTextBoxColumn();
|
|||
|
col3.Width = 70;
|
|||
|
col3.HeaderText = "货位";
|
|||
|
col3.MappingName = "location";
|
|||
|
dg.TableStyles[0].GridColumnStyles.Add(col3);
|
|||
|
|
|||
|
DataGridTextBoxColumn col4 = new DataGridTextBoxColumn();
|
|||
|
col4.Width = 80;
|
|||
|
col4.HeaderText = "批号";
|
|||
|
col4.MappingName = "batch";
|
|||
|
dg.TableStyles[0].GridColumnStyles.Add(col4);
|
|||
|
|
|||
|
DataGridTextBoxColumn col5 = new DataGridTextBoxColumn();
|
|||
|
col5.Width = 150;
|
|||
|
col5.HeaderText = "厂家";
|
|||
|
col5.MappingName = "manufacturer";
|
|||
|
dg.TableStyles[0].GridColumnStyles.Add(col5);
|
|||
|
* */
|
|||
|
}
|
|||
|
|
|||
|
private void comStatus_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
bindBg1();
|
|||
|
}
|
|||
|
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void btnStart_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
|
|||
|
try
|
|||
|
{
|
|||
|
enumFlowTaskResult rt = client.startTask(lbTask.Text, LoginInfo.UserId, LoginInfo.Token);
|
|||
|
|
|||
|
MessageBox.Show(rt.ToString());
|
|||
|
if (rt == enumFlowTaskResult.成功)
|
|||
|
{
|
|||
|
tb1.SelectedIndex=0;
|
|||
|
clear();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception er)
|
|||
|
{
|
|||
|
showErrorMsg(er);
|
|||
|
}
|
|||
|
|
|||
|
Cursor.Current = System.Windows.Forms.Cursors.Default;
|
|||
|
|
|||
|
}
|
|||
|
void clear()
|
|||
|
{
|
|||
|
lbStatus.Text = lbTask.Text ="";
|
|||
|
dg2.DataSource =null;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void TaskList_Closing(object sender, CancelEventArgs e)
|
|||
|
{
|
|||
|
timer1.Enabled = false;
|
|||
|
timer1.Dispose();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|