| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409 |
- 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 FrmPurRequirePlan : FrmPmsBase
- {
- //初始化数据
- string deliveryLocationCode = "";//地点编码
- string strCoustomInfo = "";
- public FrmPurRequirePlan()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- private void FrmPurRequirePlan_Load(object sender, EventArgs e)//Load
- {
- txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
- strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString();
- //初始化1查询区域信息
- ck_ctime.Checked = false;
- txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2);
- txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
- txtCreateTimeStart.Enabled = false;
- txtCreateTimeEnd.Enabled = false;
- ck_Mtime.Checked = true;
- cop_planMouthStart.Value = DateTime.Now.AddMonths(-1);
- cop_planMouthEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(1): DateTime.Now.AddMonths(2);
- cop_UrgencyType.SelectedIndex = 0;
- ck_isAlldepart.Checked=true;
- //加载计划类型数据
- DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
- if (strCoustomInfo == "1")//生产厂
- {
- txt_Status.SelectedIndex = 4;
- }
- else if (strCoustomInfo == "2")//供应部
- {
- this.ToolBarItemEnable(this, "DoReceive", false);
- this.ToolBarItemEnable(this, "Process", false);
- txt_Status.SelectedIndex = 4;
- }
- else//厂区
- {
- this.ToolBarItemEnable(this, "DoReceive", false);
- this.ToolBarItemEnable(this, "Process", false);
- txt_Status.SelectedIndex = 1;
- }
- //初始化2:GRID
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "CHK", "qty","remark"});
- //初始化3:行编辑区
- txt_tipsForBudget.Visible = false;
- txt_tipsForDeliveryTime.Visible = false;
- Ck_IsJIT.Checked = true;
- //txt_deliveryLocation.Enabled = false;
- }
- #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 "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;
- case "doCopy":
- doCopy();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetPUR_REQUIRE_PLAN()//刷新
- {
- dataTable1.Clear();
- dataTable2.Clear();
- message.Clear();
- clearkongjian();
- try
- {
- this.Cursor = Cursors.WaitCursor;
- RequirePlanM RqPM = new RequirePlanM();
- if (txt_Status.Value != null)
- {
- RqPM.Status = txt_Status.Value.ToString();
- }
- if (ultraTextEditor1.Text != null)
- {
- RqPM.MrId = ultraTextEditor1.Text;
- }
- if (cop_UrgencyType.Value != null)
- {
- RqPM.UrgencyType = cop_UrgencyType.Value.ToString();
- }
- if (ck_ctime.Checked == true)
- {
- if (txtCreateTimeStart.Text != "")
- {
- RqPM.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value);
- }
- if (txtCreateTimeEnd.Text != "")
- {
- RqPM.DeleteTime = Convert.ToDateTime(txtCreateTimeEnd.Value);
- }
- }
- //计划时间
- if (ck_Mtime.Checked == true)
- {
- if (cop_planMouthStart.Text != "")
- {
- DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM"));
- RqPM.MrPeriodStart = Start1;
- }
- if (cop_planMouthEnd.Text != "")
- {
- DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM"));
- RqPM.MrPeriodEnd = End1;
- }
- }
- //生成厂
- if (strCoustomInfo == "1")
- {
- RqPM.DeleteName = "1";
- }
- //供应部
- else if (strCoustomInfo == "2")
- {
- RqPM.DeleteName = "0";
- }
- else
- {
- RqPM.DeleteName = "3";
- }
- RqPM.Validflag = "1";
- RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds;
- RqPM.OperatorUserId = UserInfo.GetUserID();
- RqPM.BpmUserId = UserInfo.GetUserID();
- string strDataFlag = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.require_plan.FrmPurRequirePlan" });
- if (strDataFlag == "0")//没有数据权限
- {
- if (ck_isAlldepart.Checked)
- {
- RqPM.CreateUserid = this.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);
- //查询可用定额
- //getBudget();
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载数据失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 撤销提报
- /// </summary>
- private void RevPUR_REQUIRE_PLAN()//提报撤销
- {
- 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,strCoustomInfo});
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("撤回成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId);
- }
-
- /// <summary>
- /// 复制需求行
- /// </summary>
- private void doCopy()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择可操作的需求计划头!");
- return;
- }
- String mrId = uge.Cells["MrId"].Value.ToString();
- if (mrId == "")
- {
- MessageUtil.ShowTips("请选择可操作的需求计划头");
- return;
- }
- try
- {
- frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo, mrId);
- frm.Text = "复制需求计划[" + mrId + "]";
- frm.ShowDialog();
- if (frm.tips == "1")
- {
- string StrMrId = frm.requirePlanMId;
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId);
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("复制失败!" + e);
- return;
- }
-
- }
- /// <summary>
- /// 提报
- /// </summary>
- private void SubPUR_REQUIRE_PLAN()//提报需求
- {
- 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,strCoustomInfo});
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("提报成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- }
- /// <summary>
- /// 删除需求
- /// </summary>
- private void DelPUR_REQUIRE_PLAN()//删除需求
- {
- 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 (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", "doDeleteM_batch", new object[] { list, strCoustomInfo });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- GetPUR_REQUIRE_PLAN();
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void AddPUR_REQUIRE_PLAN()//新增需求
- {
- try
- {
- frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo);
- frm.ShowDialog();
- if(frm.tips=="1")
- {
- string StrMrId =frm.requirePlanMId;
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId);
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("新增失败!" + e);
- return;
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- private void doExcel()// 导出Excel
- {
- try
- {
- this.Cursor = Cursors.Default;
- 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") + "无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- 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();
- //if (testReqMStatus(mrId, 6) == false)
- //{
- // return;
- //}
- 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 txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证
- {
- if (txt_LastDeliveryDate.Text == "")
- {
- txt_tipsForDeliveryTime.Visible = true;
- }
- else
- {
- if (Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10))
- {
- txt_tipsForDeliveryTime.Visible = true;
- }
- else
- {
- txt_tipsForDeliveryTime.Visible = false;
- }
- }
- }
- /// <summary>
- /// 查询预算情况
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况
- {
- DateTime dt = new DateTime();
- String orgId = "";
- if (ultraGrid1.ActiveRow == null)
- {
- dt = DateTime.Now.AddMonths(1);
- orgId = UserInfo.GetDeptid();
- }
- else
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String YY = uge.Cells["mrId"].Value.ToString();
- if (String.IsNullOrEmpty(YY))
- {
- return;
- }
- RequirePlanM pd = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY });
- dt=(DateTime)pd.MrPeriodEnd;
- orgId = pd.ReqOrgId;
- }
- frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob, dt, orgId);
- 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默认为在库库存
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String init_itemUnique = uge.Cells["itemUnique"].Value.ToString();
- 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)//查询在途库存
- {
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["status"].Value.ToString().StartsWith("审批不通过"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已退回") || e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已删除"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- /// <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 ck_Mtime_CheckedChanged(object sender, EventArgs e)
- {
- cop_planMouthStart.Enabled = ck_Mtime.Checked;
- cop_planMouthEnd.Enabled = ck_Mtime.Checked;
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- dataTable2.Clear();
- message.Clear();
- clearkongjian();
- if (ultraGrid1.ActiveRow == null)
- {
- return;
- }
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String YY = uge.Cells["mrId"].Value.ToString();
- if (String.IsNullOrEmpty(YY))
- {
- return;
- }
- RequirePlanM pd = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY });
- getBudget((DateTime)pd.MrPeriodEnd, pd.ReqOrgId);
- 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);
- foreach (UltraGridRow ugr in ultraGrid2.Rows)
- {
- if (!String.IsNullOrEmpty(ugr.Cells["refuseReason"].Value.ToString().Trim()))
- {
- ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0);
- }
- else
- {
- //ugr.CellAppearance.ForeColor = Color.Black;
- }
- }
- GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"], ultraGrid2.DisplayLayout.Bands[0].Columns["remark"] });
- //加载评审意见
- getOrderReview(YY);
-
- }
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- 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 });
- //加载可用库存数量
- getInStockQty(ppd.ItemUnique);
- }
- #endregion
- #region 行按钮
- /// <summary>
- ///删除需求行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_delete_Click(object sender, EventArgs e)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择需要操作的需求计划头!");
- return;
- }
- String mrId = uge.Cells["MrId"].Value.ToString().Trim();
- //验证头状态
- if (testReqMStatus(mrId, 1) == false)
- {
- return;
- }
- if (String.IsNullOrEmpty(mrId))
- {
- MessageUtil.ShowTips("该需求计划头号为空!");
- return;
- }
- ultraGrid2.UpdateData();
- List<RequirePlanD> list = new List<RequirePlanD>();
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
- {
- string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("未获取第"+row.Index+"个的需求计划行号!");
- return;
- }
- //验证是否有权利删改行
- if (testReqCStatus(strMrLineId, 1) == false)
- {
- return;
- }
- RequirePlanD ReqD = new RequirePlanD();
- //ReqD.MrId = mrId;
- ReqD.MrLineId = strMrLineId;
- ReqD.Validflag = "0";
- ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- ReqD.DeleteTime = DateTime.Now;
- list.Add(ReqD);
- }
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未选择需求计划行");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定删除需求计划行?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doDelete_batch", new object[] { list});
- 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);
- }
- /// <summary>
- /// 保存需求行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_doSave_Click(object sender, EventArgs e)
- {
- if (testReqC() == false)
- {
- return;
- }
- 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;
- }
- List<RequirePlanD> list = new List<RequirePlanD>();
- ultraGrid2.UpdateData();
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
- {
- RequirePlanD ReqD = new RequirePlanD();
- string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
- string strmatCode = row.Cells["itemCode"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!");
- return;
- }
- if (String.IsNullOrEmpty(strmatCode))
- {
- MessageUtil.ShowTips("未获取第" + row.Index + "个的物料编码!");
- return;
- }
- //验证是否有权利删改行
- if (testReqCStatus(strMrLineId, 1) == false)
- {
- return;
- }
- //校验数据
- double qty = Convert.ToDouble(row.GetCellValue("qty"));
- ReqD.DeliveryLocationFlag = Ck_IsJIT.Checked ? "1" : "0";
- ReqD.DeliveryLocation = txt_deliveryLocation.Text;
- ReqD.DeliveryLocationCode = deliveryLocationCode;
- if (ReqD.DeliveryLocationCode == "")
- {
- MessageUtil.ShowTips("送货的地址信息不能为空");
- txt_deliveryLocation.Focus();
- return;
- }
- ReqD.Remark = row.GetCellValue("remark") == null ? "" : row.GetCellValue("remark").ToString().Trim();
- ReqD.ItemCode = strmatCode;
- ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- ReqD.Qty = qty;
- ReqD.MrLineId = strMrLineId;
- ReqD.Validflag = "1";
- ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid();
- ReqD.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- ReqD.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- ReqD.UpdateTime = DateTime.Now;
- list.Add(ReqD);
- }
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未选择需求计划行");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定修改上述需求计划行?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_batch", new object[] { list });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
- 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);
- }
- //批量新增物料
- private void btn_addItem_Click(object sender, EventArgs e)
- {
- //校验行数据
- if (testReqC() == false)
- {
- return;
- }
- List<RequirePlanD> list = new List<RequirePlanD>();
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需求计划头进行物料添加");
- return;
- }
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String mrId = uge.Cells["mrId"].Value.ToString();
- //验证头状态
- if (testReqMStatus(mrId, 1) == false)
- {
- return;
- }
- RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
- String strtenantId = pm.TenantId;
- FrmPurPlanMatNew mat = new FrmPurPlanMatNew(this.ob);
- mat.ShowDialog();
- if (mat.list==null||mat.list.Count <= 0)
- {
- return;
- }
- foreach (RequirePlanD pd in mat.list)
- {
- if (strtenantId != pd.DeleteUserid&&strCoustomInfo!="2")
- {
- if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + " 审批流程:" + pd.DeleteName + "和需求头审批流程:" + pm.TenantName + "不一致,是否忽略该物料继续?") != DialogResult.Yes)
- {
- return;
- }
- else
- {
- continue;
- }
- }
- pd.MrId = mrId;
- pd.DeliveryLocationFlag = Ck_IsJIT.Checked?"1":"0";
- pd.DeliveryLocation = txt_deliveryLocation.Text;
- pd.DeliveryLocationCode = deliveryLocationCode;
- if (pd.DeliveryLocationCode == "")
- {
- MessageUtil.ShowTips("送货的地址信息不能为空");
- txt_deliveryLocation.Focus();
- return;
- }
- pd.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
- RequirePlanD ReqD = new RequirePlanD();
- ReqD.ItemUnique = pd.ItemUnique;
- ReqD.DeliveryLocationFlag = pd.DeliveryLocationFlag;
- ReqD.DeliveryLocationCode = pd.DeliveryLocationCode;
- ReqD.MrId = mrId;
- 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;
- }
- if (pd.Qty == null || Convert.ToDouble(pd.Qty)<=0)
- {
- if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未填写需求量,是否忽略该物料继续添加?") != DialogResult.Yes)
- {
- return;
- }
- else {
- continue;
- }
- }
- pd.BudgetAmt = pd.BugPrice * pd.Qty*pd.ItemUomConefficient;
- pd.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- pd.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- pd.CreateTime = DateTime.Now;
- pd.Validflag = "1";
- pd.FlagGeneratedPurPlan = "1";//默认未接受
- pd.AuditFlag = "";
- pd.DeleteUserid = UserInfo.GetDeptid();//部门ID
- if (String.IsNullOrEmpty(pd.ItemUom) || String.IsNullOrEmpty(pd.ItemUnique) || String.IsNullOrEmpty(pd.ItemUomId))
- {
- if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未获取到采购单位,是否忽略该物料继续添加?") != DialogResult.Yes)
- {
- return;
- }
- else
- {
- continue;
- }
- }
- list.Add(pd);
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未发现可新增物料");
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D_batch", new object[] { list });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("新增行失败!" + rt.Resultmsg);
- return;
- }
- 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);
- comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg);
- clearkongjian();
- }
- /// <summary>
- /// 退回需求行重新提报
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_back_re_Click(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow == null)
- {
- return;
- }
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String YY = uge.Cells["mrId"].Value.ToString();
- if (String.IsNullOrEmpty(YY))
- {
- return;
- }
- List<RequirePlanD> list = new List<RequirePlanD>();
- ultraGrid2.UpdateData();
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
- {
- RequirePlanD ReqD = new RequirePlanD();
- string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!");
- return;
- }
- //验证是否有权利删改行
- if (testReqCStatus(strMrLineId, 2) == false)
- {
- return;
- }
- ReqD.MrLineId = strMrLineId;
- ReqD.FlagGeneratedPurPlan = "2";
- list.Add(ReqD);
- }
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未选择需求计划行");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定直接提报上述需求计划行?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doBack_batch", new object[] { list });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!");
- GetPUR_REQUIRE_PLAN();
- comm.doActiveSelRow(ultraGrid1, "MrId", YY);
- 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);
- }
- #endregion
- #region 行编辑区控制
- /// <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;
- //}
- txt_deliveryLocation.Clear();
- }
- //编辑区地址选择
- private void txt_deliveryLocation_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- String strd = Ck_IsJIT.Checked?"1":"0";//是否全部地址
- String str2 =Ck_IsJIT.Checked? "1":"0";//是否为JIT地址
- if (strCoustomInfo == "2")
- {
- strd = "0";
- }
- FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob, strd, str2);
- Dz.ShowDialog();
- if (Dz.tips != "1")
- {
- return;
- }
- txt_deliveryLocation.Text = Dz.DeliveryLocation;
- deliveryLocationCode = Dz.DeliveryLocationCode;
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 需求行数据校验
- /// </summary>
- /// <returns></returns>
- private bool testReqC()// 需求行数据校验
- {
- //if (UserInfo.GetUserID() != "tianf")
- //{
- // if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0)
- // {
- // MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!");
- // txt_orgBudget.Focus();
- // return false;
- // }
- //}
- if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0)
- {
- MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!");
- txt_orgBudget.Focus();
- return false;
- }
- if (txt_LastDeliveryDate.Text == "" || txt_tipsForDeliveryTime.Visible == true || Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10))
- {
- MessageUtil.ShowTips("请输入有效的到货时间,并保证交货周期10天以上!");
- txt_LastDeliveryDate.Focus();
- return false;
- }
- if (deliveryLocationCode == ""||txt_deliveryLocation.Text.Trim()=="")
- {
- MessageUtil.ShowTips("请选择若JIT物料请选择JIT交付地址,非JIT物料请选择非JIT交付地址(若无可用交付地址,请联系供应部维护)");
- txt_deliveryLocation.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 控件清空tab2
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void clearkongjian()//tab2控件值清空
- {
- txt_inStockQty.Text = "";
- txt_tipsForDeliveryTime.Visible = false;
- txt_tipsForBudget.Visible = false;
- //txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
- }
- /// <summary>
- /// 获取评审意见
- /// </summary>
- /// <param name="strOrderId"></param>
- private void getOrderReview(string strOrderId)
- {
- DataTable dt11 = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderMService", "getReviewMsg", new object[] { strOrderId });
- GridHelper.CopyDataToDatatable(dt11, dataTable7, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- #endregion
- #region 公共方法
- /// <summary>
- /// 剩余预算计算
- /// </summary>
- private void getBudget(DateTime dt, string orgId)//计算剩余预算
- {
- //计算预算
- String strorgId = orgId;
- String stryear = dt.Year.ToString();
- String strmouth = dt.Month.ToString();
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, "" });
- if (re.Resultcode != 0)
- {
- txt_orgBudget.Value = null;
- return;
- }
- else
- {
- txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg);
- }
- }
- /// <summary>
- /// 可用在途库存
- /// </summary>
- /// <param name="p"></param>
- private void getInStockQty(String strItemUnique)//可用在途库存
- {
- if (String.IsNullOrEmpty(strItemUnique))
- {
- txt_inStockQty.Value = null;
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique });
- if (re.Resultcode != 0)
- {
- txt_inStockQty.Value = null;
- return;
- }
- else
- {
- txt_inStockQty.Value = Convert.ToDouble(re.Resultmsg);
- }
- }
- /// <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 (pd.FlagGeneratedPurPlan != "3")
- {
- 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;
- }
- if (pd.IsAllowReturn != "1")
- {
- 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 = pm.TenantId;
- 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 + "的审批流程流程:" + matclass1.TenantName + "和需求计划头的审批流程:" + pm.TenantName + "不一致,请确定!");
- 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 if (tips == 6)
- {
- //头是否处于查看流程
- if (strCoustomInfo == "1")
- {
- if (pm.Status != "2" && pm.Status != "3" && pm.Status != "4")
- {
- MessageUtil.ShowTips("请先提报需求计划【" + mrId + "】!");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("无流程信息");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证头表有效性");
- return false;
- }
- return true;
- }
- #endregion
- }
- }
|