1173 lines
41 KiB
C#
1173 lines
41 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.Frm.Base;
|
||
using WMS.Model.SC;
|
||
using WMS.Common;
|
||
using WMS.Model.SystemManage;
|
||
using WMS.Model.Base;
|
||
using WMS.Ctrl;
|
||
using WMS.FrmBaseData;
|
||
using WMS.Business;
|
||
using WMS.Business.SC;
|
||
using WMS.Business.Common;
|
||
using WMS.Business.SystemManage;
|
||
using WMS.Business.SC.WMS.Business.SC;
|
||
|
||
namespace WMS.FrmSC
|
||
{
|
||
public partial class FrmProcess : FormBase
|
||
{
|
||
#region 变量
|
||
/// <summary>
|
||
/// 班组人员
|
||
/// </summary>
|
||
List<TeamUserModel> tlist = new List<TeamUserModel>();
|
||
/// <summary>
|
||
/// 加工List
|
||
/// </summary>
|
||
public List<ScProcessModel> list = new List<ScProcessModel>();
|
||
|
||
/// <summary>
|
||
/// 加工Model
|
||
/// </summary>
|
||
public ScProcessModel model = new ScProcessModel();
|
||
|
||
/// <summary>
|
||
/// 加工破损实体
|
||
/// </summary>
|
||
public ProBreakModel break_model = new ProBreakModel();
|
||
|
||
/// <summary>
|
||
/// 加工破损集合
|
||
/// </summary>
|
||
public List<ProBreakModel> list_break = new List<ProBreakModel>();
|
||
public List<ProBreakModel> lis = new List<ProBreakModel>();
|
||
/// <summary>
|
||
/// 加工计划
|
||
/// </summary>
|
||
public ProcessPlanModel plan_model = new ProcessPlanModel();
|
||
/// <summary>
|
||
/// 操作标志 0 新增,1 修改
|
||
/// </summary>
|
||
public int flg;
|
||
/// <summary>
|
||
/// 计划商品关联
|
||
/// </summary>
|
||
public PlanGoodsModel plangoods_model = new PlanGoodsModel();
|
||
public List<PlanGoodsModel> list_plangoods_model = new List<PlanGoodsModel>();
|
||
/// <summary>
|
||
/// 计划商品关联集合
|
||
/// </summary>
|
||
public List<ProcessPlanModel> plan_list = new List<ProcessPlanModel>();
|
||
#endregion
|
||
|
||
#region 构造函数
|
||
public FrmProcess()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定任务
|
||
/// <summary>
|
||
/// 绑定任务
|
||
/// </summary>
|
||
/// <param name="plan_model"></param>
|
||
public void BindTask(ProcessPlanModel plan_model)
|
||
{
|
||
//已领料的任务
|
||
//plan_model.STATUS = "1";
|
||
List<ProcessPlanModel> list_process = new List<ProcessPlanModel>();
|
||
try
|
||
{
|
||
list_process = IBussFactory<BussProcessPlan>.Instance().GetScPlanList(plan_model);
|
||
if (list_process.Count <= 0)
|
||
{
|
||
bs_task.DataSource = list_process;
|
||
GVPlan.RefreshData();
|
||
return;
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("加载任务出错了:BindTask" + ex.Message);
|
||
return;
|
||
}
|
||
bs_task.DataSource = list_process;
|
||
GVPlan.RefreshData();
|
||
}
|
||
#endregion
|
||
DataTable tabUnit = new DataTable();
|
||
#region 绑定破损人 单位
|
||
/// <summary>
|
||
/// 绑定破损人 单位
|
||
/// </summary>
|
||
/// <param name="teamid"></param>
|
||
public void BindPer(string teamid)
|
||
{
|
||
|
||
// lueUnit.NullText = "";
|
||
lueUnit.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("VC_DICTIONARY_NAME", "单位"));
|
||
lueUnit.ValueMember = "VC_CHAR_VALUE";
|
||
lueUnit.DisplayMember = "VC_DICTIONARY_NAME";
|
||
|
||
try
|
||
{
|
||
tabUnit = IBussFactory<BussCommon>.Instance().GetCustomCtrlData("t_sys_dictionary_tab", "VC_CHAR_VALUE", "VC_DICTIONARY_NAME", " VC_DICTIONARY_TYPE = 'vc_uom' and c_flag = '1'", "");
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("绑定破损人单位BindPer出错了:" + ex.Message);
|
||
}
|
||
lueUnit.DataSource = tabUnit;
|
||
TeamUserModel user_model = new TeamUserModel();
|
||
user_model.TEAM_ID = teamid;
|
||
|
||
|
||
try
|
||
{
|
||
List<TeamUserModel> lstTeamUsers = IBussFactory<BussTeamUser>.Instance().GetList(user_model);
|
||
lue_p.DataSource = lstTeamUsers;
|
||
lue_p.ValueMember = "USER_ID";
|
||
lue_p.DisplayMember = "USER_NAME";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获得班组人员出错了:" + ex.Message);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定状态
|
||
/// <summary>
|
||
/// 绑定状态
|
||
/// </summary>
|
||
public void BindState()
|
||
{
|
||
DataTable dt_status = new DataTable();
|
||
dt_status.Columns.Add("ID", typeof(string));
|
||
dt_status.Columns.Add("Status", typeof(string));
|
||
DataRow dr = dt_status.NewRow();
|
||
dr["ID"] = "0";
|
||
dr["Status"] = "未领取";
|
||
dt_status.Rows.Add(dr);
|
||
dr = dt_status.NewRow();
|
||
dr["ID"] = "1";
|
||
dr["Status"] = "已领取";
|
||
dt_status.Rows.Add(dr);
|
||
dr = dt_status.NewRow();
|
||
dr["ID"] = "2";
|
||
dr["Status"] = "已完成";
|
||
dt_status.Rows.Add(dr);
|
||
dr = dt_status.NewRow();
|
||
dr["ID"] = "3";
|
||
dr["Status"] = "已作废";
|
||
dt_status.Rows.Add(dr);
|
||
dr = dt_status.NewRow();
|
||
dr["ID"] = "4";
|
||
dr["Status"] = "全部";
|
||
dt_status.Rows.Add(dr);
|
||
cmbState.Properties.DataSource = dt_status;
|
||
cmbState.Properties.DisplayMember = "Status";
|
||
cmbState.Properties.ValueMember = "ID";
|
||
cmbState.EditValue = 4;
|
||
}
|
||
#endregion
|
||
|
||
#region 页面加载
|
||
/// <summary>
|
||
/// 页面加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void FrmProcess_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
colFINISH_NUM1.OptionsColumn.AllowEdit = false;
|
||
colFINISH_DATE1.OptionsColumn.AllowEdit = false;
|
||
colBREAK_NUM.OptionsColumn.AllowEdit = false;
|
||
colBREAK_PER.OptionsColumn.AllowEdit = false;
|
||
colBREAK_DATE.OptionsColumn.AllowEdit = false;
|
||
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
|
||
// BSPlanTab.DataSource = plan_model;
|
||
// plan_model.STATUS = "1";
|
||
// BSPlanTab.EndEdit();//必须有
|
||
DateStar.DateTime = System.DateTime.Now.Date;
|
||
DateEnd.DateTime = System.DateTime.Now.Date;
|
||
BindState();
|
||
cmbStorage.LoadData();
|
||
cmbStorage.ItemIndex = 0;
|
||
BindPer(plangoods_model.TEAM_ID);
|
||
BindTask(plan_model);
|
||
xtraTabPage2.PageEnabled = false;
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
#region 按钮事件
|
||
|
||
#region 入成品库
|
||
/// <summary>
|
||
/// 入成品库
|
||
/// </summary>
|
||
public void InArea()
|
||
{
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
public override void Save()
|
||
{
|
||
bs_proc.EndEdit();
|
||
bs_ProcessBreak.EndEdit();
|
||
gridView2.CloseEditor();
|
||
gridView3.CloseEditor();
|
||
list = bs_proc.DataSource as List<ScProcessModel>;
|
||
if (list.Count <= 0)
|
||
{
|
||
return;
|
||
}
|
||
model = list[0];
|
||
if (model.FINISH_NUM == 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("产品完成数量不能为0!");
|
||
return;
|
||
}
|
||
if (list_break.Count(r => r.BREAK_NUM == 0) > 0)
|
||
{
|
||
if (SystemCommon.ShowMessageBoxResult("材料明细中含有破损数量为0的系统自动为你过滤是否继续?") != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
list_break = bs_ProcessBreak.DataSource as List<ProBreakModel>;
|
||
string errText = "";
|
||
try
|
||
{
|
||
errText = IBussFactory<BussProcess>.Instance().ManageProAndBreak(model, list_break.FindAll(r => r.BREAK_NUM != 0), flg);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("保存失败了:ManageProAndBreak" + ex.Message);
|
||
return;
|
||
}
|
||
if (errText == "")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
colFINISH_NUM1.OptionsColumn.AllowEdit = false;
|
||
colFINISH_DATE1.OptionsColumn.AllowEdit = false;
|
||
colBREAK_NUM.OptionsColumn.AllowEdit = false;
|
||
colBREAK_PER.OptionsColumn.AllowEdit = false;
|
||
colBREAK_DATE.OptionsColumn.AllowEdit = false;
|
||
xtraTabControl1.SelectedTabPageIndex = 0;
|
||
if (frmButtonItem.ContainsKey("Save"))
|
||
{
|
||
frmButtonItem["Save"].Enabled = false;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Edit"))
|
||
{
|
||
frmButtonItem["Edit"].Enabled = true;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Refresh"))
|
||
{
|
||
frmButtonItem["Refresh"].Enabled = true;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Search"))
|
||
{
|
||
frmButtonItem["Search"].Enabled = true;
|
||
}
|
||
if (frmButtonItem.ContainsKey("JiaGong"))
|
||
{
|
||
frmButtonItem["JiaGong"].Enabled = true;
|
||
}
|
||
BindPlanGoods();
|
||
xtraTabControl1.SelectedTabPageIndex = 0;
|
||
xtraTabPage1.PageEnabled = true;
|
||
xtraTabPage2.PageEnabled = false;
|
||
}
|
||
else
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("操作失败:" + errText);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
public override void Search()
|
||
{
|
||
plan_model = new ProcessPlanModel();
|
||
if (DateStar.DateTime > System.DateTime.Now)
|
||
{
|
||
SystemCommon.ShowMessageBoxResult("起始时间不能大于当前时间!");
|
||
DateStar.Focus();
|
||
return;
|
||
}
|
||
if (DateEnd.DateTime < DateStar.DateTime)
|
||
{
|
||
SystemCommon.ShowMessageBoxResult("起始时间不能大于结束时间!");
|
||
DateEnd.Focus();
|
||
return;
|
||
}
|
||
plan_model.DATESTAR = DateStar.DateTime;
|
||
plan_model.DATEEND = DateEnd.DateTime;
|
||
if (!string.IsNullOrEmpty(txtPlanNameSel.Text))
|
||
{
|
||
plan_model.PLAN_NAME = txtPlanNameSel.Text;
|
||
}
|
||
if (!string.IsNullOrEmpty(cmbStorage.Text))
|
||
{
|
||
plan_model.STORAGE_ID = cmbStorage.EditValue.ToString();
|
||
}
|
||
if (cmbState.Text != "全部")
|
||
{
|
||
plan_model.STATUS = cmbState.EditValue.ToString();
|
||
}
|
||
if (str_goods_IDS != "()")
|
||
{
|
||
plan_model.Str_goods_ids = str_goods_IDS;
|
||
}
|
||
BindTask(plan_model);
|
||
|
||
xtraTabControl1.SelectedTabPageIndex = 0;
|
||
xtraTabPage1.PageEnabled = true;
|
||
xtraTabPage2.PageEnabled = false;
|
||
}
|
||
#endregion
|
||
|
||
#region 刷新
|
||
/// <summary>
|
||
/// 刷新
|
||
/// </summary>
|
||
public override void Refresh()
|
||
{ // cmbStorage.LoadData();
|
||
cmbStorage.Text = "";
|
||
DateStar.DateTime = System.DateTime.Now.Date;
|
||
DateEnd.DateTime = System.DateTime.Now.Date;
|
||
str_goods_IDS = "()";
|
||
txtPlanNameSel.Text = "";
|
||
ctr_Goods.TextBoxValue = "";
|
||
cmbState.EditValue = "4";
|
||
Search();
|
||
|
||
colFINISH_NUM1.OptionsColumn.AllowEdit = false;
|
||
colFINISH_DATE1.OptionsColumn.AllowEdit = false;
|
||
colBREAK_NUM.OptionsColumn.AllowEdit = false;
|
||
colBREAK_PER.OptionsColumn.AllowEdit = false;
|
||
colBREAK_DATE.OptionsColumn.AllowEdit = false;
|
||
|
||
if (frmButtonItem.ContainsKey("Save"))
|
||
{
|
||
frmButtonItem["Save"].Enabled = false;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Edit"))
|
||
{
|
||
frmButtonItem["Edit"].Enabled = true;
|
||
}
|
||
if (frmButtonItem.ContainsKey("JiaGong"))
|
||
{
|
||
frmButtonItem["JiaGong"].Enabled = true;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加工
|
||
/// <summary>
|
||
/// 加工
|
||
/// </summary>
|
||
public void JiaGong()
|
||
{
|
||
if (GVPlanGoods.FocusedRowHandle < 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("请选择一个商品!");
|
||
return;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Save"))
|
||
{
|
||
frmButtonItem["Save"].Enabled = true;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Edit"))
|
||
{
|
||
frmButtonItem["Edit"].Enabled = false;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Refresh"))
|
||
{
|
||
frmButtonItem["Refresh"].Enabled = false;
|
||
}
|
||
if (frmButtonItem.ContainsKey("Search"))
|
||
{
|
||
frmButtonItem["Search"].Enabled = false;
|
||
}
|
||
if (frmButtonItem.ContainsKey("JiaGong"))
|
||
{
|
||
frmButtonItem["JiaGong"].Enabled = false;
|
||
}
|
||
xtraTabControl1.SelectedTabPageIndex = 1;
|
||
xtraTabPage1.PageEnabled = false;
|
||
xtraTabPage2.PageEnabled = true;
|
||
flg = 0;
|
||
colFINISH_NUM1.OptionsColumn.AllowEdit = true;
|
||
colFINISH_DATE1.OptionsColumn.AllowEdit = true;
|
||
colBREAK_NUM.OptionsColumn.AllowEdit = true;
|
||
colBREAK_PER.OptionsColumn.AllowEdit = true;
|
||
colBREAK_DATE.OptionsColumn.AllowEdit = true;
|
||
#region 加载产品数据
|
||
|
||
if (plangoods_model == null)
|
||
{
|
||
return;
|
||
}
|
||
plangoods_model = GVPlanGoods.GetFocusedRow() as PlanGoodsModel;
|
||
// BindPer(plangoods_model.TEAM_ID);
|
||
gridView3.CloseEditor();
|
||
model = new ScProcessModel();
|
||
model.GOODS_ID = plangoods_model.GOODS_ID;
|
||
model.Goods_name = plangoods_model.GOODS_NAME;
|
||
model.TASK_ID = plangoods_model.PLAN_ID;
|
||
model.Task_name = plangoods_model.PLAN_NAME;
|
||
model.RecordDate = System.DateTime.Now;
|
||
model.RECORD_PER = userData.USER_ID;
|
||
model.Record_per_name = userData.NAME;
|
||
model.STORAGE_ID = plan_model.STORAGE_ID;
|
||
model.Storage_name = plan_model.STORAGE_NAME;
|
||
model.Group_id = plangoods_model.TEAM_ID;
|
||
model.Group_name = plangoods_model.TEAM_NAME;
|
||
model.FINISH_NUM = 0;
|
||
model.GOODS_NUM = plangoods_model.GOODS_NUM;
|
||
model.LAST_NUM = plangoods_model.GOODS_NUM - plangoods_model.GOODS_COMPLETENUM;
|
||
model.FINISH_DATE = System.DateTime.Now;
|
||
model.Status = "1";
|
||
list.Clear();
|
||
bs_proc.DataSource = list;
|
||
list.Add(model);
|
||
gridView3.RefreshData();
|
||
|
||
WorkingTaskModel goods_ma_model = new WorkingTaskModel();
|
||
goods_ma_model.PALAN_ID = model.TASK_ID;
|
||
goods_ma_model.GOODS_ID = model.GOODS_ID;
|
||
string str_goods_ma_model = Newtonsoft.Json.JsonConvert.SerializeObject(goods_ma_model);
|
||
List<WorkingTaskModel> goods_ma_list = new List<WorkingTaskModel>();
|
||
try
|
||
{
|
||
goods_ma_list = IBussFactory<BussWorkingTask>.Instance().GetMaterialList(goods_ma_model);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获得物料列表集合失败:" + ex.Message);
|
||
return;
|
||
}
|
||
List<DictionaryTabModel> dictionarytabmodel_list = new List<DictionaryTabModel>();
|
||
try
|
||
{
|
||
dictionarytabmodel_list = IBussFactory<BussDictionaryTab>.Instance().GetDictionaryTab("Step");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获得字典明细出错了GetDictionaryTab('Step')" + ex.Message);
|
||
return;
|
||
}
|
||
|
||
if (goods_ma_list.Count <= 0 || dictionarytabmodel_list.Count <= 0)
|
||
{
|
||
return;
|
||
}
|
||
list_break = new List<ProBreakModel>();
|
||
DateTime dt_now = System.DateTime.Now.Date;
|
||
goods_ma_list.ForEach(r =>
|
||
{
|
||
dictionarytabmodel_list.ForEach(x =>
|
||
{
|
||
break_model = new ProBreakModel();
|
||
break_model.STEP_ID = x.VC_CHAR_VALUE;
|
||
break_model.Step_name = x.VC_DICTIONARY_NAME;
|
||
break_model.MATERIAL_ID = r.MATERIAL_ID;
|
||
break_model.Material_name = r.MATERIAL_NAME;
|
||
break_model.MATERIAL_NUM = r.REALITY_NUM;
|
||
break_model.BREAK_NUM = 0;
|
||
break_model.BREAK_DATE = dt_now;
|
||
break_model.GOODS_ID = r.GOODS_ID;
|
||
break_model.Goods_name = r.GOODS_NAME;
|
||
break_model.STORAGE_ID = model.STORAGE_ID;
|
||
break_model.Storage_name = model.Storage_name;
|
||
break_model.TASK_ID = model.TASK_ID;
|
||
break_model.Task_name = model.Task_name;
|
||
break_model.UNIT = r.UNIT;
|
||
break_model.Unit_name = r.UNIT_NAME;
|
||
break_model.RECORD_DATE = DateTime.Now.Date;
|
||
break_model.RECORD_PER = userData.USER_ID;
|
||
//PlanGoodsModel gooModel = new PlanGoodsModel();
|
||
//gooModel.PLAN_ID = r.PALAN_ID;
|
||
//gooModel.GOODS_ID = r.GOODS_ID;
|
||
list_break.Add(break_model);
|
||
});
|
||
});
|
||
|
||
bs_ProcessBreak.DataSource = list_break;
|
||
gridView2.RefreshData();
|
||
|
||
#endregion
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region 材料破损单元格值改变
|
||
/// <summary>
|
||
/// 材料破损单元格值改变
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
||
{
|
||
//if (e.Column.Name == "colGoods_num")
|
||
//{
|
||
// decimal goods_num = Convert.ToDecimal(gridView2.GetFocusedRowCellValue(colGoods_num).ToString());
|
||
|
||
// decimal goods_all_num = Convert.ToDecimal(gridView2.GetFocusedRowCellValue(colGoods_all_num).ToString());
|
||
// if (goods_all_num < goods_num)
|
||
// {
|
||
// SystemCommon.ShowInfoMessageBox("完成数量不能大于任务数量!");
|
||
// gridView2.SetFocusedRowCellValue(colGoods_num, 0);
|
||
// return;
|
||
// }
|
||
// decimal last = Convert.ToDecimal(gridView2.GetFocusedRowCellValue(colLAST_NUM2).ToString());
|
||
// if (goods_num > last)
|
||
// {
|
||
// SystemCommon.ShowInfoMessageBox("完成数量不能大于剩余数量!");
|
||
// gridView2.SetFocusedRowCellValue(colGoods_num, 0);
|
||
// return;
|
||
// }
|
||
|
||
// decimal _temp = goods_num - old_num;
|
||
// if (goods_num == 0)
|
||
// {
|
||
// gridView2.SetFocusedRowCellValue(colLast_num1, last + _temp);
|
||
// return;
|
||
// }
|
||
|
||
// if (goods_all_num == goods_num)
|
||
// {
|
||
// if (SystemCommon.ShowMessageBoxResult("完成数量和任务数量已经相等是否确认?") != DialogResult.OK)
|
||
// {
|
||
// return;
|
||
// }
|
||
// gridView3.SetFocusedRowCellValue(colLAST_NUM2, 0);
|
||
// }
|
||
// gridView3.SetFocusedRowCellValue(colLAST_NUM2, last - goods_num);
|
||
|
||
// return;
|
||
// //decimal all_num = gridView2.GetFocusedDataRow() as ProBreakModel;
|
||
//}
|
||
if (e.Column.Name == "colBREAK_NUM")
|
||
{
|
||
decimal BREAK_NUM = Convert.ToDecimal(gridView2.GetFocusedRowCellValue(colBREAK_NUM).ToString());
|
||
if (BREAK_NUM == 0)
|
||
{
|
||
return;
|
||
}
|
||
decimal mat_num = Convert.ToDecimal(gridView2.GetFocusedRowCellValue(colMATERIAL_NUM).ToString());
|
||
if (BREAK_NUM > mat_num)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("破损数量不能大于材料数量");
|
||
gridView2.SetFocusedRowCellValue(colBREAK_NUM, 0);
|
||
return;
|
||
}
|
||
//gridView2.SetFocusedRowCellValue(colLAST_NUM, mat_num - BREAK_NUM);
|
||
}
|
||
if (e.Column.Name == "colGoods_complete_date")
|
||
{
|
||
DateTime dt_goods_com_date = Convert.ToDateTime(gridView2.GetFocusedRowCellValue(colGoods_complete_date).ToString());
|
||
if (dt_goods_com_date == System.DateTime.Now)
|
||
{
|
||
return;
|
||
}
|
||
if (dt_goods_com_date > System.DateTime.Now)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("日期不能大于当前日期!");
|
||
gridView2.SetFocusedRowCellValue(colGoods_complete_date, System.DateTime.Now);
|
||
return;
|
||
}
|
||
}
|
||
if (e.Column.Name == "colBREAK_DATE")
|
||
{
|
||
DateTime dt_BREAK_DATE = Convert.ToDateTime(gridView2.GetFocusedRowCellValue(colBREAK_DATE).ToString());
|
||
if (dt_BREAK_DATE > System.DateTime.Now)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("日期不能大于当前日期!");
|
||
gridView2.SetFocusedRowCellValue(colBREAK_DATE, System.DateTime.Now);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 产品完成单元格值改变
|
||
/// <summary>
|
||
/// 产品完成单元格值改变
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView3_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colFINISH_NUM1")
|
||
{
|
||
decimal goods_all_num = Convert.ToDecimal(gridView3.GetFocusedRowCellValue(colGOODS_NUM1).ToString());
|
||
decimal goods_finish_num = Convert.ToDecimal(gridView3.GetFocusedRowCellValue(colFINISH_NUM1).ToString());
|
||
|
||
if (goods_finish_num == 0)
|
||
{
|
||
gridView3.SetFocusedRowCellValue(colLAST_NUM2, goods_all_num - old_num);
|
||
return;
|
||
}
|
||
|
||
if (goods_finish_num > goods_all_num)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("完成数量不能大于任务数量!");
|
||
gridView3.SetFocusedRowCellValue(colFINISH_NUM1, 0);
|
||
}
|
||
else if (goods_finish_num == goods_all_num)
|
||
{
|
||
if (SystemCommon.ShowMessageBoxResult("完成数量等于任务数量确认完成此任务?") != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
gridView3.SetFocusedRowCellValue(colStatus3, "1");
|
||
}
|
||
else
|
||
{
|
||
decimal last_num = Convert.ToDecimal(gridView3.GetFocusedRowCellValue(colLAST_NUM2).ToString());
|
||
if (flg == 1)
|
||
{
|
||
if (last_num > 0)
|
||
{
|
||
decimal te = old_num - goods_finish_num;
|
||
last_num += te;
|
||
}
|
||
else
|
||
{
|
||
last_num = goods_all_num - goods_finish_num;
|
||
}
|
||
old_num = goods_finish_num;
|
||
gridView3.SetFocusedRowCellValue(colLAST_NUM2, last_num);
|
||
}
|
||
else
|
||
{
|
||
decimal t = last_num - goods_finish_num;
|
||
gridView3.SetFocusedRowCellValue(colLAST_NUM2, last_num);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
if (e.Column.Name == "colFINISH_DATE1")
|
||
{
|
||
DateTime dt_finsh = Convert.ToDateTime(gridView3.GetFocusedRowCellValue(colFINISH_DATE1).ToString());
|
||
if (dt_finsh <= System.DateTime.Now)
|
||
{
|
||
return;
|
||
}
|
||
if (dt_finsh > System.DateTime.Now)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("完成日期不能大于当前日期!");
|
||
gridView3.SetFocusedRowCellValue(colFINISH_DATE1, System.DateTime.Now.Date);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
#region 自定义列
|
||
|
||
#region 单位
|
||
/// <summary>
|
||
/// 单位
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
#region 单位
|
||
//if (e.Column.FieldName == "UNIT")
|
||
//{
|
||
// if (e.Value == null)
|
||
// {
|
||
// return;
|
||
// }
|
||
// switch (e.Value.ToString().Trim())
|
||
// {
|
||
// case "a":
|
||
// e.DisplayText = "盒";
|
||
// break;
|
||
// case "b":
|
||
// e.DisplayText = "罐";
|
||
// break;
|
||
// case "c":
|
||
// e.DisplayText = "袋";
|
||
// break;
|
||
// case "d":
|
||
// e.DisplayText = "瓶";
|
||
// break;
|
||
// case "e":
|
||
// e.DisplayText = "个";
|
||
// break;
|
||
// case "f":
|
||
// e.DisplayText = "包";
|
||
// break;
|
||
// case "g":
|
||
// e.DisplayText = "把";
|
||
// break;
|
||
// case "h":
|
||
// e.DisplayText = "筒";
|
||
// break;
|
||
// case "i":
|
||
// e.DisplayText = "张";
|
||
// break;
|
||
// case "j":
|
||
// e.DisplayText = "套";
|
||
// break;
|
||
// case "k":
|
||
// e.DisplayText = "克";
|
||
// break;
|
||
// case "l":
|
||
// e.DisplayText = "泡";
|
||
// break;
|
||
// case "m":
|
||
// e.DisplayText = "片";
|
||
// break;
|
||
// case "z":
|
||
// e.DisplayText = "箱";
|
||
// break;
|
||
// default:
|
||
// e.DisplayText = "";
|
||
// break;
|
||
// }
|
||
//}
|
||
#endregion
|
||
}
|
||
#endregion
|
||
|
||
private void gridView1_CustomColumnDisplayText_1(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
#region 完成状态
|
||
if (e.Column.FieldName == "Status")
|
||
{
|
||
if (e.Value == null)
|
||
{
|
||
return;
|
||
}
|
||
switch (e.Value.ToString())
|
||
{
|
||
case "0":
|
||
e.DisplayText = "未完成";
|
||
break;
|
||
case "1":
|
||
e.DisplayText = "已完成";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定计划商品
|
||
/// <summary>
|
||
/// 绑定计划商品
|
||
/// </summary>
|
||
public void BindPlanGoods()
|
||
{
|
||
if (GVPlan.FocusedRowHandle >= 0)
|
||
{
|
||
plan_model = GVPlan.GetFocusedRow() as ProcessPlanModel;
|
||
plangoods_model = new PlanGoodsModel();
|
||
plangoods_model.PLAN_ID = plan_model.PLAN_ID;
|
||
try
|
||
{
|
||
list_plangoods_model = IBussFactory<BussPlanGoods>.Instance().GetPlanGoodsList(plangoods_model);
|
||
BSPlanGoodsSel.DataSource = list_plangoods_model;
|
||
GVPlanGoods.RefreshData();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获得计划商品列表出错了:BussPlanGoods-GetList" + ex.Message);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
BSPlanGoodsSel.DataSource = null;
|
||
GVPlanGoods.RefreshData();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 聚焦行改变事件
|
||
/// <summary>
|
||
/// 聚焦行改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVPlan_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
||
{
|
||
BindPlanGoods();
|
||
xtraTabPage2.Text = "加工完成-" + plan_model.PLAN_ID;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 计划商品聚焦行改变
|
||
/// <summary>
|
||
/// 计划商品聚焦行改变
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVPlanGoods_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
||
{
|
||
if (GVPlanGoods.FocusedRowHandle < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
plangoods_model = new PlanGoodsModel();
|
||
plangoods_model = GVPlanGoods.GetFocusedRow() as PlanGoodsModel;
|
||
if (!frmButtonItem["JiaGong"].Enabled)
|
||
{
|
||
return;
|
||
}
|
||
if (plangoods_model == null)
|
||
{
|
||
return;
|
||
}
|
||
model = new ScProcessModel();
|
||
model.GOODS_ID = plangoods_model.GOODS_ID;
|
||
model.TASK_ID = plangoods_model.PLAN_ID;
|
||
|
||
try
|
||
{
|
||
|
||
list = IBussFactory<BussProcess>.Instance().GetProcess(model);
|
||
bs_proc.DataSource = list;
|
||
gridView3.RefreshData();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
return;
|
||
}
|
||
|
||
|
||
#region 破损
|
||
|
||
//ProcessGoodsModel mo = new ProcessGoodsModel();
|
||
//mo = gridView3.GetFocusedRow() as ProcessGoodsModel;
|
||
//if (mo == null)
|
||
//{
|
||
// list_break.Clear();
|
||
// bs_ProcessBreak.DataSource = list_break;
|
||
// gridView2.RefreshData();
|
||
// return;
|
||
//}
|
||
|
||
// BindPer(plangoods_model.TEAM_ID);
|
||
ProBreakModel bre_model = new ProBreakModel();
|
||
bre_model.GOODS_ID = plangoods_model.GOODS_ID;
|
||
bre_model.TASK_ID = plangoods_model.PLAN_ID;
|
||
try
|
||
{
|
||
list_break = IBussFactory<BussProBreak>.Instance().GetProBreak(bre_model);
|
||
bs_ProcessBreak.DataSource = list_break;
|
||
gridView2.RefreshData();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("获得破损集合出错了:" + ex.Message);
|
||
return;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
#endregion
|
||
|
||
#region 双击进入商品明细
|
||
/// <summary>
|
||
/// 双击进入商品明细
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVPlanGoods_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
xtraTabControl1.SelectedTabPageIndex = 1;
|
||
}
|
||
#endregion
|
||
|
||
#region 计划状态
|
||
/// <summary>
|
||
/// 计划状态
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVPlan_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colSTATUS")
|
||
{
|
||
if (e.Value != null)
|
||
{
|
||
switch (e.Value.ToString())
|
||
{
|
||
case "1":
|
||
e.DisplayText = "未完成";
|
||
break;
|
||
case "2":
|
||
e.DisplayText = "已完成";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 完成状态
|
||
/// <summary>
|
||
/// 完成状态
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView3_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colStatus3")
|
||
{
|
||
if (e.Value != null)
|
||
{
|
||
switch (e.Value.ToString())
|
||
{
|
||
case "1":
|
||
e.DisplayText = "已完成";
|
||
break;
|
||
case "2":
|
||
e.DisplayText = "已入库";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定破损
|
||
/// <summary>
|
||
/// 绑定破损
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView3_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
|
||
{
|
||
#region 加工商品
|
||
|
||
//if (!frmButtonItem["JiaGong"].Enabled)
|
||
//{
|
||
// return;
|
||
//}
|
||
//if (plangoods_model == null)
|
||
//{
|
||
// return;
|
||
//}
|
||
//model = new ProcessGoodsModel();
|
||
//model.GOODS_ID = plangoods_model.GOODS_ID;
|
||
//model.TASK_ID = plangoods_model.PLAN_ID;
|
||
//string _str_model = Newtonsoft.Json.JsonConvert.SerializeObject(model);
|
||
|
||
//string _str_list = "";
|
||
//try
|
||
//{
|
||
// _str_list = WebLockConfig.Instance.WebProcess.GetProcess(_str_model);
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
// return;
|
||
//}
|
||
//list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProcessGoodsModel>>(_str_list);
|
||
//bs_proc.DataSource = list;
|
||
//gridView3.RefreshData();
|
||
|
||
//#endregion
|
||
|
||
//#region 破损
|
||
|
||
//ProcessGoodsModel mo = new ProcessGoodsModel();
|
||
//mo = gridView3.GetFocusedRow() as ProcessGoodsModel;
|
||
//if (mo == null)
|
||
//{
|
||
// return;
|
||
//}
|
||
//ProBreakModel bre_model = new ProBreakModel();
|
||
//bre_model.GOODS_ID = mo.GOODS_ID;
|
||
//bre_model.TASK_ID = mo.TASK_ID;
|
||
|
||
//string str_bre_model = Newtonsoft.Json.JsonConvert.SerializeObject(bre_model);
|
||
//string str_bre_list = "";
|
||
//try
|
||
//{
|
||
// str_bre_list = WebLockConfig.Instance.WebProBreak.GetProBreak(str_bre_model);
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
||
// return;
|
||
//}
|
||
//list_break = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProBreakModel>>(str_bre_list);
|
||
|
||
//bs_ProcessBreak.DataSource = list_break;
|
||
//gridView2.RefreshData();
|
||
#endregion
|
||
}
|
||
#endregion
|
||
public string str_goods_IDS = "";
|
||
#region 所选择商品
|
||
/// <summary>
|
||
/// 所选择商品
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ctr_Goods_Button_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
if (ctr_Goods.SelectTable.Rows.Count >= 0)
|
||
{
|
||
str_goods_IDS = "(";
|
||
List<GoodsInfoModel> list_goods = new List<GoodsInfoModel>();
|
||
list_goods = ConvertHelper<GoodsInfoModel>.ConvertToList(ctr_Goods.SelectTable);
|
||
list_goods.ForEach(r =>
|
||
{
|
||
str_goods_IDS += "'";
|
||
str_goods_IDS += r.GOODS_ID;
|
||
str_goods_IDS += "',";
|
||
});
|
||
if (str_goods_IDS.EndsWith(","))
|
||
{
|
||
str_goods_IDS = str_goods_IDS.Substring(0, str_goods_IDS.Length - 1);
|
||
}
|
||
str_goods_IDS += ")";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
public decimal old_num = 0;
|
||
public ScProcessModel mo_process = new ScProcessModel();
|
||
|
||
#region 加工商品(点击时 如果为已领取则可以进行入库操作)
|
||
private void gridView3_Click(object sender, EventArgs e)
|
||
{
|
||
mo_process = gridView3.GetFocusedRow() as ScProcessModel;
|
||
if (mo_process != null)
|
||
{
|
||
if (mo_process.Status == "1")
|
||
{
|
||
frmButtonItem["InArea"].Enabled = true;
|
||
}
|
||
else
|
||
{
|
||
frmButtonItem["InArea"].Enabled = false;
|
||
}
|
||
old_num = mo_process.FINISH_NUM;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
|
||
/// <summary>
|
||
#region 标签切换
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
|
||
{
|
||
if (xtraTabControl1.SelectedTabPageIndex == 1)
|
||
{
|
||
mo_process = gridView3.GetFocusedRow() as ScProcessModel;
|
||
if (mo_process != null)
|
||
{
|
||
if (mo_process.Status == "1")
|
||
{
|
||
frmButtonItem["InArea"].Enabled = true;
|
||
}
|
||
else
|
||
{
|
||
frmButtonItem["InArea"].Enabled = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 显示商品资料
|
||
|
||
#region 计划商品单击显示商品资料
|
||
/// <summary>
|
||
/// 单击显示商品资料
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVPlanGoods_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colGOODS_NAME")
|
||
{
|
||
plangoods_model = GVPlanGoods.GetFocusedRow() as PlanGoodsModel;
|
||
if (plangoods_model != null && !string.IsNullOrEmpty(plangoods_model.GOODS_ID))
|
||
{
|
||
FrmGoodsInfoDet.IFlag = 2;
|
||
FrmGoodsInfoDet.StrGoodsID = plangoods_model.GOODS_ID;
|
||
FrmGoodsInfoDet.GetInstance().ShowDialog();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加工商品显示商品资料
|
||
/// <summary>
|
||
/// 显示商品资料
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gridView3_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colGoods_name2")
|
||
{
|
||
plangoods_model = GVPlanGoods.GetFocusedRow() as PlanGoodsModel;
|
||
if (plangoods_model != null && !string.IsNullOrEmpty(plangoods_model.GOODS_ID))
|
||
{
|
||
FrmGoodsInfoDet.IFlag = 2;
|
||
FrmGoodsInfoDet.StrGoodsID = plangoods_model.GOODS_ID;
|
||
FrmGoodsInfoDet.GetInstance().ShowDialog();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
}
|
||
}
|