/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { WeaveProcessDts2 MasterEntity = (WeaveProcessDts2)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM WO_WeaveProcessDts2 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> /// <param name="p_Entity"></param> /// <param name="p_BE"></param> /// <param name="sqlTrans"></param> public void RSave(WeaveProcess p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { string sql = "DELETE FROM WO_WeaveProcessDts2 WHERE MainID=" + p_Entity.ID.ToString(); sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE)); sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据 for (int i = 0; i < p_BE.Length; i++) { WeaveProcessDts2 entitydts = (WeaveProcessDts2)p_BE[i]; if (entitydts.ID != 0)//ID不为0说明数据库中已经存在 { this.RUpdate(entitydts, sqlTrans); } else { entitydts.MainID = p_Entity.ID; this.RAdd(entitydts, sqlTrans); } } } 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, BaseEntity[] p_BE2, BaseEntity[] p_BE3, IDBTransAccess sqlTrans) { try { this.RAdd(p_BE, sqlTrans); WeaveProcess entity = (WeaveProcess)p_BE; for (int i = 0; i < p_BE2.Length; i++) { WeaveProcessDtsRule rule = new WeaveProcessDtsRule(); WeaveProcessDts entityDts = (WeaveProcessDts)p_BE2[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; rule.RAdd(entityDts, sqlTrans); } for (int i = 0; i < p_BE3.Length; i++) { WeaveProcessDts2Rule rule2 = new WeaveProcessDts2Rule(); WeaveProcessDts2 entityDts2 = (WeaveProcessDts2)p_BE3[i]; entityDts2.MainID = entity.ID; entityDts2.Seq = i + 1; rule2.RAdd(entityDts2, sqlTrans); } FormNoControlRule rulest = new FormNoControlRule(); rulest.RAddSort((int)FormNoControlEnum.白坯织造加工单号, sqlTrans); //this.RAddDts(p_BE, p_BE2, p_BE3, sqlTrans);//保存明细数据 } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得数据库里没有被删除的ID(即数据库里有而且UI里也没有删除的数据) /// </summary> /// <param name="p_BE"></param> /// <returns></returns> private string GetIDExist(BaseEntity[] p_BE) { string outstr = "0"; for (int i = 0; i < p_BE.Length; i++) { WeaveProcessDts2 entitydts = (WeaveProcessDts2)p_BE[i]; if (entitydts.ID != 0) { outstr += "," + entitydts.ID; } } return(outstr); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); WeaveProcessDts2 entity = (WeaveProcessDts2)p_BE; WeaveProcessDts2Ctl control = new WeaveProcessDts2Ctl(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); WeaveProcessDts2 entity = (WeaveProcessDts2)p_BE; WeaveProcessDts2Ctl control = new WeaveProcessDts2Ctl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WO_WeaveProcessDts2, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { WeaveProcessDts2 entity = (WeaveProcessDts2)p_BE; }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { WeaveProcessDts2 MasterEntity = (WeaveProcessDts2)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO WO_WeaveProcessDts2("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); MasterField.Append("ItemCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemCode) + ","); MasterField.Append("ItemName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemName) + ","); MasterField.Append("ItemStd" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemStd) + ","); MasterField.Append("ItemModel" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemModel) + ","); MasterField.Append("Batch" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Batch) + ","); MasterField.Append("VendorBatch" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorBatch) + ","); MasterField.Append("ColorNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ","); MasterField.Append("ColorName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ","); MasterField.Append("VColorNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VColorNum) + ","); MasterField.Append("VColorName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VColorName) + ","); MasterField.Append("Qty" + ","); if (MasterEntity.Qty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Unit" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Unit) + ","); MasterField.Append("SingPrice" + ","); if (MasterEntity.SingPrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SingPrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Amount" + ","); if (MasterEntity.Amount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Amount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("DtsReqDate" + ","); if (MasterEntity.DtsReqDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.DtsReqDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("YarnType" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.YarnType) + ","); MasterField.Append("FreeStr1" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FreeStr1) + ","); MasterField.Append("FreeStr2" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FreeStr2) + ","); MasterField.Append("FreeNum1" + ","); if (MasterEntity.FreeNum1 != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.FreeNum1) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("FreeNum2" + ")"); if (MasterEntity.FreeNum2 != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.FreeNum2) + ")"); } 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 { WeaveProcessDts2 MasterEntity = (WeaveProcessDts2)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE WO_WeaveProcessDts2 SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ","); UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ","); UpdateBuilder.Append(" ItemStd=" + SysString.ToDBString(MasterEntity.ItemStd) + ","); UpdateBuilder.Append(" ItemModel=" + SysString.ToDBString(MasterEntity.ItemModel) + ","); UpdateBuilder.Append(" Batch=" + SysString.ToDBString(MasterEntity.Batch) + ","); UpdateBuilder.Append(" VendorBatch=" + SysString.ToDBString(MasterEntity.VendorBatch) + ","); UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ","); UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ","); UpdateBuilder.Append(" VColorNum=" + SysString.ToDBString(MasterEntity.VColorNum) + ","); UpdateBuilder.Append(" VColorName=" + SysString.ToDBString(MasterEntity.VColorName) + ","); if (MasterEntity.Qty != 0) { UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ","); } else { UpdateBuilder.Append(" Qty=null,"); } UpdateBuilder.Append(" Unit=" + SysString.ToDBString(MasterEntity.Unit) + ","); if (MasterEntity.SingPrice != 0) { UpdateBuilder.Append(" SingPrice=" + SysString.ToDBString(MasterEntity.SingPrice) + ","); } else { UpdateBuilder.Append(" SingPrice=null,"); } if (MasterEntity.Amount != 0) { UpdateBuilder.Append(" Amount=" + SysString.ToDBString(MasterEntity.Amount) + ","); } else { UpdateBuilder.Append(" Amount=null,"); } if (MasterEntity.DtsReqDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" DtsReqDate=" + SysString.ToDBString(MasterEntity.DtsReqDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" DtsReqDate=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" YarnType=" + SysString.ToDBString(MasterEntity.YarnType) + ","); UpdateBuilder.Append(" FreeStr1=" + SysString.ToDBString(MasterEntity.FreeStr1) + ","); UpdateBuilder.Append(" FreeStr2=" + SysString.ToDBString(MasterEntity.FreeStr2) + ","); if (MasterEntity.FreeNum1 != 0) { UpdateBuilder.Append(" FreeNum1=" + SysString.ToDBString(MasterEntity.FreeNum1) + ","); } else { UpdateBuilder.Append(" FreeNum1=null,"); } if (MasterEntity.FreeNum2 != 0) { UpdateBuilder.Append(" FreeNum2=" + SysString.ToDBString(MasterEntity.FreeNum2)); } else { UpdateBuilder.Append(" FreeNum2=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); } }