/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { SaleOrderTFabric MasterEntity = (SaleOrderTFabric)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Sale_SaleOrderTFabric 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_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SaleOrderTFabric entity = (SaleOrderTFabric)p_BE; SaleOrderTFabricCtl control = new SaleOrderTFabricCtl(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); SaleOrderTFabric entity = (SaleOrderTFabric)p_BE; SaleOrderTFabricCtl control = new SaleOrderTFabricCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Sale_SaleOrderTFabric, 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 { SaleOrderTFabric MasterEntity = (SaleOrderTFabric)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Sale_SaleOrderTFabric("); 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("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("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("VendorID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorID) + ","); MasterField.Append("ColorNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ","); MasterField.Append("ColorName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ","); MasterField.Append("SO" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SO) + ","); MasterField.Append("RQty" + ","); if (MasterEntity.RQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.RQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ItemModel" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemModel) + ","); MasterField.Append("DID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DID) + ","); MasterField.Append("SH" + ","); if (MasterEntity.SH != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SH) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SQty" + ","); if (MasterEntity.SQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("CPItemCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CPItemCode) + ","); MasterField.Append("CPItemName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CPItemName) + ","); MasterField.Append("CPItemStd" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CPItemStd) + ","); MasterField.Append("CPItemModel" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CPItemModel) + ","); MasterField.Append("Needle" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Needle) + ","); MasterField.Append("MWidth" + ","); if (MasterEntity.MWidth != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MWeight" + ")"); if (MasterEntity.MWeight != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ")"); } 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 { SaleOrderTFabric MasterEntity = (SaleOrderTFabric)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Sale_SaleOrderTFabric 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) + ","); if (MasterEntity.Qty != 0) { UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ","); } else { UpdateBuilder.Append(" Qty=null,"); } UpdateBuilder.Append(" Unit=" + SysString.ToDBString(MasterEntity.Unit) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" VendorID=" + SysString.ToDBString(MasterEntity.VendorID) + ","); UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ","); UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ","); UpdateBuilder.Append(" SO=" + SysString.ToDBString(MasterEntity.SO) + ","); if (MasterEntity.RQty != 0) { UpdateBuilder.Append(" RQty=" + SysString.ToDBString(MasterEntity.RQty) + ","); } else { UpdateBuilder.Append(" RQty=null,"); } UpdateBuilder.Append(" ItemModel=" + SysString.ToDBString(MasterEntity.ItemModel) + ","); UpdateBuilder.Append(" DID=" + SysString.ToDBString(MasterEntity.DID) + ","); if (MasterEntity.SH != 0) { UpdateBuilder.Append(" SH=" + SysString.ToDBString(MasterEntity.SH) + ","); } else { UpdateBuilder.Append(" SH=null,"); } if (MasterEntity.SQty != 0) { UpdateBuilder.Append(" SQty=" + SysString.ToDBString(MasterEntity.SQty) + ","); } else { UpdateBuilder.Append(" SQty=null,"); } UpdateBuilder.Append(" CPItemCode=" + SysString.ToDBString(MasterEntity.CPItemCode) + ","); UpdateBuilder.Append(" CPItemName=" + SysString.ToDBString(MasterEntity.CPItemName) + ","); UpdateBuilder.Append(" CPItemStd=" + SysString.ToDBString(MasterEntity.CPItemStd) + ","); UpdateBuilder.Append(" CPItemModel=" + SysString.ToDBString(MasterEntity.CPItemModel) + ","); UpdateBuilder.Append(" Needle=" + SysString.ToDBString(MasterEntity.Needle) + ","); if (MasterEntity.MWidth != 0) { UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ","); } else { UpdateBuilder.Append(" MWidth=null,"); } if (MasterEntity.MWeight != 0) { UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight)); } else { UpdateBuilder.Append(" MWeight=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="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { SaleOrderTFabric entity = (SaleOrderTFabric)p_BE; }