/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { VendorSaleOP MasterEntity = (VendorSaleOP)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_VendorSaleOP 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> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { VendorSaleOP MasterEntity = (VendorSaleOP)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Data_VendorSaleOP SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" OPID=" + SysString.ToDBString(MasterEntity.OPID) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); if (MasterEntity.ContactTime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" ContactTime=" + SysString.ToDBString(MasterEntity.ContactTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" ContactTime=null,"); } UpdateBuilder.Append(" ContactDts=" + SysString.ToDBString(MasterEntity.ContactDts) + ","); UpdateBuilder.Append(" DFContact=" + SysString.ToDBString(MasterEntity.DFContact) + ","); UpdateBuilder.Append(" HXTrack=" + SysString.ToDBString(MasterEntity.HXTrack) + ","); UpdateBuilder.Append(" FreeStr=" + SysString.ToDBString(MasterEntity.FreeStr)); 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> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); VendorSaleOP entity = (VendorSaleOP)p_BE; VendorSaleOPCtl control = new VendorSaleOPCtl(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); VendorSaleOP entity = (VendorSaleOP)p_BE; VendorSaleOPCtl control = new VendorSaleOPCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_VendorSaleOP, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获取客户业务归属 /// </summary> /// <returns></returns> private VendorSaleOP[] GetVendorSaleOP() { int Num = 0; for (int i = 0; i < gridView2.RowCount; i++) { if (SysConvert.ToString(gridView2.GetRowCellValue(i, "OPID")) != string.Empty) { Num++; } } VendorSaleOP[] entitydts = new VendorSaleOP[Num]; int index = 0; for (int i = 0; i < gridView2.RowCount; i++) { if (SysConvert.ToString(gridView2.GetRowCellValue(i, "OPID")) != string.Empty) { entitydts[index] = new VendorSaleOP(); entitydts[index].MainID = HTDataID; entitydts[index].Seq = i + 1; entitydts[index].SelectByID(); entitydts[index].OPID = SysConvert.ToString(gridView2.GetRowCellValue(i, "OPID")); entitydts[index].Remark = SysConvert.ToString(gridView2.GetRowCellValue(i, "Remark")); entitydts[index].ContactTime = SysConvert.ToDateTime(gridView2.GetRowCellValue(i, "ContactTime")); entitydts[index].ContactDts = SysConvert.ToString(gridView2.GetRowCellValue(i, "ContactDts")); entitydts[index].DFContact = SysConvert.ToString(gridView2.GetRowCellValue(i, "DFContact")); entitydts[index].HXTrack = SysConvert.ToString(gridView2.GetRowCellValue(i, "HXTrack")); entitydts[index].FreeStr = SysConvert.ToString(gridView2.GetRowCellValue(i, "FreeStr")); index++; } } return(entitydts); }
/// <summary> /// 处理客户归属业务员 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDealSaleOPID_Click(object sender, EventArgs e) { try { for (int i = 0; i < gridView1.RowCount; i++) { int p_ID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ID")); Vendor entity = new Vendor(); entity.ID = p_ID; entity.SelectByID(); if (entity.InSaleOP != "") { string sql = "Select * from Data_VendorSaleOP where OPID=" + SysString.ToDBString(entity.InSaleOP); sql += " AND MainID=" + entity.ID; DataTable dt = SysUtils.Fill(sql); if (dt.Rows.Count == 0) { VendorSaleOPRule rule = new VendorSaleOPRule(); VendorSaleOP entityOP = new VendorSaleOP(); entityOP.MainID = entity.ID; entityOP.OPID = entity.InSaleOP; entityOP.Remark = "自动添加"; rule.RAdd(entityOP); } } } this.ShowInfoMessage("处理完成!"); } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { VendorSaleOP MasterEntity = (VendorSaleOP)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_VendorSaleOP("); 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("OPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.OPID) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("ContactTime" + ","); if (MasterEntity.ContactTime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.ContactTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ContactDts" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ContactDts) + ","); MasterField.Append("DFContact" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DFContact) + ","); MasterField.Append("HXTrack" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.HXTrack) + ","); MasterField.Append("FreeStr" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.FreeStr) + ")"); //执行 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_BE"></param> private void CheckCorrect(BaseEntity p_BE) { VendorSaleOP entity = (VendorSaleOP)p_BE; }
/// <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, ArrayList p_BE6, BaseEntity[] p_BE7, BaseEntity[] p_BE8, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Vendor entity = (Vendor)p_BE; this.RUpdate(p_BE, sqlTrans); //VendorCtl control = new VendorCtl(sqlTrans); //control.Update(entity); string sql = "DELETE Data_VendorSaleOP WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorContact WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorAddress WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorNews WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorInvoiceDts WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); if (p_BE7.Length > 0) { sql = "DELETE Data_ItemAdd WHERE MainID=" + SysString.ToDBString(entity.ID); sql += " AND ISNULL(FormID,0)=" + SysString.ToDBString(((ItemAdd)p_BE7[0]).FormID); sql += " AND ISNULL(FormAID,0)=" + SysString.ToDBString(((ItemAdd)p_BE7[0]).FormAID); sql += " AND ISNULL(FormBID,0)=" + SysString.ToDBString(((ItemAdd)p_BE7[0]).FormBID); sqlTrans.ExecuteNonQuery(sql); } //新增客户联系人 for (int i = 0; i < p_BE2.Length; i++) { VendorContactRule rule = new VendorContactRule(); VendorContact entityVendorContact = (VendorContact)p_BE2[i]; entityVendorContact.MainID = entity.ID; entityVendorContact.Seq = i + 1; rule.RAdd(entityVendorContact, sqlTrans); } //新增客户归属业务员 for (int i = 0; i < p_BE3.Length; i++) { VendorSaleOPRule rule = new VendorSaleOPRule(); VendorSaleOP entityVendorSaleOP = (VendorSaleOP)p_BE3[i]; entityVendorSaleOP.MainID = entity.ID; entityVendorSaleOP.Seq = i + 1; rule.RAdd(entityVendorSaleOP, sqlTrans); } for (int i = 0; i < p_BE4.Length; i++) { VendorAddressRule rule = new VendorAddressRule(); VendorAddress entityVendorAddress = (VendorAddress)p_BE4[i]; entityVendorAddress.MainID = entity.ID; entityVendorAddress.Seq = i + 1; rule.RAdd(entityVendorAddress, sqlTrans); } for (int i = 0; i < p_BE5.Length; i++) { VendorNewsRule rule = new VendorNewsRule(); VendorNews entityVendorNews = (VendorNews)p_BE5[i]; entityVendorNews.MainID = entity.ID; entityVendorNews.Seq = i + 1; rule.RAdd(entityVendorNews, sqlTrans); } for (int i = 0; i < p_BE7.Length; i++) { ItemAddRule rule = new ItemAddRule(); ItemAdd entityItemAdd = (ItemAdd)p_BE7[i]; entityItemAdd.MainID = entity.ID; entityItemAdd.Seq = i + 1; rule.RAdd(entityItemAdd, sqlTrans); rule.UpdateFiledSet(entity.ID, entityItemAdd.FiledSetID, entityItemAdd.Value, sqlTrans); } for (int i = 0; i < p_BE8.Length; i++) { VendorInvoiceDtsRule rule = new VendorInvoiceDtsRule(); VendorInvoiceDts entityItemInvoice = (VendorInvoiceDts)p_BE8[i]; entityItemInvoice.MainID = entity.ID; entityItemInvoice.Seq = i + 1; rule.RAdd(entityItemInvoice, sqlTrans); } VendorTypeDtsRule vendortyperule = new VendorTypeDtsRule(); vendortyperule.RSave(p_BE, p_BE6, 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, BaseEntity[] p_BE4, BaseEntity[] p_BE5, ArrayList p_BE6, BaseEntity[] p_BE7, BaseEntity[] p_BE8, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Vendor entity = (Vendor)p_BE; this.RAdd(entity, sqlTrans); for (int i = 0; i < p_BE2.Length; i++) { VendorContactRule rule = new VendorContactRule(); VendorContact entityVendorContact = (VendorContact)p_BE2[i]; entityVendorContact.MainID = entity.ID; entityVendorContact.Seq = i + 1; rule.RAdd(entityVendorContact, sqlTrans); } //新增客户归属业务员 for (int i = 0; i < p_BE3.Length; i++) { VendorSaleOPRule rule = new VendorSaleOPRule(); VendorSaleOP entityVendorSaleOP = (VendorSaleOP)p_BE3[i]; entityVendorSaleOP.MainID = entity.ID; entityVendorSaleOP.Seq = i + 1; rule.RAdd(entityVendorSaleOP, sqlTrans); } for (int i = 0; i < p_BE4.Length; i++) { VendorAddressRule rule = new VendorAddressRule(); VendorAddress entityVendorAddress = (VendorAddress)p_BE4[i]; entityVendorAddress.MainID = entity.ID; entityVendorAddress.Seq = i + 1; rule.RAdd(entityVendorAddress, sqlTrans); } for (int i = 0; i < p_BE5.Length; i++) { VendorNewsRule rule = new VendorNewsRule(); VendorNews entityVendorNews = (VendorNews)p_BE5[i]; entityVendorNews.MainID = entity.ID; entityVendorNews.Seq = i + 1; rule.RAdd(entityVendorNews, sqlTrans); } for (int i = 0; i < p_BE7.Length; i++) { ItemAddRule rule = new ItemAddRule(); ItemAdd entityItemAdd = (ItemAdd)p_BE7[i]; entityItemAdd.MainID = entity.ID; entityItemAdd.Seq = i + 1; rule.RAdd(entityItemAdd, sqlTrans); rule.UpdateFiledSet(entity.ID, entityItemAdd.FiledSetID, entityItemAdd.Value, sqlTrans); } for (int i = 0; i < p_BE8.Length; i++) { VendorInvoiceDtsRule rule = new VendorInvoiceDtsRule(); VendorInvoiceDts entityItemInvoice = (VendorInvoiceDts)p_BE8[i]; entityItemInvoice.MainID = entity.ID; entityItemInvoice.Seq = i + 1; rule.RAdd(entityItemInvoice, sqlTrans); } VendorTypeDtsRule vendortyperule = new VendorTypeDtsRule(); vendortyperule.RSave(p_BE, p_BE6, sqlTrans); //FormNoControlRule fnrule = new FormNoControlRule(); //fnrule.RAddSort("Data_Vendor", "VendorID", entity.VendorTypeID, 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, ArrayList p_BE6, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Vendor entity = (Vendor)p_BE; this.RUpdate(p_BE, sqlTrans); //VendorCtl control = new VendorCtl(sqlTrans); //control.Update(entity); string sql = "DELETE Data_VendorSaleOP WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorContact WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorAddress WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); sql = "DELETE Data_VendorNews WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); //新增客户联系人 for (int i = 0; i < p_BE2.Length; i++) { VendorContactRule rule = new VendorContactRule(); VendorContact entityVendorContact = (VendorContact)p_BE2[i]; entityVendorContact.MainID = entity.ID; entityVendorContact.Seq = i + 1; rule.RAdd(entityVendorContact, sqlTrans); } //新增客户归属业务员 for (int i = 0; i < p_BE3.Length; i++) { VendorSaleOPRule rule = new VendorSaleOPRule(); VendorSaleOP entityVendorSaleOP = (VendorSaleOP)p_BE3[i]; entityVendorSaleOP.MainID = entity.ID; entityVendorSaleOP.Seq = i + 1; rule.RAdd(entityVendorSaleOP, sqlTrans); } for (int i = 0; i < p_BE4.Length; i++) { VendorAddressRule rule = new VendorAddressRule(); VendorAddress entityVendorAddress = (VendorAddress)p_BE4[i]; entityVendorAddress.MainID = entity.ID; entityVendorAddress.Seq = i + 1; rule.RAdd(entityVendorAddress, sqlTrans); } for (int i = 0; i < p_BE5.Length; i++) { VendorNewsRule rule = new VendorNewsRule(); VendorNews entityVendorNews = (VendorNews)p_BE5[i]; entityVendorNews.MainID = entity.ID; entityVendorNews.Seq = i + 1; rule.RAdd(entityVendorNews, sqlTrans); } VendorTypeDtsRule vendortyperule = new VendorTypeDtsRule(); vendortyperule.RSave(p_BE, p_BE6, 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, BaseEntity[] p_BE4, BaseEntity[] p_BE5, ArrayList p_BE6, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); Vendor entity = (Vendor)p_BE; this.RAdd(entity, sqlTrans); //string sql = "SELECT * FROM Data_Vendor WHERE VendorID="+SysString.ToDBString(entity.VendorID); //DataTable dt = sqlTrans.Fill(sql); //if (dt.Rows.Count > 0) //{ // throw new BaseException("客户编码已存在,请检查后重新输入"); //} //sql = "SELECT * FROM Data_Vendor WHERE VendorAttn=" + SysString.ToDBString(entity.VendorAttn); //dt = sqlTrans.Fill(sql); //if (dt.Rows.Count > 0) //{ // throw new BaseException("客户简称已存在,请检查后重新输入"); //} //sql = "SELECT * FROM Data_Vendor WHERE VendorName=" + SysString.ToDBString(entity.VendorName); //dt = sqlTrans.Fill(sql); //if (dt.Rows.Count > 0) //{ // throw new BaseException("客户全称已存在,请检查后重新输入"); //} //VendorCtl control = new VendorCtl(sqlTrans); //entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_Vendor, sqlTrans); //control.AddNew(entity); //新增客户联系人 for (int i = 0; i < p_BE2.Length; i++) { VendorContactRule rule = new VendorContactRule(); VendorContact entityVendorContact = (VendorContact)p_BE2[i]; entityVendorContact.MainID = entity.ID; entityVendorContact.Seq = i + 1; rule.RAdd(entityVendorContact, sqlTrans); } //新增客户归属业务员 for (int i = 0; i < p_BE3.Length; i++) { VendorSaleOPRule rule = new VendorSaleOPRule(); VendorSaleOP entityVendorSaleOP = (VendorSaleOP)p_BE3[i]; entityVendorSaleOP.MainID = entity.ID; entityVendorSaleOP.Seq = i + 1; rule.RAdd(entityVendorSaleOP, sqlTrans); } for (int i = 0; i < p_BE4.Length; i++) { VendorAddressRule rule = new VendorAddressRule(); VendorAddress entityVendorAddress = (VendorAddress)p_BE4[i]; entityVendorAddress.MainID = entity.ID; entityVendorAddress.Seq = i + 1; rule.RAdd(entityVendorAddress, sqlTrans); } for (int i = 0; i < p_BE5.Length; i++) { VendorNewsRule rule = new VendorNewsRule(); VendorNews entityVendorNews = (VendorNews)p_BE5[i]; entityVendorNews.MainID = entity.ID; entityVendorNews.Seq = i + 1; rule.RAdd(entityVendorNews, sqlTrans); } VendorTypeDtsRule vendortyperule = new VendorTypeDtsRule(); vendortyperule.RSave(p_BE, p_BE6, sqlTrans); //FormNoControlRule fnrule = new FormNoControlRule(); //fnrule.RAddSort("Data_Vendor", "VendorID", entity.VendorTypeID, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }