| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106 |
- 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 CoreFS.CA06;
- using Core.Mes.Client.Comm.Control;
- using Pur.Entity.configureEntity;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using Pur.Entity.require_planEntiy;
- using Pur.configure;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Pur.Pop_upWindow;
- using Bpm;
- using Pur.Entity;
- using Infragistics.Win;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win.UltraWinEditors;
- namespace Pur.require_plan
- {
- public partial class FrmPurRequirePlanOld : FrmPmsBase
- {
- public FrmPurRequirePlanOld()
- {
- InitializeComponent();
- }
- private void FrmPurRequirePlanOld_Load(object sender, EventArgs e)//Load
- {
- strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString();
- //初始化查询区域信息
- ck_ctime.Checked = true;
- txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2);
- txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
- //状态
- txt_Status.SelectedIndex = 0;
- Ck_IsJIT.Checked = false;
- txt_deliveryLocation.Enabled = false;
- //紧急程度
- cop_UrgencyType.SelectedIndex = 0;
- //审批流程
- txt_auditType.SelectedIndex = -1;
- txt_MRPERIODEND.Enabled = false;
- //加载计划类型数据
- DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
- if (strCoustomInfo == "1")//生产厂
- {
- comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", "");
- txt_auditType.Visible = true;
- txt_auditType_lab.Visible = true;
- txt_itemAuditType_lab.Visible = true;
- txt_itemAuditType.Visible = true;
-
- }
- else if (strCoustomInfo == "2")//供应部
- {
- comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122103','122101')", false, "", "");
- this.ToolBarItemEnable(this, "DoReceive", false);
- this.ToolBarItemEnable(this, "Process", false);
- //ultraTabControl2.Tabs[1].Visible = false;
- txt_auditType.Visible = false;
- txt_auditType_lab.Visible = false;
- txt_itemAuditType_lab.Visible = false;
- txt_itemAuditType.Visible = false;
- }
- else//厂区
- {
- comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122104')", false, "", "");
- //this.ToolBarItemEnable(this, "Query", true);
- //this.ToolBarItemEnable(this, "Add", true);
- //this.ToolBarItemEnable(this, "Update", true);
- //this.ToolBarItemEnable(this, "Delete", true);
- //this.ToolBarItemEnable(this, "Revocation", true);
- //this.ToolBarItemEnable(this, "Submittal", true);
- //this.ToolBarItemEnable(this, "doExcel", true);
- this.ToolBarItemEnable(this, "DoReceive", false);
- this.ToolBarItemEnable(this, "Process", false);
- ultraTabControl2.Tabs[1].Visible = false;
- txt_auditType.Visible = true;
- txt_auditType_lab.Visible = true;
- txt_itemAuditType_lab.Visible = true;
- txt_itemAuditType.Visible = true;
-
- }
- //加载流程类型
- DataTable dt8 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "122601" }, this.ob);
- comm.FilComboboxAdd(txt_auditType, dt8, "baseCode", "baseName", "validflag NOT in ('0')", false, "", "");
-
- //加载数据
- GetPUR_REQUIRE_PLAN();
- ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- ultraExpandableGroupBox2.Expanded = false;
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- }
- //初始化数据
- string init_itemUomId="";//物料单位换算ID
- string init_itemStandardsId = "";//采购标准ID
- string init_itemAttrId = "";//物料属性编码
- string init_auditFlag = "";//审批标识
- string init_itemUnique = "";//物料唯一码
- string deliveryLocationCode="";//地点编码
- string init_itemAutitTypeId = "";//物料审批流程ID
- string PRICE_TYPE = "";
- private string m_szCurPath = ""; //启动路径
- string strCoustomInfo = "";
- #region toolbar工具栏事件
- /// <summary>
- /// toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)//菜单toolbar按钮
- {
- switch (ToolbarKey)
- {
- case "Query":
- GetPUR_REQUIRE_PLAN();
- break;
- case "Add":
- AddPUR_REQUIRE_PLAN();
- break;
- case "Update":
- UpdPUR_REQUIRE_PLAN();
- break;
- case "Delete":
- DelPUR_REQUIRE_PLAN();
- break;
- case "Submittal":
- SubPUR_REQUIRE_PLAN();
- break;
- case "Revocation":
- RevPUR_REQUIRE_PLAN();
- break;
- case "DoReceive":
- ReceivePUR_REQUIRE_PLAN();
- break;
- case "Process":
- Process();
- break;
- case "doExcel":
- doExcel();
- break;
- }
- }
- /// <summary>
- /// 撤销提报
- /// </summary>
- private void RevPUR_REQUIRE_PLAN()//提报撤销
- {
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
- {
- MessageUtil.ShowTips("未发现可撤销的需求计划头!");
- return;
- }
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择可操作的需求计划头!");
- return;
- }
- String mrId = uge.Cells["MrId"].Value.ToString();
- if ( mrId == "")
- {
- MessageUtil.ShowTips("请选择可操作的需求计划头");
- return;
- }
- //头是否处于可撤回状态
- if (testReqMStatus(mrId, 3) == false)
- {
- return;
- }
- ArrayList list = new ArrayList();
- RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
- if (strCoustomInfo != "2")
- {
- if (ReqM.Status == "-1")
- {
- ReqM.Status = "-2";
- }
- else
- {
- ReqM.Status = "1";
- }
- }
- else//供应部直接撤回(直接有已审批3-》1)
- {
- ReqM.Status = "31";
- }
- ReqM.UpdateUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("确定撤回该需求计划头?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("撤回成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId);
- }
- /// <summary>
- /// 提报
- /// </summary>
- private void SubPUR_REQUIRE_PLAN()//提报需求
- {
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择需操作的需求计划头!");
- return;
- }
- String mrId = uge.Cells["MrId"].Value.ToString().Trim();
- if (mrId == "")
- {
- MessageUtil.ShowTips("请选择需操作的需求计划头!");
- return;
- }
- //验证是否可以提报
- if (testReqMStatus(mrId, 2) == false)
- {
- return;
- }
- RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
- if (strCoustomInfo != "2")
- {
- if (ReqM.Status == "-2")
- {
- ReqM.Status = "-1";//子计划提交
- }
- else
- {
- ReqM.Status = "2";//主计划提报
- }
- }
- else
- {
- ReqM.Status = "13";//供应部默认直接审批并接受(由1知道到3)
- }
- ReqM.UpdateUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("确定提报该需求计划头?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM});
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("提报成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- }
- else
- {
- UltraGridRow uge = ultraGrid3.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("未选择需提报的退回需求计划行!");
- return;
- }
- String strMrLineId = uge.Cells["MrLineId"].Value.ToString().Trim();
- if (strMrLineId=="")
- {
- MessageUtil.ShowWarning("未获取到该需求计划行的需求计划行号!");
- return;
- }
- if (testReqCStatus(strMrLineId, 2) == false)
- {
- return;
- }
- ArrayList list = new ArrayList();
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrLineId = strMrLineId;
- ReqD.FlagGeneratedPurPlan = "1";
- ReqD.UpdateName = UserInfo.GetUserName();
- ReqD.UpdateUserid = UserInfo.GetUserID();
- ReqD.UpdateTime = DateTime.Now;
- list.Add(ReqD);
- if (MessageUtil.ShowYesNoAndQuestion("确定重新提报?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = new CoreResult();
- if (strCoustomInfo == "2")
- {
- rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "32" });//供应部直接提报(3—>2)
- }
- else
- {
- rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "4" });//生成厂提报
- }
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("提报成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId);
- }
- }
- /// <summary>
- /// 删除需求
- /// </summary>
- private void DelPUR_REQUIRE_PLAN()//删除需求
- {
- //删除非退回需求
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择需要操作的需求计划头!");
- return;
- }
- String mrId=uge.Cells["MrId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(mrId))
- {
- MessageUtil.ShowTips("该需求计划头号为空!");
- return;
- }
- //删除头
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- //验证是否有权利删除头
- if (testReqMStatus(mrId,1) == false)
- {
- return;
- }
- ArrayList list = new ArrayList();
- RequirePlanM ReqM = new RequirePlanM();
- ReqM.MrId = mrId;
- ReqM.Validflag = "0";
- ReqM.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- ReqM.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- ReqM.DeleteTime = DateTime.Now;
- list.Add(ReqM);
- if (MessageUtil.ShowYesNoAndQuestion("确定删除该需求计划头?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doDelete_batch", new object[] { list, strCoustomInfo });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- GetPUR_REQUIRE_PLAN();
- }
- //删除行
- else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
- {
- UltraGridRow uRe = ultraGrid2.ActiveRow;
- if (uRe == null)
- {
- MessageUtil.ShowTips("请选择需删除的需求计划行!");
- return;
- }
- string strMrLineId = uRe.Cells["MrLineId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("未获取到该需求计划行号!");
- return;
- }
- //验证是否有权利删改行
- if (testReqCStatus(strMrLineId,1) == false)
- {
- return;
- }
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrLineId = strMrLineId;
- ReqD.Validflag = "0";
- ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- ReqD.DeleteTime = DateTime.Now;
- if (MessageUtil.ShowYesNoAndQuestion("是否确定删除该需求计划行?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate", new object[] { ReqD });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- String YY = mrId;
- RequirePlanD rpd1 = new RequirePlanD();
- rpd1.MrLineId = YY;
- rpd1.Validflag = "1";
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
- GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
- clearkongjian();
- }
- }
- //删除退回需求行
- else
- {
- UltraGridRow uRe = ultraGrid3.ActiveRow;
- if (uRe == null)
- {
- MessageUtil.ShowTips("请选择需作废的退回需求计划行!");
- return;
- }
- String strMrLineId = uRe.Cells["MrLineId"].Value.ToString();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("需求计划行号为空!");
- return;
- }
- //判断是否有权力修改
- if (testReqCStatus(strMrLineId, 2) == false)
- {
- return;
- }
- ArrayList list = new ArrayList();
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrLineId = strMrLineId;
- ReqD.FlagGeneratedPurPlan = "9";
- ReqD.UpdateName = UserInfo.GetUserName();
- ReqD.UpdateUserid = UserInfo.GetUserID();
- ReqD.UpdateTime = DateTime.Now;
- list.Add(ReqD);
- if (MessageUtil.ShowYesNoAndQuestion("确定作废该退回的需求计划行?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "5" });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功!");
- GetPUR_REQUIRE_PLAN();
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void UpdPUR_REQUIRE_PLAN()//更新需求
- {
- //修改非退回需求
- if (ultraTabControl2.SelectedTab.Text == ultraTabControl2.Tabs[0].Text)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String mrId = uge.Cells["mrId"].Value.ToString();
- if (uge == null || mrId=="")
- {
- MessageUtil.ShowTips("未选择需求订单");
- return;
- }
- ////判断是否处于可增删改的状态
- //if (!uge.Cells["Status"].Value.Equals("待编制") && !uge.Cells["Status"].Value.Equals("待提报") && !uge.Cells["Status"].Value.Equals("审批不通过"))
- //{
- // MessageUtil.ShowWarning("需求计划头【" + uge.Cells["MrId"].Value.ToString() + "】为已编制、审批中或已审批状态之一,无权限增删改,或请刷新后再操作!");
- // return;
- //}
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- //验证是否有权力修改头
- if (testReqMStatus(mrId, 4) == false)
- {
- return;
- }
- //验证输入的数据
- if (testReqM() == false)
- {
- return;
- }
- RequirePlanM ReqM = new RequirePlanM();
- ReqM.UpdateName = UserInfo.GetUserName();
- ReqM.UpdateUserid = UserInfo.GetUserID();
- ReqM.UpdateTime = DateTime.Now;
- ReqM.MrId = mrId;
- ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称
- ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID
- if (txt_MRPERIODEND.Enabled == false)
- {
- ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
- }
- else
- {
- ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value);
- }
- ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString().Trim().Trim();
- ReqM.RequireType = txt_RequeType.Value.ToString().Trim();
- ReqM.TenantId = strCoustomInfo != "2" ? txt_auditType.Value.ToString().Trim() : null;
- ReqM.TenantName = strCoustomInfo != "2" ? txt_auditType.Text.Trim() : null;
- if (MessageUtil.ShowYesNoAndQuestion("确定要修改该需求计划头?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("修改成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- clearkongjian1();
- }
- else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])//需求计划行修改
- {
- UltraGridRow uged = ultraGrid2.ActiveRow;
- if (uged == null)
- {
- MessageUtil.ShowWarning("未选择需求计划行");
- return;
- }
- String strMrLineId = uged.GetCellValue("MrLineId").ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId) || String.IsNullOrEmpty(mrId))
- {
- MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!");
- return;
- }
- //判断是否有权力进行操作行
- if (testReqCStatus(strMrLineId, 1) == false)
- {
- return;
- }
- if (uged.GetCellValue("itemCode") == null)
- {
- MessageUtil.ShowWarning("需求计划行物料编码为空物");
- return;
- }
- if (testReqC() == false)
- {
- return;
- }
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrId = mrId;
- ReqD.Validflag = "1";
- ReqD.ItemUnique = init_itemUnique;
- //2016年2月28新增leitao
- if (Ck_IsJIT.Checked)
- {
- ReqD.DeliveryLocationFlag = "1";
- ReqD.DeliveryLocation = txt_deliveryLocation.Text;
- ReqD.DeliveryLocationCode = deliveryLocationCode;
- if (ReqD.DeliveryLocationCode == "")
- {
- MessageUtil.ShowTips("JIT送货的地址信息不能为空");
- txt_deliveryLocation.Focus();
- return;
- }
- }
- else
- {
- ReqD.DeliveryLocationFlag = "0";
- ReqD.DeliveryLocation = "";
- ReqD.DeliveryLocationCode = "";
- }
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
- for(int ii=0;ii<dt2.Rows.Count;ii++)
- {
- if (dt2.Rows[ii]["mrLIneId"].ToString().Trim() != txt_MRLINEID.Text.ToString().Trim())
- {
- MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[ii]["MrLineId"].ToString() + "】");
- return;
- }
- }
- ReqD.MrLineId = txt_MRLINEID.Text.ToString().Trim();
- ReqD.ItemCode = txt_ItemCode.Text.ToString().Trim();
- ReqD.ItemName = txt_ItemName.Text.ToString().Trim();
- ReqD.Remark = txt_Remark.Text.ToString().Trim();
- ReqD.ItemAttr = txt_item_Attr.Text.ToString().Trim();//属性名称
- if (txt_BUGPRICE.Text != "")
- {
- ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text);
- }
- double dbItemUomConefficien;
- if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
- {
- MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空");
- return;
- }
- ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
- ReqD.WeightUnit = txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
- ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
- ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
- ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);//消耗预算
- ReqD.UpdateName = UserInfo.GetUserName();
- ReqD.UpdateUserid = UserInfo.GetUserID();
- ReqD.UpdateTime = DateTime.Now;
- ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
- ReqD.ItemStandardsId = init_itemStandardsId;
- ReqD.ItemUomId = init_itemUomId;
- ReqD.ItemAttrId = init_itemAttrId;
- ReqD.AuditFlag = "0";
- ReqD.DeleteUserid = UserInfo.GetDeptid();
- if (MessageUtil.ShowYesNoAndQuestion("确定修改该需求计划行?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败! " + rt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("修改成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- comm.doActiveSelRow(ultraGrid2, "MrLineId", ReqD.MrLineId);
- RequirePlanD rpd1 = new RequirePlanD();
- rpd1.MrLineId = mrId;
- rpd1.Validflag = "1";
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
- GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
- clearkongjian();
- }
- }
- //退回需求计划行修改
- else
- {
- UltraGridRow uged = ultraGrid3.ActiveRow;
- if (uged == null)
- {
- MessageUtil.ShowWarning("未选择退回需求计划行");
- return;
- }
- String strMrlineId = uged.GetCellValue("MrLineId").ToString().Trim();
- String strMrId = uged.GetCellValue("MrId").ToString().Trim();
- if(String.IsNullOrEmpty(strMrlineId)||String.IsNullOrEmpty(strMrId))
- {
- MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!");
- return;
- }
- //判断是否有权力修改
- //判断是否有权力进行操作行
- if (testReqCStatus(strMrlineId, 2) == false)
- {
- return;
- }
- if (testReqC() == false)
- {
- return;
- }
- if (uged.GetCellValue("itemCode") == null)
- {
- MessageUtil.ShowWarning("需求计划行物料编码为空物");
- return;
- }
- if (uged.GetCellValue("itemCode").ToString().Trim() != txt_ItemCode.Value.ToString().Trim())
- {
- MessageUtil.ShowWarning("退回物料不予许修改需求物料编码");
- return;
- }
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrId = strMrId;
- ReqD.Validflag = "1";
- ReqD.ItemUnique = init_itemUnique;
- //2016年2月28新增leitao
- if (Ck_IsJIT.Checked)
- {
- ReqD.DeliveryLocationFlag = "1";
- ReqD.DeliveryLocation = txt_deliveryLocation.Text;
- ReqD.DeliveryLocationCode = deliveryLocationCode;
- if (ReqD.DeliveryLocationCode == "")
- {
- MessageUtil.ShowTips("JIT送货的地址信息不能为空");
- txt_deliveryLocation.Focus();
- return;
- }
- }
- else
- {
- ReqD.DeliveryLocationFlag = "0";
- ReqD.DeliveryLocation = "";
- ReqD.DeliveryLocationCode = "";
- }
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
- for (int ii = 0; ii < dt2.Rows.Count; ii++)
- {
- if (dt2.Rows[ii]["mrLIneId"].ToString().Trim() != strMrlineId)
- {
- MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[ii]["MrLineId"].ToString() + "】");
- return;
- }
- }
- ReqD.MrLineId = strMrlineId;
- ReqD.ItemCode = txt_ItemCode.Text.Trim();
- ReqD.ItemName = txt_ItemName.Text.Trim();
- ReqD.Remark = txt_Remark.Text.Trim();
- ReqD.ItemAttr = txt_item_Attr.Text.Trim();//属性名称
- if (txt_BUGPRICE.Text.Trim() != "")
- {
- ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text.Trim());
- }
- double dbItemUomConefficien;
- if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
- {
- MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空!");
- return;
- }
- ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
- ReqD.WeightUnit = txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
- ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
- ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
- ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);
- ReqD.UpdateName = UserInfo.GetUserName();
- ReqD.UpdateUserid = UserInfo.GetUserID();
- ReqD.UpdateTime = DateTime.Now;
- ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
- ReqD.ItemStandardsId = init_itemStandardsId;
- ReqD.ItemUomId = init_itemUomId;
- ReqD.ItemAttrId = init_itemAttrId;
- ReqD.AuditFlag = "0";
- //this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "update", new object[] { ReqD });
- if (MessageUtil.ShowYesNoAndQuestion("确定修改该需求计划行(退回):" + strMrlineId + "?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId);
- clearkongjian();
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void AddPUR_REQUIRE_PLAN()//新增需求
- {
- //退回标签页不允许新增
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
- {
- MessageUtil.ShowTips("未发现可新增项");
- return;
- }
- UltraGridRow uge = ultraGrid1.ActiveRow;
- //需求头标签页可以新增
- try
- {
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])//新增头信息
- {
- if (testReqM() == false)
- {
- return;
- }
- RequirePlanM ReqM = new RequirePlanM();
- ReqM.CreateName = UserInfo.GetUserName();
- ReqM.CreateUserid = UserInfo.GetUserID();
- ReqM.CreateTime = DateTime.Now;
- if (txt_MRPERIODEND.Enabled == false)
- {
- ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
- }
- else
- {
- ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value);
- }
- ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString();
- ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称
- ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID
- ReqM.Validflag = "1";
- ReqM.RequireType = txt_RequeType.Value.ToString();
- ReqM.Status = "1";
- ReqM.TenantId = strCoustomInfo!="2"?txt_auditType.Value.ToString().Trim():null;
- ReqM.TenantName = strCoustomInfo!= "2" ? txt_auditType.Text.Trim() : null;
- if (ReqM.RequireType == "122104")
- {
- ReqM.Status = "-2";//子计划
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "insert_id", new object[] { ReqM, strCoustomInfo});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("新增头失败! " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功! 新增头:" + crt.Resultmsg);
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", crt.Resultmsg);
- clearkongjian1();
- }
- else if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)//新增需求行信息
- {
- String strMrId = uge.Cells["mrId"].Value.ToString();
- if (uge == null || strMrId == "")
- {
- MessageUtil.ShowTips("请选择可操作的需求计划头");
- }
- if (testReqC() == false)
- {
- return;
- }
- //判断是否有权力新增
- if (testReqMStatus(strMrId, 1) == false)
- {
- return;
- }
- //是否新增了相同的物料
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.MrId = strMrId;
- ReqD.Validflag = "1";
- ReqD.ItemUnique = init_itemUnique;
- //2016年2月28新增leitao
- if (Ck_IsJIT.Checked)
- {
- ReqD.DeliveryLocationFlag = "1";
- ReqD.DeliveryLocation = txt_deliveryLocation.Text;
- ReqD.DeliveryLocationCode = deliveryLocationCode;
- if (ReqD.DeliveryLocationCode == "")
- {
- MessageUtil.ShowTips("JIT送货的地址信息不能为空");
- txt_deliveryLocation.Focus();
- return;
- }
- }
- else
- {
- ReqD.DeliveryLocationFlag = "0";
- ReqD.DeliveryLocation = "";
- ReqD.DeliveryLocationCode = "";
- }
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
- if (dt2.Rows.Count>0)
- {
- MessageUtil.ShowWarning("已存在相同需求计划行【"+dt2.Rows[0]["MrLineId"].ToString() + "】");
- return;
- }
- ReqD.ItemCode = txt_ItemCode.Text;//物料编码
- ReqD.ItemName = txt_ItemName.Text.Trim();//物料名称
- ReqD.Remark = txt_Remark.Text;//备注
- ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text);//预算价
- ReqD.ItemAttr = txt_item_Attr.Text;//属性名称
- double dbItemUomConefficien;
- if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
- {
- MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空");
- return;
- }
- ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
- ReqD.WeightUnit =txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
- ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
- ReqD.Validflag = "1";
- ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
- ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);//消耗预算
- ReqD.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- ReqD.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- ReqD.CreateTime = DateTime.Now;
- ReqD.FlagGeneratedPurPlan = "1";//默认未接受
- ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
- ReqD.ItemStandardsId = init_itemStandardsId;
- ReqD.ItemUomId = init_itemUomId;
- ReqD.ItemAttrId = init_itemAttrId;
- ReqD.AuditFlag = "";
- ReqD.DeleteUserid = UserInfo.GetDeptid();//部门ID
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D", new object[] { ReqD });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("新增失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("新增行信息成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", strMrId);
- String YY = strMrId;
- RequirePlanD rpd1 = new RequirePlanD();
- rpd1.MrLineId = YY;
- rpd1.Validflag = "1";
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
- GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
- comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg);
- clearkongjian();
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("新增失败!" + e);
- return;
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- private void doExcel()// 导出Excel
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需导出明细的汇总需求计划!");
- return;
- }
- //获取导出的采购计划行表
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid2);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料明细");
- if (ultraGrid2.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "需求计划[" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "]明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("需求计划:" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "无可导出明细!");
- }
- }
- else
- {
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid3);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料明细");
- if (ultraGrid3.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "退回需求行明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("无可导出退回需求计划行明细!");
- }
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetPUR_REQUIRE_PLAN()//刷新
- {
- clearkongjian();
- clearkongjian1();
- dataTable1.Clear();
- dataTable2.Clear();
- dataTable3.Clear();
- try
- {
- this.Cursor = Cursors.WaitCursor;
- //string str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_M", "suppone_entity", new string[] { "txt_" }, true, txt_MRID.Parent);
- //str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_D", "suppone_entity", new string[] { "txt_" }, true, txt_MRLINEID.Parent);
- RequirePlanM RqPM = new RequirePlanM();
- RequirePlanD rpd = new RequirePlanD();
- if (txt_Status.Value != null)
- {
- RqPM.Status = txt_Status.Value.ToString();
- }
- if (ultraTextEditor1.Text != null)
- {
- RqPM.MrId = ultraTextEditor1.Text;
- rpd.MrId = ultraTextEditor1.Text;
- }
- if (cop_UrgencyType.Value != null)
- {
- RqPM.UrgencyType = cop_UrgencyType.Value.ToString();
- }
- if (ck_ctime.Checked==true)
- {
- if (txtCreateTimeStart.Text != "")
- {
- RqPM.MrPeriodStart = Convert.ToDateTime(txtCreateTimeStart.Value);
- rpd.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value);
- }
- if (txtCreateTimeEnd.Text != "")
- {
- RqPM.MrPeriodEnd = Convert.ToDateTime(txtCreateTimeEnd.Value);
- rpd.UpdateTime = Convert.ToDateTime(txtCreateTimeEnd.Value);
- }
- }
- //生成厂
- if (strCoustomInfo == "1")
- {
- RqPM.DeleteName = "1";
- rpd.DeleteName = "1";
- }
- //供应部
- else if (strCoustomInfo == "2")
- {
- RqPM.DeleteName = "0";
- rpd.DeleteName = "0";
- }
- else
- {
- RqPM.DeleteName = "3";
- rpd.DeleteName = "3";
- }
- //RqPM.Status = txt_Status.Value.ToString();
- //RqPM.MrId = ultraTextEditor1.Text;
- //RqPM.UrgencyType = ultraComboEditor2.Value.ToString();
- //RqPM.MrPeriodStart = Convert.ToDateTime(txtMrPeriodStart.Value);
- //RqPM.MrPeriodEnd = Convert.ToDateTime(txtMrPeriodEnd.Value);
- RqPM.Validflag = "1";
- RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds;
- RqPM.OperatorUserId = UserInfo.GetUserID();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
- foreach (DataRow row in dt.Rows)
- {
- row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
- }
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- //查询的退回需求信息
- rpd.Validflag = "1";
- rpd.FlagGeneratedPurPlan = "3";
- rpd.ValidDataPurviewIds = this.ValidDataPurviewIds;
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
- foreach (DataRow row in dt2.Rows)
- {
- row["itemDescE"] = Convert.ToDateTime(row["itemDescE"]).ToString("yyyy/MM");
- }
- GridHelper.CopyDataToDatatable(dt2, dataTable3, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载数据失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 需求计划接收准备汇总
- /// </summary>
- private void ReceivePUR_REQUIRE_PLAN()
- {
- string[] strViews=this.ValidDataPurviewIds;
- FrmPurRequirePlanReceive2 frm = new FrmPurRequirePlanReceive2(this.ob, strViews,strCoustomInfo);
- frm.ShowDialog();
- if (frm.tips == "1")
- {
- GetPUR_REQUIRE_PLAN();
- }
- }
- /// <summary>
- /// 查看流程详情
- /// </summary>
- private void Process()//查看流程详情
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowWarning("请选择一条记录");
- return;
- }
- string mrId = uge.Cells["mrId"].Value.ToString();
- ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId);
- detail.ShowDialog();
- }
- #endregion
- #region 界面事件
- /// <summary>
- /// 文件上传
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraButton1_Click(object sender, EventArgs e)//文件上传
- {
- m_szCurPath = "Image/pss/sale/order";
- // PlanFile.FlileUpload(m_szCurPath);
- }
- /// <summary>
- /// 文件查看
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTextEditor2_DoubleClick(object sender, EventArgs e)//文件查看
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.ShowDialog();
- //ultraTextEditor2.Value = ofd.FileName;
- //选择文件夹
- //FolderBrowserDialog fbd = new FolderBrowserDialog();
- //fbd.ShowDialog();
- //MessageBox.Show(fbd.SelectedPath);
- }
- /// <summary>
- /// 需求数量变化事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_QTY_ValueChanged(object sender, EventArgs e)//需求数量变化事件
- {
- if (!string.IsNullOrEmpty(txt_QTY.Value.ToString()))
- {
- double useBuget = Convert.ToDouble(txt_BUGPRICE.Value) * Convert.ToDouble(txt_QTY.Value) * Convert.ToDouble(txt_ItemUomConefficient.Value);
- txt_BUDGETAMT.Value = useBuget;
- if (!string.IsNullOrEmpty(txt_ItemUomConefficient.Text))
- {
- ultraTextEditor6.Value = Convert.ToDouble(txt_ItemUomConefficient.Value) * Convert.ToDouble(txt_QTY.Value);
- }
- double canUseBuget = Convert.ToDouble(txt_orgBudget.Value);
- if (useBuget > canUseBuget)
- {
- if (CK_isBugCtrl.Checked == true)
- {
- txt_tipsForBudget.Visible = true;
- txt_orgBudget.Appearance.ForeColor = Color.Red;
- }
- }
- else
- {
- txt_tipsForBudget.Visible = false;
- }
- }
- else
- {
- txt_BUDGETAMT.Text = "";
- ultraTextEditor6.Text = "";
- }
- }
- /// <summary>
- /// 要求交期验证
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证
- {
- if (txt_LastDeliveryDate.Text == "")
- {
- txt_tipsForDate.Text = "*无效交期";
- txt_tipsForDate.ForeColor = Color.Red;
- txt_tipsForDate.Visible = true;
- }
- else
- {
- DateTime inputDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- DateTime timeNow = DateTime.Now;
- if (inputDate <= timeNow)
- {
- txt_tipsForDate.Text = "*无效交期";
- txt_tipsForDate.ForeColor = Color.Red;
- txt_tipsForDate.Visible = true;
- }
- else
- {
- txt_tipsForDate.Visible = false;
- }
- }
- }
- /// <summary>
- /// 需求数量校验
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_QTY_KeyPress(object sender, KeyPressEventArgs e)//需求数量校验
- {
- if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
- {
- e.Handled = true;
- }
- }
- /// <summary>
- /// 切换Tab1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_Click(object sender, EventArgs e)//切换Tab0
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- }
-
- /// <summary>
- /// 切换Tab1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_Click(object sender, EventArgs e)//切换Tab1
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
- }
- /// <summary>
- /// 切换Tab0
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)//切换Tab0
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- clearkongjian1();
- clearkongjian();
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- return;
- txt_MRID.Text = uge.Cells["MRID"].Value.ToString();
- txt_MRPERIODEND.Value = uge.Cells["MRPERIODEND"].Value;//计划期间-结束
- txt_REQORGNAME.Text = UserInfo.GetDepartment();//申请者机构名称
- txt_URGENCYTYPE.Text = uge.Cells["URGENCYTYPE"].Value.ToString();//紧急程度类型
- txt_RequeType.Text = uge.Cells["REQUIRETYPE"].Value.ToString().Trim();//需求计划类型
- txt_auditType.Value = uge.Cells["tenantId"].Value.ToString().Trim();//审批流程计划类型
- String YY = uge.Cells["mrId"].Value.ToString();
- RequirePlanD rpd = new RequirePlanD();
- rpd.Validflag = "1";
- rpd.MrId = YY;
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
- GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- /// <summary>
- /// 切换Tab1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)//切换Tab1
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
- clearkongjian();
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String strMrLineId = uge.Cells["MRLINEID"].Value.ToString();
- RequirePlanD ppd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
- txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString();
- txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString();
- txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString();
- deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString();
- txt_MRLINEID.Text = strMrLineId;
- txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注
- txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码
- PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text });
- if (matclass1 != null)
- {
- init_itemAutitTypeId = matclass1.TenantId;
- txt_itemAuditType.Text = matclass1.TenantName;
- }
- txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称
- txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号
- txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称
- txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString();
- txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString();
- txt_QTY.Value = uge.Cells["QTY"].Value.ToString();
- txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString();
- //2016年2月28日新增字段leitao
- txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值
- txt_inStockQty.Text = "10000";//在库库存
- txt_pipeLineStock.Text = "100";//在途库存
- init_itemAttrId = ppd.ItemAttrId;//属性编码
- init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码
- init_itemUomId = ppd.ItemUomId;//单位换算编码
- init_auditFlag = ppd.AuditFlag;//审批标识
- if (ppd.DeliveryLocationFlag == "1")//JIT标识
- {
- Ck_IsJIT.Checked = true;
- }
- else
- {
- Ck_IsJIT.Checked = false;
- }
- init_itemUnique = ppd.ItemUnique;
- //加载是否定额控制
- getBugCtrl(uge.Cells["ItemCode"].Value.ToString(), "2");
- //剩余预算
- getBudget(strMrLineId);
- //加载可用库存数量
- getInStockQty(ppd.ItemUnique);
- //加载可用在途库存数量
- getPipeLineStock(ppd.ItemUnique);
- }
- /// <summary>
- /// 点击退回需求
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)// 点击退回需求
- {
- clearkongjian();
- UltraGridRow uge = ultraGrid3.ActiveRow;
- if (uge == null)
- return;
- String strMrLineId = uge.Cells["MRLINEID"].Value.ToString();
- RequirePlanD ppd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
- txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString();
- txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
- txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString();
- txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString();
- deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString();
- txt_MRLINEID.Text = strMrLineId;
- txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注
- txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码
- PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text });
- if (matclass1 != null)
- {
- init_itemAutitTypeId = matclass1.TenantId;
- txt_itemAuditType.Text = matclass1.TenantName;
- }
- txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称
- txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号
- txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称
- txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString();
- txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString();
- txt_QTY.Value = uge.Cells["QTY"].Value.ToString();
- txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString();
- //2016年2月28日新增字段leitao
- txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值
- txt_inStockQty.Text = "10000";//在库库存
- txt_pipeLineStock.Text = "100";//在途库存
- getBudget(strMrLineId);//剩余预算
- init_itemAttrId = ppd.ItemAttrId;//属性编码
- init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码
- init_itemUomId = ppd.ItemUomId;//单位换算编码
- init_auditFlag = ppd.AuditFlag;//审批标识
- if (ppd.DeliveryLocationFlag == "1")//JIT标识
- {
- Ck_IsJIT.Checked = true;
- }
- else
- {
- Ck_IsJIT.Checked = false;
- }
- init_itemUnique = ppd.ItemUnique;
- }
- private void ultraTextEditor5_MouseClick(object sender, MouseEventArgs e)
- {
- }
- /// <summary>
- /// 部门信息弹出事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox1_MouseClick(object sender, MouseEventArgs e)//部门信息弹出
- {
- frmdepartment fdt = new frmdepartment(ob);
- fdt.ShowDialog();
- if (fdt.BuyerUnitDesc == null)
- return;
- txt_REQORGNAME.Text = fdt.BuyerUnitDesc;
- }
- /// <summary>
- /// 需求列表和退回需求行切换
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)//需求列表和退回需求行切换
- {
- // 切换到需求列表
- if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
- {
- clearkongjian();
- ultraTabControl1.Tabs[0].Visible = true;
- txt_Status.Enabled = true;
- cop_UrgencyType.Enabled = true;
- ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- this.ToolBarItemEnable(this, "Add", true);
- this.ToolBarItemEnable(this, "Process", true);
- this.ToolBarItemEnable(this, "Revocation", true);
- txt_ItemName.Enabled = true;
- }
- //切换到退回需求计划
- if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
- {
- clearkongjian();
- ultraTabControl1.SelectedTab=ultraTabControl1.Tabs[1];
- ultraTabControl1.Tabs[0].Visible=false;
- txt_Status.Enabled = false;
- cop_UrgencyType.Enabled = false;
- this.ToolBarItemEnable(this, "Add", false);
- this.ToolBarItemEnable(this, "Process", false);
- this.ToolBarItemEnable(this, "Revocation", false);
- txt_ItemName.Enabled = false;
- }
- }
- /// <summary>
- /// 库存数量校验
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTextEditor6_KeyPress(object sender, KeyPressEventArgs e)//库存数量校验
- {
- if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
- {
- e.Handled = true;
- }
- }
- /// <summary>
- /// 物料弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_ItemName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//物料弹窗
- {
- FrmPurPlanMat mat = new FrmPurPlanMat(this.ob, init_itemUnique);
- mat.ShowDialog();
- if (mat.getItemCode() == null)
- return;
- txt_ItemCode.Value = mat.getItemCode().ToString();
- txt_ItemName.Value = mat.getItemName().ToString();
- txt_item_Attr.Text = mat.ItemAttr;//属性名称
- PRICE_TYPE = mat.getPriceType().ToString();
- txt_BUGPRICE.Value = mat.getBugPrice().ToString();
- //if (mat.getItemUseUom().ToString() == "是" || mat.getItemUseUom().ToString()=="1")
- //{
- txt_ItemUomConefficient.Text = mat.getItemUomConefficient().ToString().Trim();
- txt_WEIGHTUNIT.Text = mat.getWeightUnit().ToString();
- txt_WEIGHTUNIT1.Text = mat.getWeightUnit().ToString();
- txt_WEIGHTUNIT2.Text = mat.getWeightUnit().ToString();
- txt_ItemUom.Text = mat.UomName;
- txt_QTY.Value = 0;
- ultraTextEditor6.Text = "";
- txt_BUDGETAMT.Text = "";
- txt_Remark.Text = "";
- //2016年2月28新增leitao
- init_itemAttrId = mat.ItemAttrId;//属性编码
- init_itemStandardsId = mat.ItemStandardsId;//采购标准编码
- init_itemUomId = mat.ItemUomId;//单位换算编码
- init_auditFlag = "0";//审批标识
- init_itemUnique = mat.ItemUnique;
- txt_itemStandardsCode.Text = mat.StandardsCode;
- init_itemAutitTypeId = mat.TenantId;
- txt_itemAuditType.Text = mat.TenantName;
-
- //加载可用库存数量
- getInStockQty(mat.ItemUnique);
- //加载可用在途库存数量
- getPipeLineStock(mat.ItemUnique);
- //确定是否预算控制
- getBugCtrl(mat.getItemCode().Trim(), mat.IsBudgetCtrl);
- }
-
- /// <summary>
- /// 机构弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_REQORGNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//机构弹窗
- {
- frmdepartment fdt = new frmdepartment(ob);
- fdt.ShowDialog();
- if (fdt.BuyerUnitDesc == null)
- return;
- txt_REQORGNAME.Text = fdt.BuyerUnitDesc;
- }
- /// <summary>
- /// 交付地点弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_deliveryLocation_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 交付地点弹窗
- {
- frmPopActualSeat Dz = new frmPopActualSeat(this.ob,"1");
- //FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob);
- Dz.ShowDialog();
- if (Dz.DeliveryLocationCode == null)
- {
- return;
- }
- txt_deliveryLocation.Text = Dz.DeliveryLocation;
- deliveryLocationCode = Dz.DeliveryLocationCode;
- //txt_URGENCYTYPE.SelectAll();
- }
-
- /// <summary>
- /// 查询预算情况
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况
- {
- frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob);
- frm.ShowDialog();
- }
- /// <summary>
- /// 查询在库存库存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_inStockQty_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在库存库存
- {
- string TabShow = "0";//tab默认为在库库存
- if (String.IsNullOrEmpty(init_itemUnique))
- {
- MessageUtil.ShowTips("未选择物料!");
- return;
- }
- frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob,init_itemUnique,TabShow);
- frm.ShowDialog();
- }
- /// <summary>
- /// 查询在途库存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_pipeLineStock_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在途库存
- {
- string TabShow = "1";//tab默认为在途库存
- if (String.IsNullOrEmpty(init_itemUnique))
- {
- MessageUtil.ShowTips("未选择物料!");
- return;
- }
- frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob, init_itemUnique,TabShow);
- frm.ShowDialog();
- }
- /// <summary>
- /// 是否按照时间查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ck_ctime_CheckedChanged(object sender, EventArgs e)// 是否按照时间查询
- {
- if (ck_ctime.Checked == false)
- {
- txtCreateTimeEnd.Enabled = false;
- txtCreateTimeStart.Enabled = false;
- }
- else
- {
- txtCreateTimeEnd.Enabled = true;
- txtCreateTimeStart.Enabled = true;
- }
- }
- /// <summary>
- /// 紧急采购允许输入月份
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_URGENCYTYPE_ValueChanged(object sender, EventArgs e)// 紧急采购允许输入月份
- {
- if (txt_URGENCYTYPE.SelectedIndex == 1)
- {
- txt_MRPERIODEND.Enabled = true;
- }
- else
- {
- txt_MRPERIODEND.Enabled = false;
- txt_MRPERIODEND.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
- }
- }
- #endregion
- #region 公共方法
- /// <summary>
- /// 控件清空tab2
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void clearkongjian()//tab2控件值清空
- {
- txt_item_Attr.Text = "";
- txt_MRLINEID.Text = "";
- txt_Remark.Text = "";
- txt_ItemCode.Text = "";
- txt_ItemName.Text = "";
- txt_MRLINEID.Text = "";
- txt_BUGPRICE.Text = "";
- txt_BUDGETAMT.Text = "";
- txt_QTY.Value = 0;
- ultraTextEditor6.Text = "";
- txt_ItemUom.Text = "";
- txt_WEIGHTUNIT.Text = "";
- txt_WEIGHTUNIT1.Text = "";
- txt_WEIGHTUNIT2.Text = "";
- txt_ItemUomConefficient.Text = "";
- txt_inStockQty.Text = "-";
- txt_pipeLineStock.Text= "-";
- //2016.2.28新增leitao
-
- txt_inStockQty.Text = "";
- txt_itemStandardsCode.Text = "";
- txt_pipeLineStock.Text = "";
- CK_isBugCtrl.Checked = false;
- getBudget("");
- init_itemAttrId = "";//属性编码
- init_itemStandardsId = "";//采购标准编码
- init_itemUomId = "";//单位换算编码
- init_auditFlag = "";//审批标识
- //init_deliveryLocationFlag = "";//JIT标识
- init_itemUnique = "";
- init_itemAutitTypeId = "";
- txt_itemAuditType.Text = "";
- //Ck_IsJIT.Checked = false;
- //deliveryLocationCode = "";//地点编码
- txt_tipsForDate.Visible = false;
- txt_tipsForBudget.Visible = false;
- txt_orgBudget.Appearance.ForeColor = Color.Black;
- txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
- }
- /// <summary>
- /// 控件清空1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void clearkongjian1()//tab1控件值清空
- {
- txt_RequeType.SelectedIndex = 0;
- txt_MRID.Text = "";
- txt_URGENCYTYPE.SelectedIndex = 0;
- txt_auditType.SelectedIndex = 0;
- txt_MRPERIODEND.Enabled = false;
- txt_REQORGNAME.Text = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment();
- if (DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")))
- {
- txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM"));
- }
- else
- {
- txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
- }
- }
- /// <summary>
- /// 获取需求计划行编码
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public string getCodeId(string str)//获取需求计划行编码
- {
- String YY = ultraGrid1.ActiveRow.Cells["mrId"].Value.ToString();
- RequirePlanD rpd = new RequirePlanD();
- rpd.MrLineId = YY;
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
- string strChild = "";
- int intChild = dt1.Rows.Count;
- intChild++;
- strChild = intChild.ToString();
- while (strChild.Length < 3)
- {
- strChild = "0" + strChild;
- }
- return str + "-" + strChild;
- }
- /// <summary>
- /// JIT选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Ck_IsJIT_CheckedChanged(object sender, EventArgs e)// JIT选择事件
- {
- if (Ck_IsJIT.Checked)
- {
- txt_deliveryLocation.Enabled = true;
- }
- else
- {
- txt_deliveryLocation.Enabled = false;
- }
- }
- /// <summary>
- /// 剩余预算计算
- /// </summary>
- private void getBudget(String mrLIneId)//计算剩余预算
- {
- //计算预算
- String strorgId=UserInfo.GetDeptid();
- String stryear=DateTime.Now.Year.ToString();
- String strmouth = DateTime.Now.Month.ToString();
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, mrLIneId});
- if (re.Resultcode != 0)
- {
- txt_orgBudget.Value = 0;
- return;
- }
- else
- {
- txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg);
- }
-
- }
- /// <summary>
- /// 可用在途库存
- /// </summary>
- /// <param name="itemUniqueNew"></param>
- /// <param name="qty"></param>
- private void getPipeLineStock(String strItemUnique)//可用在途库存
- {
- if (String.IsNullOrEmpty(strItemUnique))
- {
- txt_pipeLineStock.Text = "-";
- return;
- }
- OrderC orderc = new OrderC();
- orderc.ItemUnique = strItemUnique;
- orderc.Validflag = "1";
- orderc.DeleteName = "1";//仅查询在途库存大于0的
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCService", "getPipeLineStockQty", new object[] { orderc });
- if (re.Resultcode != 0)
- {
- txt_pipeLineStock.Text = "-";
- return;
- }
- else
- {
- txt_pipeLineStock.Text = re.Resultmsg;
- }
- }
- /// <summary>
- /// 可用在途库存
- /// </summary>
- /// <param name="p"></param>
- private void getInStockQty(String strItemUnique)//可用在途库存
- {
- if (String.IsNullOrEmpty(strItemUnique))
- {
- txt_inStockQty.Text = "-";
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique });
- if (re.Resultcode != 0)
- {
- txt_inStockQty.Text = "-";
- return;
- }
- else
- {
- txt_inStockQty.Text = re.Resultmsg;
- }
- }
- /// <summary>
- /// 查询物料是否预算控制
- /// </summary>
- /// <param name="p1"></param>
- /// <param name="p2">是否预算控制1:控制,0不控制,2未知</param>
- private void getBugCtrl(string itemCode, string p2)
- {
- if (p2 == "0")
- {
- CK_isBugCtrl.Checked = false;
- }
- else if (p2 == "1")
- {
- CK_isBugCtrl.Checked = true;
- }
- else
- {
- if (String.IsNullOrEmpty(itemCode))
- {
- MessageUtil.ShowTips("物料编码为空,无法判断该物料是否为预算控制物料");
- return;
- }
- MatEntity mAT = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { itemCode });
- if (mAT == null)
- {
- MessageUtil.ShowTips("物料【" + itemCode + "】不存在,请确定");
- return;
- }
- if (mAT.IsBudgetCtrl == "1")
- {
- CK_isBugCtrl.Checked = true;
- }
- else
- {
- CK_isBugCtrl.Checked = false;
- }
- }
- }
- /// <summary>
- /// 需求行数据校验
- /// </summary>
- /// <returns></returns>
- private bool testReqC()// 需求行数据校验
- {
- if (txt_ItemCode.Text.ToString().Trim()=="")
- {
- MessageUtil.ShowWarning("物料编码不能为空!");
- return false;
- }
- if (txt_QTY.Value == null)
- {
- MessageUtil.ShowWarning("需求数量不能为空!");
- return false;
- }
- if (Convert.ToDouble(txt_QTY.Value) == 0)
- {
- MessageUtil.ShowWarning("需求数量不能为0");
- return false;
- }
- if (txt_tipsForBudget.Visible == true)
- {
- MessageUtil.ShowTips("超出预算,请确定,或请刷新页面再操作!");
- txt_QTY.Focus();
- return false;
- }
- if (txt_LastDeliveryDate.Text == "" || txt_tipsForDate.Visible == true)
- {
- MessageUtil.ShowTips("请输入有效的到货时间!");
- txt_LastDeliveryDate.Focus();
- return false;
- }
- if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0] && strCoustomInfo != "2")
- {
- string strtenantId = ultraGrid1.ActiveRow.GetCellValue("tenantId").ToString();
- if (strtenantId != init_itemAutitTypeId)
- {
- MessageUtil.ShowTips("该物料审批流程和需求计划头流程不一致!");
- txt_itemAuditType.Focus();
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 需求头信息校验
- /// </summary>
- /// <returns></returns>
- private bool testReqM()// 需求头信息校验
- {
- if (txt_MRPERIODEND.Text == "")
- {
- MessageUtil.ShowTips("计划月份不能为空!");
- txt_MRPERIODEND.Focus();
- return false;
- }
- if (txt_MRPERIODEND.Enabled==false&&(DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26"))))
- {
- if (MessageUtil.ShowYesNoAndQuestion("需求提报截止日期为每月25号,若提交将默认为下月需求计划。确定新增?") != DialogResult.Yes)
- {
- txt_MRPERIODEND.Focus();
- return false;
- }
- }
- if (txt_RequeType.Value == null)
- {
- MessageUtil.ShowTips("请选择需求计划类型!");
- txt_RequeType.Focus();
- return false;
- }
- if (txt_URGENCYTYPE.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择紧急程度类型!");
- txt_URGENCYTYPE.Focus();
- return false;
- }
- if (strCoustomInfo != "2")
- {
- if (txt_auditType.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择审批流程类型!");
- txt_auditType.Focus();
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 验证是否有权力操作行
- /// </summary>
- /// <param name="strMrLineId"></param>
- /// <param name="tips"></param>
- /// <returns></returns>
- private Boolean testReqCStatus(String strMrLineId, int tips)// 验证是否有权力操作行
- {
- RequirePlanD pd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
- if (pd.CreateUserid != UserInfo.GetUserID())
- {
- MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划行");
- return false;
- }
- //是否待提报是否有权力进行删改
- if (tips == 1)
- {
- //行计划为未接收和已退回下是才能修改和删除
- //if (!(pd.FlagGeneratedPurPlan == "1") && !(pd.FlagGeneratedPurPlan == "3"))
- //{
- // MessageUtil.ShowTips("行计划为“未接收”和“已退回”下才能删改,或请刷新再操作");
- // return;
- //}
- //验证是否有权力操作头
- if (testReqMStatus(pd.MrId, 1) == false)
- {
- return false;
- }
- if (!(pd.FlagGeneratedPurPlan == "1"))
- {
- MessageUtil.ShowTips("行计划为“未接收”下才能删改,或请刷新再操作");
- return false;
- }
- }
- //判断退回需求行是否可以提报和删改
- else if (tips == 2)
- {
- if (pd.FlagGeneratedPurPlan != "3")
- {
- MessageUtil.ShowTips("行计划为非“已退回”状态,无权限删改或提报,或请刷新再操作");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证行信息有效性");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证是否有权力操作头
- /// </summary>
- /// <param name="mrId"></param>
- /// <param name="tips"></param>
- /// <returns></returns>
- private Boolean testReqMStatus(String mrId, int tips)// 验证是否有权力操作头
- {
- if (strCoustomInfo != "1" && strCoustomInfo != "2" && strCoustomInfo != "3")
- {
- MessageUtil.ShowTips("界面CoustomInfo参数配置错误,1:生产厂,2:供应部,3:科室厂区");
- return false;
- }
- RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
- if (pm.CreateUserid != UserInfo.GetUserID())
- {
- MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划");
- return false;
- }
- //判断是否有权力进行增删改
- if (tips == 1)
- {
- //头是否处于可删该的状态
- if (pm.Status == "-1"||pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
- {
- MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
- return false;
- }
- }
- //判断是否有权力进行修改
- else if (tips == 4)
- {
- //头是否处于可删该的状态
- if (pm.Status == "-1" || pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
- {
- MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
- return false;
- }
- //判断是流程是否一致
- if (strCoustomInfo != "2")
- {
- String itemAutitTypeId = txt_auditType.Value.ToString().Trim();
- RequirePlanD testpd = new RequirePlanD();
- testpd.MrId = mrId;
- testpd.Validflag = "1";
- List<RequirePlanD> dtPd = this.execute<List<RequirePlanD>>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd, 0, 0 });
- if (dtPd.Count > 0)
- {
- foreach (RequirePlanD rpd in dtPd)
- {
- String strItemCode = rpd.ItemCode;
- PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { strItemCode });
- if (matclass1 != null)
- {
- if (matclass1.TenantId != itemAutitTypeId)
- {
- MessageUtil.ShowTips("和该需求头下物料:" + strItemCode + "的流程不一致,请确定!");
- txt_auditType.Focus();
- return false;
- }
- }
- }
- }
- }
- }
- //判断是否可以提报
- else if (tips == 2)
- {
- if (!(pm.Status == "1") && !(pm.Status == "4") && !(pm.Status == "-2"))
- {
- MessageUtil.ShowTips("需求计划头【" + mrId + "】只能在“待提交”、“待提报”和“审批不通过”状态下才有权限进行提报,或请刷新后再操作!");
- return false;
- }
- //判断是否有行信息
- RequirePlanD testpd =new RequirePlanD();
- testpd.MrId=mrId;
- testpd.Validflag="1";
- DataTable dtPd= this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd,0,0 });
- if (dtPd.Rows.Count<=0)
- {
- MessageUtil.ShowWarning("需求计划头【" + mrId + "】无需求计划行,请添加物料后再提报!");
- return false;
- }
- }
- //是否有权利撤回
- else if (tips == 3)
- {
- //头是否处于可撤回状态
- if (strCoustomInfo != "2")
- {
- if (!(pm.Status == "2") && !(pm.Status == "-1"))
- {
- MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
- return false;
- }
- }
- else
- {
- if (!(pm.Status == "3"))
- {
- MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
- return false;
- }
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证头表有效性");
- return false;
- }
- return true;
- }
- #endregion
- }
- }
|