/// <summary> /// 删除 /// </summary> public override void EntityDelete() { AuditPriceRule rule = new AuditPriceRule(); AuditPrice entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); AuditPrice entity = (AuditPrice)p_BE; AuditPriceCtl control = new AuditPriceCtl(sqlTrans); string sql = "SELECT Code FROM Sale_AuditPrice WHERE Code=" + SysString.ToDBString(entity.Code); if (sqlTrans.Fill(sql).Rows.Count != 0) { throw new Exception("该单号已存在,请重新生成"); } //entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Sale_AuditPrice, sqlTrans); control.AddNew(entity); //sql = " UPDATE Enum_FormNoControl SET CurSort=CurSort+1 WHERE ID=" + (int)FormNoControlEnum.核价单号;//更新CurSort sqlTrans.ExecuteNonQuery(sql); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { AuditPrice MasterEntity = (AuditPrice)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Sale_AuditPrice 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 AuditPrice EntityGet() { AuditPrice entity = new AuditPrice(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { AuditPrice entity = new AuditPrice(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); HTDataFormNo = entity.Code; txtCode.Text = entity.Code.ToString(); txtProductCode.Text = entity.ProductCode.ToString(); drpItemCode.EditValue = entity.ItemCode; txtItemName.Text = entity.ItemName.ToString(); txtItemStd.Text = entity.ItemStd.ToString(); txtItemModel.Text = entity.ItemModel.ToString(); txtProductName.Text = entity.ProductName.ToString(); txtEquipment.Text = entity.Equipment.ToString(); txtProductGY.Text = entity.ProductGY.ToString(); txtProductRSGY.Text = entity.ProductRSGY.ToString(); txtMakeOPID.Text = Common.GetOPName(entity.MakeOPID.ToString()); txtMakeDate.DateTime = entity.MakeDate; drpJSOPID.EditValue = entity.JSOPID; drpSHOPID.EditValue = entity.SHOPID; txtRemark.Text = entity.Remark.ToString(); txtPPrice.Text = entity.PPrice.ToString(); txtPDatetime.DateTime = entity.PDatetime; txtSPrice.Text = entity.SPrice.ToString(); txtSDatetime.DateTime = entity.SDatetime; drpCompanyTypeID.EditValue = entity.CompanyTypeID; txtItemAmount.Text = entity.ItemAmount.ToString(); txtOthAmount.Text = entity.OthAmount.ToString(); txtColorAmount.Text = entity.ColorAmount.ToString(); txtDTAmount.Text = entity.DTAmount.ToString(); txtDTSHAmount.Text = entity.DTSHAmount.ToString(); txtSTPrice.Text = entity.STPrice.ToString(); HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); }
/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); AuditPrice entity = (AuditPrice)p_BE; AuditPriceCtl control = new AuditPriceCtl(sqlTrans); control.Update(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 修改 /// </summary> public override void EntityUpdate() { AuditPriceRule rule = new AuditPriceRule(); AuditPrice entity = EntityGet(); AuditPriceDts[] entitydts = EntityDtsGet(); decimal ItemAmount = 0.00m;//计算原料总额 for (int i = 0; i < entitydts.Length; i++) { ItemAmount += entitydts[i].Amount; } entity.ItemAmount = ItemAmount; entity.PPrice = ItemAmount + entity.OthAmount; //原坯绞纱价格=原料总额+加工费 entity.SPrice = entity.PPrice + entity.ColorAmount; //原色绞纱价格=坯绞纱价格+染色费 entity.STPrice = entity.SPrice * (1 + entity.DTSHAmount / 100) + entity.DTAmount; //色筒纱价格=色绞纱价格*(1+倒筒损耗)+倒筒费 entity.SubmitFlag = this.HTSubmitFlagUpdateGet(); rule.RUpdate(entity, entitydts); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); AuditPrice entity = (AuditPrice)p_BE; AuditPriceCtl control = new AuditPriceCtl(sqlTrans); string sql = "DELETE FROM Sale_AuditPriceDts WHERE MainID=" + entity.ID.ToString(); sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据 control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private AuditPrice EntityGet() { AuditPrice entity = new AuditPrice(); entity.ID = HTDataID; entity.SelectByID(); entity.Code = txtCode.Text.Trim(); entity.ProductCode = txtProductCode.Text.Trim(); entity.ItemCode = SysConvert.ToString(drpItemCode.EditValue); entity.ItemName = txtItemName.Text.Trim(); entity.ItemStd = txtItemStd.Text.Trim(); entity.ItemModel = txtItemModel.Text.Trim(); entity.ProductName = txtProductName.Text.Trim(); entity.Equipment = txtEquipment.Text.Trim(); entity.ProductGY = txtProductGY.Text.Trim(); entity.ProductRSGY = txtProductRSGY.Text.Trim(); if (this.HTFormStatus == FormStatus.新增) { entity.MakeOPID = FParamConfig.LoginID; entity.MakeDate = txtMakeDate.DateTime.Date; } entity.JSOPID = SysConvert.ToString(drpJSOPID.EditValue); entity.SHOPID = SysConvert.ToString(drpSHOPID.EditValue); entity.Remark = txtRemark.Text.Trim(); entity.PPrice = SysConvert.ToDecimal(txtPPrice.Text.Trim()); entity.PDatetime = txtPDatetime.DateTime.Date; entity.SPrice = SysConvert.ToDecimal(txtSPrice.Text.Trim()); entity.SDatetime = txtSDatetime.DateTime.Date; entity.CompanyTypeID = SysConvert.ToInt32(drpCompanyTypeID.EditValue); entity.ItemAmount = SysConvert.ToDecimal(txtItemAmount.Text.Trim()); entity.OthAmount = SysConvert.ToDecimal(txtOthAmount.Text.Trim()); entity.ColorAmount = SysConvert.ToDecimal(txtColorAmount.Text.Trim()); entity.DTAmount = SysConvert.ToDecimal(txtDTAmount.Text.Trim()); entity.DTSHAmount = SysConvert.ToDecimal(txtDTSHAmount.Text.Trim()); entity.STPrice = SysConvert.ToDecimal(txtSTPrice.Text.Trim()); return(entity); }
/// <summary> /// 保存(传入事务处理) /// </summary> /// <param name="p_Entity"></param> /// <param name="p_BE"></param> /// <param name="sqlTrans"></param> public void RSave(AuditPrice p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { string sql = "DELETE FROM Sale_AuditPriceDts WHERE MainID=" + p_Entity.ID.ToString(); sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据 for (int i = 0; i < p_BE.Length; i++) { AuditPriceDts entitydts = (AuditPriceDts)p_BE[i]; sql = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM Sale_AuditPriceDts 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_BE"></param> private void CheckCorrect(BaseEntity p_BE) { AuditPrice entity = (AuditPrice)p_BE; }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { AuditPrice MasterEntity = (AuditPrice)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Sale_AuditPrice("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("Code" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ","); MasterField.Append("CompanyTypeID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CompanyTypeID) + ","); MasterField.Append("ProductCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProductCode) + ","); 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("ProductName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProductName) + ","); MasterField.Append("Equipment" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Equipment) + ","); MasterField.Append("ProductGY" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProductGY) + ","); MasterField.Append("ProductRSGY" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ProductRSGY) + ","); MasterField.Append("MakeOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPID) + ","); 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("JSOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.JSOPID) + ","); MasterField.Append("SHOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SHOPID) + ","); MasterField.Append("SubmitFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ","); MasterField.Append("DelFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("PPrice" + ","); if (MasterEntity.PPrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.PPrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("PDatetime" + ","); if (MasterEntity.PDatetime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.PDatetime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SPrice" + ","); if (MasterEntity.SPrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SPrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SDatetime" + ","); if (MasterEntity.SDatetime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.SDatetime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ItemAmount" + ","); if (MasterEntity.ItemAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ItemAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("OthAmount" + ","); if (MasterEntity.OthAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.OthAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ColorAmount" + ","); if (MasterEntity.ColorAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ColorAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("DTAmount" + ","); if (MasterEntity.DTAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.DTAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("DTSHAmount" + ","); if (MasterEntity.DTSHAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.DTSHAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("STPrice" + ")"); if (MasterEntity.STPrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.STPrice) + ")"); } 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 { AuditPrice MasterEntity = (AuditPrice)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Sale_AuditPrice SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ","); UpdateBuilder.Append(" CompanyTypeID=" + SysString.ToDBString(MasterEntity.CompanyTypeID) + ","); UpdateBuilder.Append(" ProductCode=" + SysString.ToDBString(MasterEntity.ProductCode) + ","); 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(" ProductName=" + SysString.ToDBString(MasterEntity.ProductName) + ","); UpdateBuilder.Append(" Equipment=" + SysString.ToDBString(MasterEntity.Equipment) + ","); UpdateBuilder.Append(" ProductGY=" + SysString.ToDBString(MasterEntity.ProductGY) + ","); UpdateBuilder.Append(" ProductRSGY=" + SysString.ToDBString(MasterEntity.ProductRSGY) + ","); UpdateBuilder.Append(" MakeOPID=" + SysString.ToDBString(MasterEntity.MakeOPID) + ","); 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(" JSOPID=" + SysString.ToDBString(MasterEntity.JSOPID) + ","); UpdateBuilder.Append(" SHOPID=" + SysString.ToDBString(MasterEntity.SHOPID) + ","); UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); if (MasterEntity.PPrice != 0) { UpdateBuilder.Append(" PPrice=" + SysString.ToDBString(MasterEntity.PPrice) + ","); } else { UpdateBuilder.Append(" PPrice=null,"); } if (MasterEntity.PDatetime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" PDatetime=" + SysString.ToDBString(MasterEntity.PDatetime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" PDatetime=null,"); } if (MasterEntity.SPrice != 0) { UpdateBuilder.Append(" SPrice=" + SysString.ToDBString(MasterEntity.SPrice) + ","); } else { UpdateBuilder.Append(" SPrice=null,"); } if (MasterEntity.SDatetime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" SDatetime=" + SysString.ToDBString(MasterEntity.SDatetime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" SDatetime=null,"); } if (MasterEntity.ItemAmount != 0) { UpdateBuilder.Append(" ItemAmount=" + SysString.ToDBString(MasterEntity.ItemAmount) + ","); } else { UpdateBuilder.Append(" ItemAmount=null,"); } if (MasterEntity.OthAmount != 0) { UpdateBuilder.Append(" OthAmount=" + SysString.ToDBString(MasterEntity.OthAmount) + ","); } else { UpdateBuilder.Append(" OthAmount=null,"); } if (MasterEntity.ColorAmount != 0) { UpdateBuilder.Append(" ColorAmount=" + SysString.ToDBString(MasterEntity.ColorAmount) + ","); } else { UpdateBuilder.Append(" ColorAmount=null,"); } if (MasterEntity.DTAmount != 0) { UpdateBuilder.Append(" DTAmount=" + SysString.ToDBString(MasterEntity.DTAmount) + ","); } else { UpdateBuilder.Append(" DTAmount=null,"); } if (MasterEntity.DTSHAmount != 0) { UpdateBuilder.Append(" DTSHAmount=" + SysString.ToDBString(MasterEntity.DTSHAmount) + ","); } else { UpdateBuilder.Append(" DTSHAmount=null,"); } if (MasterEntity.STPrice != 0) { UpdateBuilder.Append(" STPrice=" + SysString.ToDBString(MasterEntity.STPrice)); } else { UpdateBuilder.Append(" STPrice=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); } }