| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
- using Core.StlMes.Client.PlnSaleOrd.工序排产;
- using Core.StlMes.Client.PlnSaleOrd.工序排产.entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- 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;
- namespace Core.StlMes.Client.PlnSaleOrd
- {
- public partial class FrmPlnPassmodel : FrmBase
- {
- private string passmPlanId = "";
- public FrmPlnPassmodel()
- {
- InitializeComponent();
- }
- private void FrmPlnPassmodel_Load(object sender, EventArgs e)
- {
- BaseHelper.setOtherColumnReadOnly(ultraGridPassModel, new string[] { "" });
- BaseHelper.InitCellPosition(ultraGridPassModel, new string[] { "PlanNum", "GxProSeq", "PassName" });
- BaseHelper.GridColumnCount(ultraGridPassModel, new string[] { "PlanNum" });
- PlanHelper.InitDropPline("D", "", txtPline1,this.ob);
- PlanHelper.InitDropPline("D", "", txtPline2, this.ob);
- //BaseHelper.NitializeDropDownBox(txtPline1, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPline", "PLINE_NAME", "PLINE_CODE", false, ob);
- // BaseHelper.NitializeDropDownBox(txtPline2, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPline", "PLINE_NAME", "PLINE_CODE", false, ob);
-
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query"://查询
- Query();
- break;
- case "Add"://新增
- Add();
- break;
- case "Update"://修改 q
- Update();
- break;
- case "Delete"://删除
- Delete();
- break;
- case "Close"://关闭
- this. Close();
- break;
- case "Export": //导出
- GridHelper.ulGridToExcel(ultraGridPassModel, "孔型信息");
- break;
- default:
- break;
- }
- }
- private void Query()
- {
- string plineCode = "";
- if (chcPline.Checked && txtPline1.Value != null)
- { plineCode = txtPline1.Value.ToString(); }
- string year = "";
- if (chcYear.Checked && txtYear1.Value != null)
- { year = DateTime.Parse(txtYear1.Value.ToString()).ToString("yyyy-MM"); }
- List<PlnPassmodelEntity> listSource = EntityHelper.GetData<PlnPassmodelEntity>
- ("com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.queryModel", new object[] { plineCode, year }, ob);
- plnPassmodelEntityBindingSource.DataSource = listSource;
- if (!passmPlanId.Equals("") && ultraGridPassModel.Rows.Count > 0)
- {
- foreach (UltraGridRow ugr in ultraGridPassModel.Rows)
- {
- if (ugr.Cells["PassmPlanId"].Text.Equals(passmPlanId))
- {
- ugr.Activate();
- break;
- }
- }
- }
- passmPlanId = "";
- }
- /// <summary>
- /// 新增验证时间
- /// </summary>
- /// <param name="plineCode"></param>
- /// <param name="planTimeB"></param>
- /// <returns></returns>
- private bool CheckEndTime(string plineCode, string planTimeB, string yearMonth)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.getMaxEndTime", new object[] { plineCode, yearMonth }, ob);
- if (dt == null || dt.Rows.Count == 0)
- {
- return true;
- }
- else
- {
- string maxEndTime = dt.Rows[0][0].ToString();
- if (maxEndTime.Length == 0)
- { return true; }
- else
- {
- DateTime dt1 = Convert.ToDateTime(planTimeB);
- DateTime dt2 = Convert.ToDateTime(maxEndTime);
- if (DateTime.Compare(dt1, dt2) >= 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
- /// <summary>
- /// 验证参数
- /// </summary>
- /// <returns></returns>
- private bool CheckParams()
- {
- if (txtPline2.Value == null) { MessageUtil.ShowWarning("请选择产线描述!", txtPline2); return false; }
- if (txtModel.Value == null) { MessageUtil.ShowWarning("请选择孔型描述!", txtModel); return false; }
- if (txtNum.Value == null || txtNum.Value.ToString().Equals("") || Convert.ToInt32(txtNum.Value.ToString()) <= 0) { MessageUtil.ShowWarning("请输入计划支数!", txtNum); return false; }
- if (txtYear2.Value == null) { MessageUtil.ShowWarning("请选择生产年月!", txtYear2); return false; }
- if (txtPlanTimeB.Value == null) { MessageUtil.ShowWarning("请选择开始时间!", txtPlanTimeB); return false; }
- if (txtPlanTimeE.Value == null) { MessageUtil.ShowWarning("请选择结束时间!", txtPlanTimeE); return false; }
- if (DateTime.Parse(txtPlanTimeB.Value.ToString()) > DateTime.Parse(txtPlanTimeE.Value.ToString())) { MessageUtil.ShowWarning("开始时间不能大于线束时间!", txtPlanTimeB); return false; }
- return true;
- }
- private void Add()
- {
- if (!CheckParams()) { return; }
- PlnPassmodelEntity entity = new PlnPassmodelEntity();
- string year = DateTime.Parse(txtYear2.Value.ToString()).ToString("yyyy-MM");
- int num = Convert.ToInt32(txtNum.Value.ToString());
- string modelCode = txtModel.Value.ToString();
- string modelName = txtModel.Text.Trim();
- string plineCode = txtPline2.Value.ToString();
- string plineName = txtPline2.Text.Trim();
- string planTimeB = DateTime.Parse(txtPlanTimeB.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- string planTimeE = DateTime.Parse(txtPlanTimeE.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- entity.PassCode = modelCode;
- entity.PassName = modelName;
- entity.PlineCode = plineCode;
- entity.PlineName = plineName;
- entity.ProMonth = year;
- entity.PlanNum = num;
- entity.BeginTime = planTimeB;
- entity.EndTime = planTimeE;
- entity.CreateName = UserInfo.GetUserName();
- if (!CheckEndTime(plineCode, planTimeB, year))
- {
- MessageUtil.ShowWarning("产线 " + plineName + " 新增记录的开始时间小于该产线的最大结束时间!", txtPlanTimeB);
- return;
- }
- string jsonStr = JSONFormat.Format(entity);
- if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.add", new object[] { jsonStr }, ob);
- if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
- else
- {
- MessageUtil.ShowWarning("新增成功!", ultraGridPassModel);
- Query();
- }
- }
- private void Update()
- {
- UltraGridRow ugr=ultraGridPassModel.ActiveRow;
- if(ugr==null){
- MessageUtil.ShowWarning("请选择要修改的记录!", ultraGridPassModel);
- return;
- }
- if (!CheckParams()) { return; }
- PlnPassmodelEntity entity = (PlnPassmodelEntity)ugr.ListObject;
- string year = DateTime.Parse(txtYear2.Value.ToString()).ToString("yyyy-MM");
- int num = Convert.ToInt32(txtNum.Value.ToString());
- string modelCode = txtModel.Value.ToString();
- string modelName = txtModel.Text.Trim();
- string plineCode = txtPline2.Value.ToString();
- string plineName = txtPline2.Text.Trim();
- string planTimeB = DateTime.Parse(txtPlanTimeB.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- string planTimeE = DateTime.Parse(txtPlanTimeE.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- entity.PassCode = modelCode;
- entity.PassName = modelName;
- entity.ProMonth = year;
- entity.PlanNum = num;
- entity.BeginTime = planTimeB;
- entity.EndTime = planTimeE;
- entity.UpdateName = UserInfo.GetUserName();
- string jsonStr = JSONFormat.Format(entity);
- if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
- {
- return;
- }
- passmPlanId = entity.PassmPlanId;
- string[] param = PlanHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.update", new object[] { jsonStr }, ob);
- if (param == null) { MessageUtil.ShowWarning("服务端处理失败!", ultraGridPassModel); }
- else
- {
- MessageUtil.ShowWarning(param[1], ultraGridPassModel);
- if ((bool.Parse(param[0]))) { Query(); }
- }
- }
- private void Delete()
- {
- UltraGridRow ugr = ultraGridPassModel.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择要删除的记录!", ultraGridPassModel);
- return;
- }
- if (!CheckParams()) { return; }
- PlnPassmodelEntity entity = (PlnPassmodelEntity)ugr.ListObject;
- string jsonStr = JSONFormat.Format(entity);
- if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No)
- {
- return;
- }
- string[] param = PlanHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.delete", new object[] { jsonStr }, ob);
- if (param == null) { MessageUtil.ShowWarning("服务端处理失败!", ultraGridPassModel); }
- else
- {
- MessageUtil.ShowWarning(param[1], ultraGridPassModel);
- if ((bool.Parse(param[0]))) { Query(); }
- }
- }
- private void chc_CheckedChanged(object sender, EventArgs e)
- {
- if (chcPline.Checked) { txtPline1.ReadOnly = false; } else { txtPline1.ReadOnly = true; }
- if (chcYear.Checked) { txtYear1.ReadOnly = false; } else { txtYear1.ReadOnly = true; }
- }
- private void ultraGridPassModel_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow ugr = ultraGridPassModel.ActiveRow;
- if (ugr == null)
- {
- return;
- }
- PlnPassmodelEntity entity = (PlnPassmodelEntity)ugr.ListObject;
- txtPline2.Value = entity.PlineCode;
- txtPline2.Text = entity.PlineName;
- txtModel.Value = entity.PassCode;
- txtModel.Text = entity.PassName;
- txtYear2.Value = DateTime.Parse(entity.ProMonth).ToString("yyyy-MM");
- txtNum.Value = Convert.ToInt32(entity.PlanNum.ToString());
- txtPlanTimeB.Value = DateTime.Parse(entity.BeginTime).ToString("yyyy-MM-dd HH:mm:ss");
- txtPlanTimeE.Value = DateTime.Parse(entity.EndTime).ToString("yyyy-MM-dd HH:mm:ss");
- }
- private void txtPline2_ValueChanged(object sender, EventArgs e)
- {
- if (txtPline2.Value == null)
- {
- txtModel.Clear();
- return;
- }
- BaseHelper.NitializeDropDownBox(txtModel, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPassModel", new Object[] { txtPline2.Value.ToString() }, "PASS_NAME", "PASS_CODE", false, ob);
- }
-
- }
- }
|