/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { YarnCompact MasterEntity = (YarnCompact)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Buy_YarnCompact 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(YarnCompact p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { string sql = "DELETE FROM Buy_YarnCompactDts WHERE MainID=" + p_Entity.ID.ToString(); sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据 for (int i = 0; i < p_BE.Length; i++) { YarnCompactDts entitydts = (YarnCompactDts)p_BE[i]; sql = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM Buy_YarnCompactDts WHERE MainID=" + p_Entity.ID.ToString(); entitydts.Seq = SysConvert.ToInt32(sqlTrans.Fill(sql).Rows[0][0].ToString());//找到最大的Seq 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_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { YarnCompact MasterEntity = (YarnCompact)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Buy_YarnCompact("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("VendorID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorID) + ","); MasterField.Append("BuyOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.BuyOPID) + ","); MasterField.Append("SubmitFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ","); MasterField.Append("ProcFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProcFlag) + ","); MasterField.Append("DelFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("Code" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ","); MasterField.Append("VendorOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorOPID) + ","); MasterField.Append("TotalAmount" + ","); if (MasterEntity.TotalAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.TotalAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("TotalQty" + ","); if (MasterEntity.TotalQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.TotalQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MakeOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPID) + ","); MasterField.Append("CompanyTypeID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CompanyTypeID) + ","); MasterField.Append("InDate" + ","); if (MasterEntity.InDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.InDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("NeedDate" + ","); if (MasterEntity.NeedDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.NeedDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("PayMethod" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.PayMethod) + ","); MasterField.Append("MakeDate" + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ItemTypeID" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemTypeID) + ")"); //执行 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 { YarnCompact MasterEntity = (YarnCompact)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Buy_YarnCompact SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" VendorID=" + SysString.ToDBString(MasterEntity.VendorID) + ","); UpdateBuilder.Append(" BuyOPID=" + SysString.ToDBString(MasterEntity.BuyOPID) + ","); UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ","); UpdateBuilder.Append(" ProcFlag=" + SysString.ToDBString(MasterEntity.ProcFlag) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ","); UpdateBuilder.Append(" VendorOPID=" + SysString.ToDBString(MasterEntity.VendorOPID) + ","); if (MasterEntity.TotalAmount != 0) { UpdateBuilder.Append(" TotalAmount=" + SysString.ToDBString(MasterEntity.TotalAmount) + ","); } else { UpdateBuilder.Append(" TotalAmount=null,"); } if (MasterEntity.TotalQty != 0) { UpdateBuilder.Append(" TotalQty=" + SysString.ToDBString(MasterEntity.TotalQty) + ","); } else { UpdateBuilder.Append(" TotalQty=null,"); } UpdateBuilder.Append(" MakeOPID=" + SysString.ToDBString(MasterEntity.MakeOPID) + ","); UpdateBuilder.Append(" CompanyTypeID=" + SysString.ToDBString(MasterEntity.CompanyTypeID) + ","); if (MasterEntity.InDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" InDate=" + SysString.ToDBString(MasterEntity.InDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" InDate=null,"); } if (MasterEntity.NeedDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" NeedDate=" + SysString.ToDBString(MasterEntity.NeedDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" NeedDate=null,"); } UpdateBuilder.Append(" PayMethod=" + SysString.ToDBString(MasterEntity.PayMethod) + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" MakeDate=" + SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" MakeDate=null,"); } UpdateBuilder.Append(" ItemTypeID=" + SysString.ToDBString(MasterEntity.ItemTypeID)); 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); } }