private void CreateReLsWork() { //获取重工工序列表 if (selectprocess.ReWorkProcess != null) { string[] ReWorkProcessID = selectprocess.ReWorkProcess.Split(','); List <MES.Server.Model.BPM_ReWork> temLsRework = new List <Server.Model.BPM_ReWork>(); foreach (string tem in ReWorkProcessID) { List <MES.Server.Model.BPM_ProductTemplate> tePt = (from s in LsV_ProcessTemplate where s.ProcessID == tem select s).ToList(); if (tePt.Count > 0) { MES.Server.Model.BPM_ProductTemplate teProcess = (MES.Server.Model.BPM_ProductTemplate)tePt[0]; temLsRework.Add(new Server.Model.BPM_ReWork() { OrderID = order.OrderID, DispositonJobNum = user.Job_Num, DispositonUser = user.Name, WK_Receive = teProcess.ProcessID, Disposition = teProcess.ProcessName }); } } LsReWork = temLsRework; } }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(MES.Server.Model.BPM_ProductTemplate model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BPM_ProductTemplate("); strSql.Append("Department,WorkShop,PtID,Alias,Name,Num,ProcessID,ProcessName,ProcessSign,IsCheckTotalCount,OnceQty,StandardHours,ConnectorQty,TL,IsVital,IsControl,ReWorkProcess)"); strSql.Append(" values ("); strSql.Append("@Department,@WorkShop,@PtID,@Alias,@Name,@Num,@ProcessID,@ProcessName,@ProcessSign,@IsCheckTotalCount,@OnceQty,@StandardHours,@ConnectorQty,@TL,@IsVital,@IsControl,@ReWorkProcess)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Department", SqlDbType.VarChar, 50), new SqlParameter("@WorkShop", SqlDbType.VarChar, 50), new SqlParameter("@PtID", SqlDbType.VarChar, 100), new SqlParameter("@Alias", SqlDbType.VarChar, 100), new SqlParameter("@Name", SqlDbType.VarChar, 100), new SqlParameter("@Num", SqlDbType.Int, 4), new SqlParameter("@ProcessID", SqlDbType.VarChar, 100), new SqlParameter("@ProcessName", SqlDbType.VarChar, 100), new SqlParameter("@ProcessSign", SqlDbType.VarChar, 100), new SqlParameter("@IsCheckTotalCount", SqlDbType.Bit, 1), new SqlParameter("@OnceQty", SqlDbType.Int, 4), new SqlParameter("@StandardHours", SqlDbType.Decimal, 9), new SqlParameter("@ConnectorQty", SqlDbType.Int, 4), new SqlParameter("@TL", SqlDbType.Decimal, 9), new SqlParameter("@IsVital", SqlDbType.VarChar, 10), new SqlParameter("@IsControl", SqlDbType.VarChar, 10), new SqlParameter("@ReWorkProcess", SqlDbType.VarChar, 1000) }; parameters[0].Value = model.Department; parameters[1].Value = model.WorkShop; parameters[2].Value = model.PtID; parameters[3].Value = model.Alias; parameters[4].Value = model.Name; parameters[5].Value = model.Num; parameters[6].Value = model.ProcessID; parameters[7].Value = model.ProcessName; parameters[8].Value = model.ProcessSign; parameters[9].Value = model.IsCheckTotalCount; parameters[10].Value = model.OnceQty; parameters[11].Value = model.StandardHours; parameters[12].Value = model.ConnectorQty; parameters[13].Value = model.TL; parameters[14].Value = model.IsVital; parameters[15].Value = model.IsControl; parameters[16].Value = model.ReWorkProcess; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 获取工单信息 /// </summary> /// <param name="value"></param> private void GetOrder(string value) { Order = order_bll.GetModel(value); if (Order != null) //查找工单是否存在 { if (Order.Product != null) //检查产品是否为空 { if (SelectProcess != null) //检查选择的工序是否为空 { MES.Server.Model.BPM_ProductTemplate resultPt = Order.Product.ControlProcessList.ToList().Find( delegate(MES.Server.Model.BPM_ProductTemplate pt) { return(pt.ProcessID == SelectProcess.ProcessID); }); //检查已选择的工序是否此工单也有 if (resultPt == null) //如果没有 { LsV_ProcessTemplate = Order.Product.ControlProcessList.ToList(); SelectProcess = new Server.Model.BPM_ProductTemplate(); } else { //获取记录 并计算已生产的数量 LsProduction = productionrecords_bll.GetModelList("OrderID='" + order.OrderID + "' AND ProcessID='" + SelectProcess.ProcessID + "'"); var sum = (from temp in LsProduction select temp).Sum(t => t.Qty); Sum = decimal.Parse(sum.ToString()); } } else { LsV_ProcessTemplate = Order.Product.ControlProcessList.ToList(); SelectProcess = new Server.Model.BPM_ProductTemplate(); } if (order.Relax != null) //接头总数=接头数量 x 总批量 x 款放比例 { OrderQty = int.Parse((order.Count * double.Parse(order.Relax.ToString()) * double.Parse(order.Product.ConnectorQty.ToString())).ToString()); } else { OrderQty = int.Parse((order.Count * double.Parse(order.Product.ConnectorQty.ToString())).ToString()); ZhuifengLib.MessageShow.Message.MessageInfo("工单未设置宽放比例;请联系助理进行设置!"); } } else { LsV_ProcessTemplate = null; SelectProcess = new Server.Model.BPM_ProductTemplate(); } } else { LsV_ProcessTemplate = null; SelectProcess = new Server.Model.BPM_ProductTemplate(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MES.Server.Model.BPM_ProductTemplate DataRowToModel(DataRow row) { MES.Server.Model.BPM_ProductTemplate model = new MES.Server.Model.BPM_ProductTemplate(); if (row != null) { if (row["Department"] != null) { model.Department = row["Department"].ToString(); } if (row["WorkShop"] != null) { model.WorkShop = row["WorkShop"].ToString(); } if (row["PtID"] != null) { model.PtID = row["PtID"].ToString(); } if (row["Alias"] != null) { model.Alias = row["Alias"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Num"] != null && row["Num"].ToString() != "") { model.Num = int.Parse(row["Num"].ToString()); } if (row["ProcessID"] != null) { model.ProcessID = row["ProcessID"].ToString(); } if (row["ProcessName"] != null) { model.ProcessName = row["ProcessName"].ToString(); } if (row["ProcessSign"] != null) { model.ProcessSign = row["ProcessSign"].ToString(); } if (row["IsCheckTotalCount"] != null && row["IsCheckTotalCount"].ToString() != "") { if ((row["IsCheckTotalCount"].ToString() == "1") || (row["IsCheckTotalCount"].ToString().ToLower() == "true")) { model.IsCheckTotalCount = true; } else { model.IsCheckTotalCount = false; } } if (row["OnceQty"] != null && row["OnceQty"].ToString() != "") { model.OnceQty = int.Parse(row["OnceQty"].ToString()); } if (row["StandardHours"] != null && row["StandardHours"].ToString() != "") { model.StandardHours = decimal.Parse(row["StandardHours"].ToString()); } if (row["ConnectorQty"] != null && row["ConnectorQty"].ToString() != "") { model.ConnectorQty = int.Parse(row["ConnectorQty"].ToString()); } if (row["TL"] != null && row["TL"].ToString() != "") { model.TL = decimal.Parse(row["TL"].ToString()); } if (row["IsVital"] != null) { model.IsVital = row["IsVital"].ToString(); } if (row["IsControl"] != null) { model.IsControl = row["IsControl"].ToString(); } if (row["ReWorkProcess"] != null) { model.ReWorkProcess = row["ReWorkProcess"].ToString(); } if (row["ID_Key"] != null && row["ID_Key"].ToString() != "") { model.ID_Key = decimal.Parse(row["ID_Key"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MES.Server.Model.BPM_ProductTemplate model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BPM_ProductTemplate set "); strSql.Append("Department=@Department,"); strSql.Append("WorkShop=@WorkShop,"); strSql.Append("PtID=@PtID,"); strSql.Append("Alias=@Alias,"); strSql.Append("Name=@Name,"); strSql.Append("Num=@Num,"); strSql.Append("ProcessID=@ProcessID,"); strSql.Append("ProcessName=@ProcessName,"); strSql.Append("ProcessSign=@ProcessSign,"); strSql.Append("IsCheckTotalCount=@IsCheckTotalCount,"); strSql.Append("OnceQty=@OnceQty,"); strSql.Append("StandardHours=@StandardHours,"); strSql.Append("ConnectorQty=@ConnectorQty,"); strSql.Append("TL=@TL,"); strSql.Append("IsVital=@IsVital,"); strSql.Append("IsControl=@IsControl,"); strSql.Append("ReWorkProcess=@ReWorkProcess"); strSql.Append(" where ID_Key=@ID_Key"); SqlParameter[] parameters = { new SqlParameter("@Department", SqlDbType.VarChar, 50), new SqlParameter("@WorkShop", SqlDbType.VarChar, 50), new SqlParameter("@PtID", SqlDbType.VarChar, 100), new SqlParameter("@Alias", SqlDbType.VarChar, 100), new SqlParameter("@Name", SqlDbType.VarChar, 100), new SqlParameter("@Num", SqlDbType.Int, 4), new SqlParameter("@ProcessID", SqlDbType.VarChar, 100), new SqlParameter("@ProcessName", SqlDbType.VarChar, 100), new SqlParameter("@ProcessSign", SqlDbType.VarChar, 100), new SqlParameter("@IsCheckTotalCount", SqlDbType.Bit, 1), new SqlParameter("@OnceQty", SqlDbType.Int, 4), new SqlParameter("@StandardHours", SqlDbType.Decimal, 9), new SqlParameter("@ConnectorQty", SqlDbType.Int, 4), new SqlParameter("@TL", SqlDbType.Decimal, 9), new SqlParameter("@IsVital", SqlDbType.VarChar, 10), new SqlParameter("@IsControl", SqlDbType.VarChar, 10), new SqlParameter("@ReWorkProcess", SqlDbType.VarChar, 1000), new SqlParameter("@ID_Key", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Department; parameters[1].Value = model.WorkShop; parameters[2].Value = model.PtID; parameters[3].Value = model.Alias; parameters[4].Value = model.Name; parameters[5].Value = model.Num; parameters[6].Value = model.ProcessID; parameters[7].Value = model.ProcessName; parameters[8].Value = model.ProcessSign; parameters[9].Value = model.IsCheckTotalCount; parameters[10].Value = model.OnceQty; parameters[11].Value = model.StandardHours; parameters[12].Value = model.ConnectorQty; parameters[13].Value = model.TL; parameters[14].Value = model.IsVital; parameters[15].Value = model.IsControl; parameters[16].Value = model.ReWorkProcess; parameters[17].Value = model.ID_Key; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }