/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { TowelProductionPlanDtsStepProducts MasterEntity = (TowelProductionPlanDtsStepProducts)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM WO_TowelProductionPlanDtsStepProducts WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
/// <summary> /// 获得工人产量实体 /// </summary> /// <returns></returns> private TowelProductionPlanDtsStepProducts[] EntityProductsGet(int p_MainID, int p_DtsID, int p_SubSeq, int p_StepID, string p_CardNo) { //int index = GetDataCompleteNum(); int index = 0; for (int i = 0; i < gridView4.RowCount; i++) { if (SysConvert.ToString(gridView4.GetRowCellValue(i, "ProOPID")) != "") { index++; } } TowelProductionPlanDtsStepProducts[] entitydts = new TowelProductionPlanDtsStepProducts[index]; index = 0; for (int i = 0; i < gridView4.RowCount; i++) { if (SysConvert.ToString(gridView4.GetRowCellValue(i, "ProOPID")) != "") { entitydts[index] = new TowelProductionPlanDtsStepProducts(); entitydts[index].ID = SysConvert.ToInt32(gridView4.GetRowCellValue(i, "ID")); entitydts[index].SelectByID(); entitydts[index].MainID = p_MainID; entitydts[index].DtsID = p_DtsID; entitydts[index].SubSeq = p_SubSeq; entitydts[index].StepID = p_StepID; entitydts[index].Seq = i + 1; entitydts[index].CardNo = p_CardNo; entitydts[index].ProOPID = SysConvert.ToString(gridView4.GetRowCellValue(i, "ProOPID")); entitydts[index].Qty = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "Qty")); entitydts[index].Remark = SysConvert.ToString(gridView4.GetRowCellValue(i, "Remark")); entitydts[index].RecQty = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "RecQty")); entitydts[index].CQty = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "CQty")); entitydts[index].MLDefect = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "MLDefect")); entitydts[index].RSDefect = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "RSDefect")); entitydts[index].FRDefect = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "CQty")); entitydts[index].OtherDefect = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "OtherDefect")); entitydts[index].JarNum = SysConvert.ToString(gridView4.GetRowCellValue(i, "JarNum")); entitydts[index].MWidth = SysConvert.ToString(gridView4.GetRowCellValue(i, "MWidth")); entitydts[index].MWeight = SysConvert.ToString(gridView4.GetRowCellValue(i, "MWeight")); entitydts[index].SeCha = SysConvert.ToString(gridView4.GetRowCellValue(i, "SeCha")); entitydts[index].SeLaoDu = SysConvert.ToString(gridView4.GetRowCellValue(i, "SeLaoDu")); entitydts[index].XiShuiXing = SysConvert.ToString(gridView4.GetRowCellValue(i, "XiShuiXing")); entitydts[index].Conclusion = SysConvert.ToString(gridView4.GetRowCellValue(i, "Conclusion")); entitydts[index].WorkStartTime = SysConvert.ToDateTime(gridView4.GetRowCellValue(i, "WorkStartTime")); entitydts[index].WorkingHours = SysConvert.ToDecimal(gridView4.GetRowCellValue(i, "WorkingHours")); index++; } } return(entitydts); }
/// <summary> /// 检验字段值是否已存在 /// </summary> /// <param name="p_TableName">表名</param> /// <param name="p_FieldName">字段名</param> /// <param name="p_FieldValue">字段值</param> /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param> /// <param name="p_KeyValue">主键值</param> /// <param name="p_sqlTrans"></param> /// <returns></returns> private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans) { TowelProductionPlanDtsStepProducts entity = (TowelProductionPlanDtsStepProducts)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, TowelProductionPlanDtsStepProducts.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); TowelProductionPlanDtsStepProducts entity = (TowelProductionPlanDtsStepProducts)p_BE; TowelProductionPlanDtsStepProductsCtl control = new TowelProductionPlanDtsStepProductsCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); TowelProductionPlanDtsStepProducts entity = (TowelProductionPlanDtsStepProducts)p_BE; TowelProductionPlanDtsStepProductsCtl control = new TowelProductionPlanDtsStepProductsCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WO_TowelProductionPlanDtsStepProducts, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { TowelProductionPlanDtsStepProducts MasterEntity = (TowelProductionPlanDtsStepProducts)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO WO_TowelProductionPlanDtsStepProducts("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("DtsID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DtsID) + ","); MasterField.Append("SubSeq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubSeq) + ","); MasterField.Append("StepID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.StepID) + ","); MasterField.Append("CardNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CardNo) + ","); MasterField.Append("ProOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProOPID) + ","); MasterField.Append("Qty" + ","); if (MasterEntity.Qty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); MasterField.Append("RecQty" + ","); if (MasterEntity.RecQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.RecQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("CQty" + ","); if (MasterEntity.CQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.CQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("JarNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.JarNum) + ","); MasterField.Append("MWidth" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ","); MasterField.Append("MWeight" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ","); MasterField.Append("SeCha" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SeCha) + ","); MasterField.Append("SeLaoDu" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SeLaoDu) + ","); MasterField.Append("XiShuiXing" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.XiShuiXing) + ","); MasterField.Append("Conclusion" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Conclusion) + ","); MasterField.Append("MLDefect" + ","); if (MasterEntity.MLDefect != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.MLDefect) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("RSDefect" + ","); if (MasterEntity.RSDefect != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.RSDefect) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("FRDefect" + ","); if (MasterEntity.FRDefect != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.FRDefect) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("OtherDefect" + ","); if (MasterEntity.OtherDefect != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.OtherDefect) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("WorkStartTime" + ","); if (MasterEntity.WorkStartTime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.WorkStartTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("WorkingHours" + ")"); if (MasterEntity.WorkingHours != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.WorkingHours) + ")"); } else { MasterValue.Append("null)"); } //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { TowelProductionPlanDtsStepProducts MasterEntity = (TowelProductionPlanDtsStepProducts)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE WO_TowelProductionPlanDtsStepProducts SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" DtsID=" + SysString.ToDBString(MasterEntity.DtsID) + ","); UpdateBuilder.Append(" SubSeq=" + SysString.ToDBString(MasterEntity.SubSeq) + ","); UpdateBuilder.Append(" StepID=" + SysString.ToDBString(MasterEntity.StepID) + ","); UpdateBuilder.Append(" CardNo=" + SysString.ToDBString(MasterEntity.CardNo) + ","); UpdateBuilder.Append(" ProOPID=" + SysString.ToDBString(MasterEntity.ProOPID) + ","); if (MasterEntity.Qty != 0) { UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ","); } else { UpdateBuilder.Append(" Qty=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); if (MasterEntity.RecQty != 0) { UpdateBuilder.Append(" RecQty=" + SysString.ToDBString(MasterEntity.RecQty) + ","); } else { UpdateBuilder.Append(" RecQty=null,"); } if (MasterEntity.CQty != 0) { UpdateBuilder.Append(" CQty=" + SysString.ToDBString(MasterEntity.CQty) + ","); } else { UpdateBuilder.Append(" CQty=null,"); } UpdateBuilder.Append(" JarNum=" + SysString.ToDBString(MasterEntity.JarNum) + ","); UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ","); UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight) + ","); UpdateBuilder.Append(" SeCha=" + SysString.ToDBString(MasterEntity.SeCha) + ","); UpdateBuilder.Append(" SeLaoDu=" + SysString.ToDBString(MasterEntity.SeLaoDu) + ","); UpdateBuilder.Append(" XiShuiXing=" + SysString.ToDBString(MasterEntity.XiShuiXing) + ","); UpdateBuilder.Append(" Conclusion=" + SysString.ToDBString(MasterEntity.Conclusion) + ","); if (MasterEntity.MLDefect != 0) { UpdateBuilder.Append(" MLDefect=" + SysString.ToDBString(MasterEntity.MLDefect) + ","); } else { UpdateBuilder.Append(" MLDefect=null,"); } if (MasterEntity.RSDefect != 0) { UpdateBuilder.Append(" RSDefect=" + SysString.ToDBString(MasterEntity.RSDefect) + ","); } else { UpdateBuilder.Append(" RSDefect=null,"); } if (MasterEntity.FRDefect != 0) { UpdateBuilder.Append(" FRDefect=" + SysString.ToDBString(MasterEntity.FRDefect) + ","); } else { UpdateBuilder.Append(" FRDefect=null,"); } if (MasterEntity.OtherDefect != 0) { UpdateBuilder.Append(" OtherDefect=" + SysString.ToDBString(MasterEntity.OtherDefect) + ","); } else { UpdateBuilder.Append(" OtherDefect=null,"); } if (MasterEntity.WorkStartTime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" WorkStartTime=" + SysString.ToDBString(MasterEntity.WorkStartTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" WorkStartTime=null,"); } if (MasterEntity.WorkingHours != 0) { UpdateBuilder.Append(" WorkingHours=" + SysString.ToDBString(MasterEntity.WorkingHours)); } else { UpdateBuilder.Append(" WorkingHours=null"); } UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }
/// <summary> /// 保存 保存当前站输入的信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click_1(object sender, EventArgs e) { try { this.BaseFocusLabel.Focus(); int MainID = SysConvert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MainID")); int DtsID = SysConvert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DtsID")); int SubSeq = SysConvert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SubSeq")); int StepID = SysConvert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "StepID")); int ID = 0; //保存卡号等信息 #region 保存卡号等信息 string sql = " select * from WO_TowelProductionPlanDtsStep where 1=1 "; sql += " and MainID = " + MainID; sql += " and DtsID = " + DtsID; sql += " and SubSeq = " + SubSeq; sql += " and StepID = " + StepID; DataTable dt = SysUtils.Fill(sql); if (dt.Rows.Count > 0) { ID = SysConvert.ToInt32(dt.Rows[0]["ID"]); } TowelProductionPlanDtsStep entity = new TowelProductionPlanDtsStep(); TowelProductionPlanDtsStepRule rule = new TowelProductionPlanDtsStepRule(); entity.ID = ID; entity.SelectByID(); entity.MainID = MainID; entity.DtsID = DtsID; entity.SubSeq = SubSeq; entity.StepID = this.FormListAID;//站别为当前 FormListAID entity.CardNo = SysConvert.ToString(txtCardNo.Text.Trim()); entity.RecQty = SysConvert.ToDecimal(txtRecQty.Text.Trim()); entity.RecDate = SysConvert.ToDateTime(txtRecDate.DateTime); entity.ZPQty = SysConvert.ToDecimal(txtZPQty.Text.Trim()); entity.CPQty = SysConvert.ToDecimal(txtCPQty.Text.Trim()); entity.MakeOPID = SysConvert.ToString(drpMakeOPID.EditValue); //entity.ProOPID = SysConvert.ToString(drpProOPID.EditValue); entity.Remark = SysConvert.ToString(txtRemark.Text.Trim()); if (SysConvert.ToDecimal(entity.RecQty) == 0) { this.ShowInfoMessage("请输入收到数量"); txtRecQty.Focus(); return; } if (entity.ID > 0) { rule.RUpdate(entity); //this.ShowInfoMessage("保存成功"); } else { rule.RAdd(entity); //this.ShowInfoMessage("保存成功"); } #endregion //2 #region 保存工人产量表 TowelProductionPlanDtsStepProducts ProductsEntity = new TowelProductionPlanDtsStepProducts(); TowelProductionPlanDtsStepProductsRule ProductsRule = new TowelProductionPlanDtsStepProductsRule(); int ProductsID = 0; string sqlA = " select * from WO_TowelProductionPlanDtsStepProducts where 1=1 "; sqlA += " and MainID = " + MainID; sqlA += " and DtsID = " + DtsID; sqlA += " and SubSeq = " + SubSeq; sqlA += " and StepID = " + StepID; DataTable dtA = SysUtils.Fill(sqlA); if (dtA.Rows.Count > 0) { for (int i = 0; i < dtA.Rows.Count; i++) { ProductsID = SysConvert.ToInt32(dtA.Rows[i]["ID"]); ProductsEntity.ID = ProductsID; ProductsEntity.SelectByID(); ProductsRule.RDelete(ProductsEntity);//删除现有 } } TowelProductionPlanDtsStepProducts[] EntityProducts = EntityProductsGet(MainID, DtsID, SubSeq, StepID, entity.CardNo); ProductsRule.RAdd(EntityProducts); #endregion this.ShowInfoMessage("保存成功"); GetCondtion(); BindGrid(); ProcessGrid.GridViewFocus(gridView1, new string[] { "DtsID" }, new string[] { DtsID.ToString() }); } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { TowelProductionPlanDtsStepProducts entity = (TowelProductionPlanDtsStepProducts)p_BE; }