304 lines
10 KiB
C#
304 lines
10 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using WMS.Model.Strategy;
|
||
|
||
using WMS.Common;
|
||
using WMS.Model.Base;
|
||
using WMS.Frm.Base;
|
||
using WMS.Business;
|
||
|
||
namespace WMS.FrmStrategy
|
||
{
|
||
public partial class FrmAutoTaskDet : Form
|
||
{
|
||
/// <summary>
|
||
/// 自动创建任务实体
|
||
/// </summary>
|
||
public AutoTaskModel au_model = new AutoTaskModel();
|
||
|
||
/// <summary>
|
||
/// 自动创建任务List
|
||
/// </summary>
|
||
public List<AutoTaskModel> list = new List<AutoTaskModel>();
|
||
|
||
/// <summary>
|
||
/// 指派依据
|
||
/// </summary>
|
||
public AccordingModel acc_model = new AccordingModel();
|
||
|
||
/// <summary>
|
||
/// 指派依据集合
|
||
/// </summary>
|
||
public List<AccordingModel> list_acc = new List<AccordingModel>();
|
||
|
||
/// <summary>
|
||
/// 操作标志 0 新增,1 修改
|
||
/// </summary>
|
||
public int flg = 0;
|
||
|
||
|
||
/// <summary>
|
||
/// 当前登录用户信息
|
||
/// </summary>
|
||
public UserDataModel userData = new UserDataModel();
|
||
|
||
public FrmAutoTaskDet()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
public FrmAutoTaskDet(int flg, UserDataModel userData)
|
||
{
|
||
InitializeComponent();
|
||
|
||
this.flg = flg;
|
||
this.userData = userData;
|
||
}
|
||
|
||
private void FrmAutoTaskDet_Load(object sender, EventArgs e)
|
||
{
|
||
#region 事务类型
|
||
|
||
//事务类型
|
||
WorkTypeModel model = new WorkTypeModel();
|
||
string str_model = Newtonsoft.Json.JsonConvert.SerializeObject(model);
|
||
string str_work_list = "";
|
||
try
|
||
{
|
||
// str_work_list = WebLockConfig.Instance.WebWorkType.execWorkTypeGetList(str_model);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
return;
|
||
}
|
||
lue_Tran.Properties.ValueMember = "WORK_ID";
|
||
lue_Tran.Properties.DisplayMember = "WORK_NAME";
|
||
List<WorkTypeModel> li_worl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkTypeModel>>(str_work_list);
|
||
lue_Tran.Properties.DataSource = li_worl;
|
||
|
||
#endregion
|
||
|
||
#region 工种类型
|
||
|
||
lue_WorkType.Properties.DisplayMember = "KIND_NAME";
|
||
lue_WorkType.Properties.ValueMember = "WORK_KIND";
|
||
WorkTypeContackModel cont_model = new WorkTypeContackModel();
|
||
cont_model.WORK_TYPE = lue_Tran.EditValue.ToString();
|
||
string str_cont_model = Newtonsoft.Json.JsonConvert.SerializeObject(cont_model);
|
||
string str_list = "";
|
||
try
|
||
{
|
||
// str_list = WebLockConfig.Instance.WebWorkTypeContack.execWorkTypeContackGetList(str_cont_model);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
return;
|
||
}
|
||
List<WorkTypeContackModel> li_cont = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkTypeContackModel>>(str_list);
|
||
lue_WorkType.Properties.DataSource = li_cont;
|
||
#endregion
|
||
|
||
bs_AutoTask.DataSource = au_model;
|
||
lue_WorkType.EditValue = au_model.WORK_TYPE;
|
||
lue_Tran.EditValue = au_model.TRAN_TYPE;
|
||
|
||
if (flg == 1)
|
||
{
|
||
BindAccording();
|
||
}
|
||
else
|
||
{
|
||
radioGroup1.EditValue = "1";
|
||
rgProduce.EditValue = "1";
|
||
radioGroup2.EditValue = "1";
|
||
}
|
||
}
|
||
|
||
#region 绑定指派依据
|
||
/// <summary>
|
||
/// 绑定指派依据
|
||
/// </summary>
|
||
public void BindAccording()
|
||
{
|
||
acc_model = new AccordingModel();
|
||
acc_model.Auto_id = au_model.STRATEGY_ID;
|
||
string str_model = Newtonsoft.Json.JsonConvert.SerializeObject(acc_model);
|
||
string str_acc_list = "";
|
||
try
|
||
{
|
||
// str_acc_list = WebLockConfig.Instance.WebAccording.GetAccording(str_model);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
return;
|
||
}
|
||
|
||
list_acc = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AccordingModel>>(str_acc_list);
|
||
bs_According.DataSource = list_acc;
|
||
gridView1.RefreshData();
|
||
}
|
||
#endregion
|
||
|
||
#region 关闭按钮
|
||
/// <summary>
|
||
/// 关闭按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ctrlButtons2_Click(object sender, EventArgs e)
|
||
{
|
||
this.Close();
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void saveButton_Click(object sender, EventArgs e)
|
||
{
|
||
//bs_AutoTask.EndEdit();
|
||
//bs_According.EndEdit();
|
||
list_acc = bs_According.DataSource as List<AccordingModel>;
|
||
if (list_acc == null)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("依据不能为空!");
|
||
return;
|
||
}
|
||
if (list_acc.Count <= 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("指派依据不能为空!请先增加指派依据!");
|
||
return;
|
||
}
|
||
au_model = bs_AutoTask.DataSource as AutoTaskModel;
|
||
au_model.CREATE_DATE = System.DateTime.Now.Date;
|
||
au_model.USER_ID = userData.USER_ID;
|
||
if (lue_Tran.EditValue != null)
|
||
{
|
||
au_model.TRAN_TYPE = lue_Tran.EditValue.ToString();
|
||
}
|
||
if (lue_WorkType.EditValue != null)
|
||
{
|
||
au_model.WORK_TYPE = lue_WorkType.EditValue.ToString();
|
||
}
|
||
|
||
string str_model = Newtonsoft.Json.JsonConvert.SerializeObject(au_model);
|
||
string str_list_acc = Newtonsoft.Json.JsonConvert.SerializeObject(list_acc);
|
||
string errText = "";
|
||
try
|
||
{
|
||
// errText = WebLockConfig.Instance.WebAutoTask.ManageAutoTask(str_model, str_list_acc, flg);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误");
|
||
return;
|
||
}
|
||
if (errText == "")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void label6_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void ctrlButtons1_Click(object sender, EventArgs e)
|
||
{
|
||
if (txt_Start.Text.Trim() == "")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("区间开始不能为空!");
|
||
txt_Start.Focus();
|
||
return;
|
||
}
|
||
if (txt_End.Text.Trim() == "")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("区间结束不能为空!");
|
||
txt_End.Focus();
|
||
return;
|
||
}
|
||
if (txt_Count.Text.Trim() == "")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("取件件数不能为空!");
|
||
txt_Count.Focus();
|
||
return;
|
||
}
|
||
if (Convert.ToInt32(txt_End.Text) <= Convert.ToInt32(txt_Start.Text))
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("区间结束必须大于区间开始");
|
||
txt_Start.SelectAll();
|
||
txt_Start.Focus();
|
||
return;
|
||
}
|
||
|
||
acc_model = new AccordingModel();
|
||
// acc_model.ACCORD_ID = WebLockConfig.Instance.WebAccording.GetSerNum(); ;
|
||
acc_model.Auto_id = au_model.STRATEGY_ID;
|
||
acc_model.ACCORD_START = Convert.ToDecimal(txt_Start.Text);
|
||
acc_model.ACCORD_END = Convert.ToDecimal(txt_End.Text);
|
||
acc_model.ACCORD_NUM = Convert.ToDecimal(txt_Count.Text);
|
||
if (list_acc != null && list_acc.Count > 0)
|
||
{
|
||
if (list_acc.FindAll(r => r.ACCORD_START == acc_model.ACCORD_START && r.ACCORD_END == acc_model.ACCORD_END).Count > 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("该依据已经包含该区间!请重新输入");
|
||
txt_Start.SelectAll();
|
||
txt_Start.Focus();
|
||
return;
|
||
}
|
||
}
|
||
|
||
list_acc.Add(acc_model);
|
||
bs_According.DataSource = list_acc;
|
||
gridView1.RefreshData();
|
||
}
|
||
|
||
private void DicWorkKind_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void lue_Tran_EditValueChanged(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(lue_Tran.Text))
|
||
{
|
||
//DicWorkKind.selSql = "select VC_CHAR_VALUE,VC_DICTIONARY_NAME from t_sys_dictionary_tab where VC_DICTIONARY_TYPE='workkind_type'";
|
||
//DicWorkKind.selSql += " and VC_CHAR_VALUE in (select work_kind from WorkTypeContack where work_type = '" + lue_Tran.EditValue.ToString() + "')";
|
||
//DicWorkKind.selSql += " order by VC_CHAR_VALUE";
|
||
lue_WorkType.Properties.DisplayMember = "KIND_NAME";
|
||
lue_WorkType.Properties.ValueMember = "WORK_KIND";
|
||
WorkTypeContackModel cont_model = new WorkTypeContackModel();
|
||
cont_model.WORK_TYPE = lue_Tran.EditValue.ToString();
|
||
string str_cont_model = Newtonsoft.Json.JsonConvert.SerializeObject(cont_model);
|
||
string str_list = "";
|
||
try
|
||
{
|
||
// str_list = IBussFactory<BussWorkTypeContack>.Instance().execWorkTypeContackGetList(str_cont_model);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
return;
|
||
}
|
||
List<WorkTypeContackModel> li_cont = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkTypeContackModel>>(str_list);
|
||
lue_WorkType.Properties.DataSource = li_cont;
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|