From abe0a716aba51906d52e36f17ff02a340dc49937 Mon Sep 17 00:00:00 2001 From: zzr99 <1940172413@qq.com> Date: 星期二, 19 四月 2022 10:32:16 +0800 Subject: [PATCH] 标准工时+标准工时导入 --- PlanM/数据导入/Gy_StdWorkTimes_RoutingBill.cs | 322 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 318 insertions(+), 4 deletions(-) diff --git "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs" "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs" index 40db531..34ac451 100644 --- "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs" +++ "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs" @@ -1,19 +1,333 @@ -锘縰sing System; +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 Pub_Class; +using SQLHelper; -namespace PlanM.鏁版嵁瀵煎叆 +namespace PlanM { - public partial class Gy_StdWorkTimes_RoutingBill : Form + public partial class Gy_StdWorkTimes_RoutingBill : BLL.Gy_DataInTmp { public Gy_StdWorkTimes_RoutingBill() { InitializeComponent(); } + public int HItemID =0; + public int HMaker = 0; //制单人 + public int HMakeDate = 0; //制单日期 + public int HChecker = 0; //审核人 + public int HCheckDate = 0; //审核日期 + public int HStopflag = 0; + public int HRemark = 0; + public int HUSEORGName = 0; //组织ID + public int HProcName = 0; // + public int HMaterName = 0; //物料ID + public int HProcNum = 0; // + public int HMaterNum = 0; //物料ID + public int HStdWorkTimes = 0; //标准工时 + public int HUpperlimit = 0; //上限比例 + public int HLowerlimit = 0; //下限比例 + + //public int HMaterNumberCol = 0; //产品代码 + //public int HWorkTypeNameCol = 0; //工种 + //public int HProcNameCol = 0; //工序 + //public int HWorkCenterNameCol = 0; //工作中心 + //public int HProcMulNameCol = 0; //工段 + //public int HWorkCenterName_SCol = 0; //产线 + //public int HWorkQtyCol = 0; //产能 + //public int HSubStdEmpQtyCol = 0; //人数 + //public int HWorkQty_SCol = 0; //产线产能 + //public int HSubStdEmpQty_SCol = 0; //产线人数 + + //public int HMouldNoCol = 0; //模具编号 + //public int HChangeMouldCol = 0; //换模时间 + //public int HPackStdCol = 0; //周转箱标准 + //public int HPackCol = 0; //周转箱 + //public int HPutAreaCol = 0; //暂放区 + //// + //public int HMyWorkDaysCol = 0; //生产周期 + //public int HMyFixWorkDaysCol = 0; //固定生产天数 + + //public int HBeginDayQtyCol = 6; //开工固天 + //public int HBeginFixQtyCol = 7; //开工余量 + //public int HFixPriceCol = 8; //定额 小时工资 + //public int HProcPriceCol = 9; //工价 + //public int HProcTypeCol = 0; //工序类型 + // + public const int HBeginRow = 2; //有效数据,开始行数 + // + //DAL.ClsGy_RoutingBill; + public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View(); + public DAL.ClsGy_StdWorkTimes_Ctl BillNew = new DAL.ClsGy_StdWorkTimes_Ctl(); + DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View(); + //DAL.ClsGy_WorkType_View oWorkType = new DAL.ClsGy_WorkType_View(); + long j = -1; + int c = 0; + + public override bool OpenExcelData() + { + base.sSheetName = txtHSheetName.Text; + return base.OpenExcelData(); + } + + /// <summary> + /// 初始化界面 + /// </summary> + public override void initData() + { + base.initData(); + base.sSheetName = txtHSheetName.Text ; + base.ModRightName = "Gy_StdWorkTimes_RoutingBill"; + base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck; + base.ModRightNameClose = base.ModRightName + base.ModRightNameClose; + base.ModRightNameDelete = base.ModRightName + base.ModRightNameDelete; + base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit; + base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney; + base.ModRightNameQty = base.ModRightName + base.ModRightNameQty; + base.ModCaption = "标准工时导入"; + this.Text = base.ModCaption; + lblCaption.Text = base.ModCaption; + // + DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear); + DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod); + // + } + //导入 + public override void Sub_DataIn() + { + string hnumber = ""; + // + HStdWorkTimes = DBUtility.Gy_BaseFun.Fun_GetCol("标准工时", grdMain); + HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain); + HProcName = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain); + HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("物料代码", grdMain); + HMaterName = DBUtility.Gy_BaseFun.Fun_GetCol("物料", grdMain); + HUpperlimit = DBUtility.Gy_BaseFun.Fun_GetCol("上线比例", grdMain); + HLowerlimit = DBUtility.Gy_BaseFun.Fun_GetCol("下线比例", grdMain); + HUSEORGName = DBUtility.Gy_BaseFun.Fun_GetCol("组织", grdMain); + HMaker = DBUtility.Gy_BaseFun.Fun_GetCol("制单人", grdMain); + HMakeDate = DBUtility.Gy_BaseFun.Fun_GetCol("制单日期", grdMain); + + //没有找到列 + if (HStdWorkTimes == -1) + { + MessageBox.Show("没有找到【标准工时】的标题", "提示"); + return; + } + if (HProcName == -1) + { + MessageBox.Show("没有找到【工序】的标题", "提示"); + return; + } + if (HMaterName == -1) + { + MessageBox.Show("没有找到【物料】的标题", "提示"); + return; + } + if (HUpperlimit == -1) + { + MessageBox.Show("没有找到【上线比例】的标题", "提示"); + return; + } + if (HLowerlimit == -1) + { + MessageBox.Show("没有找到【下线比例】的标题", "提示"); + return; + } + if (HUSEORGName == -1) + { + MessageBox.Show("没有找到【组织】的标题", "提示"); + return; + } + if (HMaker == -1) + { + MessageBox.Show("没有找到【制单人】的标题", "提示"); + return; + } + if (HMakeDate == -1) + { + MessageBox.Show("没有找到【制单日期】的标题", "提示"); + return; + } + // + if (!Checkdata()) + { + return; + } + if (grdMain.Rows.Count > 0) + { + hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[HMaterNum].Value); + BillNew.omodel.HMakeDate = (DateTime.Today.Date).ToString(); + BillNew.omodel.HUSEORGID = DBUtility.ClsPub.HOrgID; + BillNew.omodel.HStopflag = false; + BillNew.DetailColl.Clear(); + } + for (int i = 0; i <= grdMain.Rows.Count - 1; i++) + { + if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value) != "") + { + //写入类 + if (WriteClass(i)) + { + //保存记录 + if (!BillNew.AddNew()) + { + MessageBox.Show("导入失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); + return; + } + } + } + else + { + MessageBox.Show("工序代码或物料代码为空!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); + return; + } + } + MessageBox.Show("导入完毕"); + grdMain.DataSource = null; + } + + //写入类 从控件 + private bool WriteClass(int row) + { + string sHNumber = ""; + string sHNamePoc = ""; + string HStopflag = ""; + string HUSEORGID = ""; + //string sHNumberWorkType = ""; + string HStdWorkTimes = ""; + string HUpperlimit=""; //上限比例 + string HLowerlimit=""; //下限比例 + + int HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("产品代码", grdMain); + int sMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("产品名称", grdMain); + int sModelCol = DBUtility.Gy_BaseFun.Fun_GetCol("规格型号", grdMain); + int HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain); + int sProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain); + int sSourceNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("资源代码", grdMain); + int sSourceNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("生产资源", grdMain); + int sPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("单价", grdMain); + //long HItemID = 0; + // + sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNum].Value); + sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HProcNum].Value); + // + // + HStopflag = DBUtility.ClsPub.isBool(grdMain.Rows[row].Cells[HStopflag].Value).ToString(); + HUSEORGID = DBUtility.ClsPub.HOrgID.ToString(); + HStdWorkTimes = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HStdWorkTimes].Value).ToString(); + HUpperlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HUpperlimit].Value).ToString(); + HLowerlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HLowerlimit].Value).ToString(); + + //判断是否允许 保存 + if (!DBUtility.ClsPub.AllowNumber(sHNumber)) + { + MessageBox.Show("产品代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示"); + return false; + } + if (!DBUtility.ClsPub.AllowNumber(sHNamePoc)) + { + MessageBox.Show("工序代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示"); + return false; + } + + Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model(); + + //得到工序内码 + if (oProcHlp.GetInfoByName(sHNamePoc)) + { + oSub.HProcID = oProcHlp.omodel.HItemID; + } + //得到物料内码 + if (oMaterHlp.GetInfoByName(sHNumber)) + { + oSub.HMaterID = oMaterHlp.omodel.HItemID; + } + + + //写入信息 + oSub.HEntryID = j; + + oSub.HMaker = DBUtility.ClsPub.CurUserName; + oSub.HMakeDate = (DateTime.Today.Date).ToString(); + oSub.HStdWorkTimes = double.Parse(HStdWorkTimes); + oSub.HRemark = ""; + oSub.HUpperlimit = double.Parse(HUpperlimit); + oSub.HLowerlimit = double.Parse(HLowerlimit); + oSub.HStopflag = bool.Parse(HStopflag); + + + BillNew.DetailColl.Add(oSub); + return true; + } + + //检查物料 + private bool Checkdata() + { + bool b = false; + string sErrMsg = ""; + string sMsg = ""; + for (int i = 0; i <= grdMain.Rows.Count - 1; i++) + { + string sHNumber = ""; + string sHNamePoc = ""; + + // + sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value); + sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value); + if (sHNumber != "") + { + // + //审核代码是否合理 + if (!DBUtility.ClsPub.AllowNumber(sHNumber)) + { + MessageBox.Show("物料代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示"); + return false; + } + //得到物料内码 + int j = i + HBeginRow; + if (!oMaterHlp.GetInfoByNumber(sHNumber)) + { + sMsg = "[" + sHNumber + "]物料不存在"; + if (sErrMsg.Contains(sMsg) == false) + { + sErrMsg = sErrMsg + "[" + sHNumber + "]物料不存在\r\n"; + } + b = true; + } + //得到工序内码 + if (!oProcHlp.GetInfoByName(sHNamePoc)) + { + sMsg = "[" + sHNamePoc + "]工序不存在"; + if (sErrMsg.Contains(sMsg) == false) + { + sErrMsg = sErrMsg + "[" + sHNamePoc + "]工序不存在\r\n"; + } + b = true; + } + } + } + if (b == true) + { + Pub_Control.ErrMsgBox oMsgbox = new Pub_Control.ErrMsgBox(); + oMsgbox.txtHErrMsg.Text = sErrMsg; + oMsgbox.ShowDialog(); + return false; + } + else + { + return true; + } + } + + private void Gy_StdWorkTimes_RoutingBill_Load(object sender, EventArgs e) + { + + } } } + -- Gitblit v1.9.1