/// <summary> /// 转入生产计划 /// </summary> /// <param name="SaleID"></param> /// <returns></returns> public int ToPlan(int SaleID, int FillMan) { try { // DataTable dt = GetList("(ID=" + SaleID + ")").Tables[0]; Hownet.Model.SalesOrderInfoList modSOI = GetModel(SaleID); Hownet.BLL.SysTem bllST = new SysTem(); Hownet.Model.SysTem modST = bllST.GetModel(bllST.GetMaxId() - 1); Hownet.BLL.ProductionPlan bllPP = new ProductionPlan(); Hownet.Model.ProductionPlan modPP = new Hownet.Model.ProductionPlan(); modPP.SalesOrderInfoID = modSOI.ID; // Convert.ToInt32(dt.Rows[0]["ID"]); modPP.MaterielID = modSOI.MaterielID; // Convert.ToInt32(dt.Rows[0]["MaterielID"]); modPP.BrandID = modSOI.BrandID; // Convert.ToInt32(dt.Rows[0]["BrandID"]); modPP.Num = modSOI.Num; // Convert.ToInt32(dt.Rows[0]["Num"]);// bllPP.NewNum(DateTime.Today, modST.NumType); // dalPP.NewNum(DateTime.Today, modST.NumType); modPP.DateTime = modSOI.DateTime; // Convert.ToDateTime(dt.Rows[0]["DateTime"]);// DateTime.Today; modPP.LastDate = modSOI.LastDate; // Convert.ToDateTime(dt.Rows[0]["LastDate"]); modPP.Remark = modSOI.Remark; // dt.Rows[0]["Remark"].ToString(); modPP.PWorkingID = modPP.BomID = 0; modPP.CompanyID = modSOI.CompanyID; // Convert.ToInt32(dt.Rows[0]["CompanyID"]); modPP.IsTicket = modPP.IsBom = false; modPP.VerifyDate = Convert.ToDateTime("1900-1-1"); modPP.VerifyMan = 0; modPP.DeparmentID = 0; modPP.UpData = 1; modPP.FillDate = DateTime.Today; modPP.FilMan = FillMan; modPP.TicketDate = Convert.ToDateTime("1900-1-1"); modPP.BedNO = string.Empty; modPP.PackingMethodID = modSOI.PackingMethodID; // Convert.ToInt32(dt.Rows[0]["PackingMethodID"]); modPP.SewingRemark = modSOI.Remark + "\r\n" + modSOI.SewingRemark; // dt.Rows[0]["Remark"].ToString() + "\r\n" + dt.Rows[0]["SewingRemark"].ToString(); modPP.TypeID = modPP.ParentID = 0; modPP.ParentID = 0; modPP.IsVerify = 1; modPP.AssociatedID = string.Empty; modPP.AssociatedMatID = 0; //dt.Rows[0]["IsToPlan"] = 1; modSOI.IsToPlan = true; Update(modSOI); // UpdateByDt(dt); return(bllPP.Add(modPP)); } catch (Exception ex) { return(0); } // return dal.ToPlan(SaleID, FillMan); }
/// <summary> /// 合并生产计划 /// </summary> /// <param name="StrPPID"></param> public int MergePP(string StrPPID) { Hownet.BLL.AmountInfo bllAI = new AmountInfo(); string[] ss = StrPPID.Split(','); int MainID = 0; Hownet.Model.ProductionPlan modPP = GetModel(Convert.ToInt32(ss[0])); modPP.TypeID = -1; modPP.DeparmentID = -1; modPP.UpData = 1; modPP.IsVerify = 1; MainID = Add(modPP); DataTable dt = dal.GetMergeAmount(StrPPID, (int)Enums.TableType.ProductionPlan).Tables[0]; DataTable dttt = dt.Clone(); Hownet.BLL.MaterielList bllML = new MaterielList(); Hownet.Model.MaterielList modML; Hownet.BLL.Materiel bllMat = new Materiel(); Hownet.Model.Materiel modMat = bllMat.GetModel(modPP.MaterielID); for (int i = 0; i < dt.Rows.Count; i++) { dttt.Rows.Clear(); dt.Rows[i]["MainID"] = MainID; modML = new Hownet.Model.MaterielList(); modML.BrandID = modPP.BrandID; modML.ColorID = Convert.ToInt32(dt.Rows[i]["ColorID"]); modML.ColorOneID = Convert.ToInt32(dt.Rows[i]["ColorOneID"]); modML.ColorTwoID = Convert.ToInt32(dt.Rows[i]["ColorTwoID"]); modML.MaterielID = modPP.MaterielID; modML.MeasureID = modMat.MeasureID; modML.SizeID = Convert.ToInt32(dt.Rows[i]["SizeID"]); dt.Rows[i]["MListID"] = modML.ID = bllML.GetID(modML); dttt.Rows.Add(dt.Rows[i].ItemArray); bllAI.AddByDt(dttt); } for (int i = 0; i < ss.Length; i++) { modPP = GetModel(Convert.ToInt32(ss[i])); modPP.DeparmentID = MainID; modPP.IsVerify = (int)Enums.IsVerify.合并或拆分; Update(modPP); } return(MainID); }
/// <summary> /// 将生产计划进行生产 /// </summary> /// <param name="PlanID">计划单ID</param> /// <param name="TaskID">生产单ID</param> /// <param name="PlanTypeID">计划单类型</param> /// <param name="TaskTypeID">生产单类型</param> /// <param name="t">真为生产,假为取消生产单</param> public void UpPlanAmount(int PlanID, int TaskID, int PlanTypeID, int TaskTypeID, bool t) { Hownet.BLL.AmountInfo bllAI = new AmountInfo(); List <Hownet.Model.AmountInfo> liPP = bllAI.DataTableToList(bllAI.GetList("(MainID=" + PlanID + ") And (TableTypeID=" + PlanTypeID + ")").Tables[0]); if (liPP.Count > 0) { List <Hownet.Model.AmountInfo> liTask = bllAI.DataTableToList(bllAI.GetList("(MainID=" + TaskID + ") And (TableTypeID=" + TaskTypeID + ")").Tables[0]); if (liTask.Count > 0) { for (int i = 0; i < liPP.Count; i++) { for (int j = 0; j < liTask.Count; j++) { if (liPP[i].MListID == liTask[j].MListID) { if (t) { liPP[i].NotAmount -= liTask[j].Amount; } else { liPP[i].NotAmount += liTask[j].Amount; } bllAI.Update(liPP[i]); break; } } } } } Hownet.Model.ProductionPlan modPP = GetModel(PlanID); if (modPP.IsVerify < 4) { modPP.IsVerify = 4; Update(modPP); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Hownet.Model.ProductionPlan model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.ProductionPlan model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <Hownet.Model.ProductionPlan> DataTableToList(DataTable dt) { List <Hownet.Model.ProductionPlan> modelList = new List <Hownet.Model.ProductionPlan>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Hownet.Model.ProductionPlan model; for (int n = 0; n < rowsCount; n++) { model = new Hownet.Model.ProductionPlan(); if (dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } else { model.ID = 0; } if (dt.Rows[n]["SalesOrderInfoID"].ToString() != "") { model.SalesOrderInfoID = int.Parse(dt.Rows[n]["SalesOrderInfoID"].ToString()); } else { model.SalesOrderInfoID = 0; } if (dt.Rows[n]["MaterielID"].ToString() != "") { model.MaterielID = int.Parse(dt.Rows[n]["MaterielID"].ToString()); } else { model.MaterielID = 0; } if (dt.Rows[n]["BrandID"].ToString() != "") { model.BrandID = int.Parse(dt.Rows[n]["BrandID"].ToString()); } else { model.BrandID = 0; } if (dt.Rows[n]["Num"].ToString() != "") { model.Num = int.Parse(dt.Rows[n]["Num"].ToString()); } else { model.Num = 0; } if (dt.Rows[n]["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(dt.Rows[n]["DateTime"].ToString()); } else { model.DateTime = DateTime.Parse("1900-1-1"); } if (dt.Rows[n]["LastDate"].ToString() != "") { model.LastDate = DateTime.Parse(dt.Rows[n]["LastDate"].ToString()); } else { model.LastDate = DateTime.Parse("1900-1-1"); } model.Remark = dt.Rows[n]["Remark"].ToString(); if (dt.Rows[n]["PWorkingID"].ToString() != "") { model.PWorkingID = int.Parse(dt.Rows[n]["PWorkingID"].ToString()); } else { model.PWorkingID = 0; } if (dt.Rows[n]["BomID"].ToString() != "") { model.BomID = int.Parse(dt.Rows[n]["BomID"].ToString()); } else { model.BomID = 0; } if (dt.Rows[n]["CompanyID"].ToString() != "") { model.CompanyID = int.Parse(dt.Rows[n]["CompanyID"].ToString()); } else { model.CompanyID = 0; } if (dt.Rows[n]["IsTicket"].ToString() != "") { if ((dt.Rows[n]["IsTicket"].ToString() == "1") || (dt.Rows[n]["IsTicket"].ToString().ToLower() == "true")) { model.IsTicket = true; } else { model.IsTicket = false; } } if (dt.Rows[n]["IsBom"].ToString() != "") { if ((dt.Rows[n]["IsBom"].ToString() == "1") || (dt.Rows[n]["IsBom"].ToString().ToLower() == "true")) { model.IsBom = true; } else { model.IsBom = false; } } if (dt.Rows[n]["IsVerify"].ToString() != "") { model.IsVerify = int.Parse(dt.Rows[n]["IsVerify"].ToString()); } else { model.IsVerify = 0; } if (dt.Rows[n]["VerifyDate"].ToString() != "") { model.VerifyDate = DateTime.Parse(dt.Rows[n]["VerifyDate"].ToString()); } else { model.VerifyDate = DateTime.Parse("1900-1-1"); } if (dt.Rows[n]["VerifyMan"].ToString() != "") { model.VerifyMan = int.Parse(dt.Rows[n]["VerifyMan"].ToString()); } else { model.VerifyMan = 0; } if (dt.Rows[n]["DeparmentID"].ToString() != "") { model.DeparmentID = int.Parse(dt.Rows[n]["DeparmentID"].ToString()); } else { model.DeparmentID = 0; } if (dt.Rows[n]["UpData"].ToString() != "") { model.UpData = int.Parse(dt.Rows[n]["UpData"].ToString()); } else { model.UpData = 0; } if (dt.Rows[n]["FillDate"].ToString() != "") { model.FillDate = DateTime.Parse(dt.Rows[n]["FillDate"].ToString()); } else { model.FillDate = DateTime.Parse("1900-1-1"); } if (dt.Rows[n]["FilMan"].ToString() != "") { model.FilMan = int.Parse(dt.Rows[n]["FilMan"].ToString()); } else { model.FilMan = 0; } if (dt.Rows[n]["TicketDate"].ToString() != "") { model.TicketDate = DateTime.Parse(dt.Rows[n]["TicketDate"].ToString()); } else { model.TicketDate = DateTime.Parse("1900-1-1"); } model.BedNO = dt.Rows[n]["BedNO"].ToString(); if (dt.Rows[n]["PackingMethodID"].ToString() != "") { model.PackingMethodID = int.Parse(dt.Rows[n]["PackingMethodID"].ToString()); } else { model.PackingMethodID = 0; } model.SewingRemark = dt.Rows[n]["SewingRemark"].ToString(); if (dt.Rows[n]["TypeID"].ToString() != "") { model.TypeID = int.Parse(dt.Rows[n]["TypeID"].ToString()); } else { model.TypeID = 0; } if (dt.Rows[n]["ParentID"].ToString() != "") { model.ParentID = int.Parse(dt.Rows[n]["ParentID"].ToString()); } else { model.ParentID = 0; } model.AssociatedID = dt.Rows[n]["AssociatedID"].ToString(); if (dt.Rows[n]["AssociatedMatID"] != null && dt.Rows[n]["AssociatedMatID"].ToString() != "") { model.AssociatedMatID = int.Parse(dt.Rows[n]["AssociatedMatID"].ToString()); } model.A = int.Parse(dt.Rows[n]["A"].ToString()); modelList.Add(model); } } return(modelList); }