| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- 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 com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Pur.configure;
- using Pur.Entity;
- using Pur.Entity.require_planEntiy;
- namespace Pur.require_plan
- {
- public partial class frmPurRequirePlanMAdd : FrmPmsBase
- {
- public string tips = "0";
- public string requirePlanMId = "";
- public string txt_REQORGID = "";
- private string strCustomInfo;
- private string mrId="";
- public frmPurRequirePlanMAdd()
- {
- InitializeComponent();
- }
- public frmPurRequirePlanMAdd(OpeBase OB,String customInfo)
- {
- this.ob = OB;
- this.strCustomInfo = customInfo;
- InitializeComponent();
- }
- public frmPurRequirePlanMAdd(OpeBase opeBase, string strCoustomInfo, string mrId)
- {
- // TODO: Complete member initialization
- this.ob = opeBase;
- this.strCustomInfo = strCoustomInfo;
- InitializeComponent();
- this.mrId = mrId;
- btn_add.Text = "复制&A";
- }
- private void frmPurRequirePlanMAdd_Load(object sender, EventArgs e)
- {
- Init();
- }
- private void Init()
- {
- //紧急程度类型
- txt_URGENCYTYPE.SelectedIndex = 0;
- //加载计划类型数据
- DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
- if (strCustomInfo == "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;
- }
- else if (strCustomInfo == "2")//供应部
- {
- comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", "");
- //ultraTabControl2.Tabs[1].Visible = false;
- txt_auditType.Visible = false;
- txt_auditType_lab.Visible = false;
- }
- else//厂区
- {
- comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122104')", false, "", "");
- txt_auditType.Visible = true;
- txt_auditType_lab.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, "", "");
- txt_RequeType.SelectedIndex = 0;
- txt_URGENCYTYPE.SelectedIndex = 0;
- txt_auditType.SelectedIndex = 0;
- txt_MRPERIODEND.Enabled = false;
- txt_REQORGNAME.Text = UserInfo.GetDepartment();
- txt_REQORGID = UserInfo.GetDeptid();
- if (strCustomInfo == "2")
- {
- if (DateTime.Now < DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM/01")))
- {
- 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"));
- }
- }
- else
- {
- 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="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"));
- }
- }
- //新增操作
- private void btn_add_Click(object sender, EventArgs e)
- {
- 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)
- {
- if (strCustomInfo == "2")
- {
- ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM/01")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
- }
- else
- {
- 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 = txt_REQORGNAME.Text.Trim();//申请者机构名称
- ReqM.ReqOrgId = txt_REQORGID;//申请者机构ID
- ReqM.ApplyReqOrgName = UserInfo.GetDepartment();
- ReqM.ApplyReqOrgId = UserInfo.GetDeptid();
- ReqM.Validflag = "1";
- ReqM.RequireType = txt_RequeType.Value.ToString();
- ReqM.Status = "1";
- ReqM.TenantId = strCustomInfo != "2" ? txt_auditType.Value.ToString().Trim() : null;
- ReqM.TenantName = strCustomInfo != "2" ? txt_auditType.Text.Trim() : null;
- if (ReqM.RequireType == "122104")
- {
- ReqM.Status = "-2";//子计划
- }
- CoreResult crt = new CoreResult();
- if (!String.IsNullOrEmpty(mrId))
- {
- ReqM.MrId = mrId;
- crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "do_Copy", new object[] { ReqM, strCustomInfo });
- }
- else
- {
- crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "insert_id", new object[] { ReqM, strCustomInfo });
- }
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败! " + crt.Resultmsg);
- tips = "0";
- return;
- }
- else
- {
- MessageUtil.ShowTips("操作成功! 新增需求计划头:" + crt.Resultmsg);
- requirePlanMId = crt.Resultmsg;
- tips = "1";
- this.Close();
- }
- }
- /// <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 (String.IsNullOrEmpty(txt_REQORGID))
- {
- MessageUtil.ShowTips("请选择使用单位!");
- txt_REQORGNAME.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_REQORGNAME.Text.Trim()))
- {
- MessageUtil.ShowTips("请选择使用单位!");
- txt_REQORGNAME.Focus();
- return false;
- }
- if (strCustomInfo != "2")
- {
- if (txt_auditType.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择审批流程类型!");
- txt_auditType.Focus();
- return false;
- }
- }
- else
- {
- if (txt_REQORGID.Length >= 9)
- {
- if (txt_REQORGID.Substring(0, 9) == "002001029")
- {
- MessageUtil.ShowTips("替生产厂提报的需求计划不能选【供应部】和下面的科室作为申请单位!");
- txt_REQORGNAME.Focus();
- return false;
- }
- }
- }
- return true;
- }
- private void txt_REQORGNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- frmdepartment frm = new frmdepartment(this.ob);
- //frm.StartPosition = FormStartPosition.Manual;
- //frm.Location = publicPms.getShowLocation(frm);
- frm.ShowDialog();
- String strdeptId = frm.BuyerUnitCode;
- String strDeptName = frm.Fulltext;
- if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName))
- {
- txt_REQORGID = strdeptId;
- txt_REQORGNAME.Text = strDeptName;
- }
- }
- }
- }
|