/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, BaseEntity[] p_BE3, BaseEntity[] p_BE4, BaseEntity[] p_BE5, int Flag, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Item entity = (Item)p_BE; string sql = "SELECT ItemCode FROM Data_Item WHERE ItemCode=" + SysString.ToDBString(entity.ItemCode); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("编码已存在,请重新生成"); } ItemCtl control = new ItemCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_Item, sqlTrans); control.AddNew(entity); ItemColorDtsRule rule2 = new ItemColorDtsRule(); rule2.RSave(entity, p_BE2, sqlTrans); ItemAddRule ruleItemAdd = new ItemAddRule(); for (int i = 0; i < p_BE3.Length; i++) { ItemAdd entityDts = (ItemAdd)p_BE3[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemAdd.RAdd(entityDts, sqlTrans); ruleItemAdd.UpdateFiledSet(entity.ID, entityDts.FiledSetID, entityDts.Value, sqlTrans); } ItemPicRule ruleItemPic = new ItemPicRule(); for (int i = 0; i < p_BE4.Length; i++) { ItemPic entityDts = (ItemPic)p_BE4[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemPic.RAdd(entityDts, sqlTrans); } ItemCodeFacDtsRule ruleItemCodeFac = new ItemCodeFacDtsRule(); for (int i = 0; i < p_BE5.Length; i++) { ItemCodeFacDts entityDts = (ItemCodeFacDts)p_BE5[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemCodeFac.RAdd(entityDts, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="p_BE3">原料</param> /// <param name="p_BE4">颜色</param> /// <param name="p_BE5">类别</param> /// <param name="p_BE6">物理指标</param> /// <param name="p_BE7">替代白坯</param> /// <param name="p_BE8">工厂编码及报价</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE3, BaseEntity[] p_BE4, BaseEntity[] p_BE5, BaseEntity[] p_BE6, BaseEntity[] p_BE7, BaseEntity[] p_BE8, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Item entity = (Item)p_BE; this.RUpdate(entity, sqlTrans); ItemDtsRule rule1 = new ItemDtsRule(); rule1.RSave(entity, p_BE3, sqlTrans); ItemColorDtsRule rule2 = new ItemColorDtsRule(); rule2.RSave(entity, p_BE4, sqlTrans); ItemLBDtsRule rule3 = new ItemLBDtsRule(); rule3.RSave(entity, p_BE5, sqlTrans); if (p_BE6 != null) { ItemCheckStandardPhyRule rule4 = new ItemCheckStandardPhyRule(); rule4.RSave(entity, p_BE6, sqlTrans); } if (p_BE7 != null) { ItemGreyFabReplaceRule rule4 = new ItemGreyFabReplaceRule(); rule4.RSave(entity, p_BE7, sqlTrans); } if (p_BE8 != null) { ItemCodeFacDtsRule rule5 = new ItemCodeFacDtsRule(); rule5.RSave(entity, p_BE8, 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 RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, BaseEntity[] p_BE3, BaseEntity[] p_BE4, BaseEntity[] p_BE5, int Flag, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Item entity = (Item)p_BE; string sql = "SELECT ItemCode FROM Data_Item WHERE ItemCode=" + SysString.ToDBString(entity.ItemCode) + " AND ID<>" + entity.ID; DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("编码已存在,请重新生成"); } ItemCtl control = new ItemCtl(sqlTrans); control.Update(entity); ItemColorDtsRule rule2 = new ItemColorDtsRule(); rule2.RSave(entity, p_BE2, sqlTrans); if (p_BE3.Length > 0) { sql = "DELETE Data_ItemAdd WHERE MainID=" + SysString.ToDBString(entity.ID); sql += " AND ISNULL(FormID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormID); sql += " AND ISNULL(FormAID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormAID); sql += " AND ISNULL(FormBID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormBID); sqlTrans.ExecuteNonQuery(sql); } ItemAddRule ruleItemAdd = new ItemAddRule(); for (int i = 0; i < p_BE3.Length; i++) { ItemAdd entityDts = (ItemAdd)p_BE3[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemAdd.RAdd(entityDts, sqlTrans); ruleItemAdd.UpdateFiledSet(entity.ID, entityDts.FiledSetID, entityDts.Value, sqlTrans); } sql = "DELETE Data_ItemPic WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); ItemPicRule ruleItemPic = new ItemPicRule(); for (int i = 0; i < p_BE4.Length; i++) { ItemPic entityDts = (ItemPic)p_BE4[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemPic.RAdd(entityDts, sqlTrans); } sql = "DELETE Data_ItemCodeFacDts WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); ItemCodeFacDtsRule ruleItemCodeFac = new ItemCodeFacDtsRule(); for (int i = 0; i < p_BE5.Length; i++) { ItemCodeFacDts entityDts = (ItemCodeFacDts)p_BE5[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemCodeFac.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 RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, BaseEntity[] p_BE3, BaseEntity[] p_BE4, int p_Flag, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Item entity = (Item)p_BE; string sql = "SELECT ItemCode FROM Data_Item WHERE ItemCode=" + SysString.ToDBString(entity.ItemCode) + " AND ID<>" + entity.ID; DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("编码已存在,请重新生成"); } ItemCtl control = new ItemCtl(sqlTrans); control.Update(entity); ItemColorDtsRule rule2 = new ItemColorDtsRule(); rule2.RSave(entity, p_BE2, sqlTrans); if (p_BE3.Length > 0) { sql = "DELETE Data_ItemAdd WHERE MainID=" + SysString.ToDBString(entity.ID); sql += " AND ISNULL(FormID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormID); sql += " AND ISNULL(FormAID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormAID); sql += " AND ISNULL(FormBID,0)=" + SysString.ToDBString(((ItemAdd)p_BE3[0]).FormBID); sqlTrans.ExecuteNonQuery(sql); } ItemAddRule ruleItemAdd = new ItemAddRule(); for (int i = 0; i < p_BE3.Length; i++) { ItemAdd entityDts = (ItemAdd)p_BE3[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemAdd.RAdd(entityDts, sqlTrans); ruleItemAdd.UpdateFiledSet(entity.ID, entityDts.FiledSetID, entityDts.Value, sqlTrans); } sql = "DELETE Data_ItemPic WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); ItemPicRule ruleItemPic = new ItemPicRule(); for (int i = 0; i < p_BE4.Length; i++) { ItemPic entityDts = (ItemPic)p_BE4[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; ruleItemPic.RAdd(entityDts, sqlTrans); } #region cost自动计算 entity = new Item(sqlTrans); entity.ID = ((Item)p_BE).ID; entity.SelectByID(); decimal Cost = 0; decimal PBPrice = entity.PBPrice;//坯价格 decimal RShrinkage = GetDecimalByString(entity.RShrinkage, '%'); decimal RSAmount = entity.RSAmount; decimal RSSH = GetDecimalByString(entity.RSSH, '%'); decimal JGAmount = entity.JGAmount; decimal JGSH = GetDecimalByString(entity.JGSH, '%'); decimal HZAmount = entity.HZAmount; decimal ProfitMargin = GetDecimalByString(entity.ProfitMargin, '%'); decimal Quot = GetDecimalByString(entity.COST, '/') * (1m + (ProfitMargin / 100m)); Cost = (((PBPrice * (1m + (RShrinkage / 100m)) + RSAmount) * (1m + (RSSH / 100m)) + JGAmount) * (1m + (JGSH / 100m)) + HZAmount) * 1.06m + 0.2m; Cost = SysConvert.ToDecimal(Cost, 2); //Quot = SysConvert.ToDecimal(Quot, 2); sql = "UPDATE Data_Item SET COSTA=" + SysString.ToDBString(Cost.ToString() + "/M"); //sql += ",QUOT="+SysString.ToDBString(Quot.ToString()+"/M"); sql += " WHERE ID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "UPDATE Data_ItemAdd SET Value=" + SysString.ToDBString(Cost.ToString() + "/M"); sql += " WHERE FiledName='COSTA'";// +SysString.ToDBString(entity.ID); sql += " AND MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); //sql = "UPDATE Data_ItemAdd SET Value=" + SysString.ToDBString(Quot.ToString() + "/M"); //sql += " WHERE FiledName='QUOT'";// +SysString.ToDBString(entity.ID); //sql += " AND MainID=" + SysString.ToDBString(entity.ID); //sqlTrans.ExecuteNonQuery(sql); #endregion } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }