private VendorNews[] GetVendorNews() { int Num = 0; for (int i = 0; i < gridView4.RowCount; i++) { if (SysConvert.ToString(gridView4.GetRowCellValue(i, "Item")) != string.Empty) { Num++; } } VendorNews[] entitydts = new VendorNews[Num]; int index = 0; for (int i = 0; i < gridView4.RowCount; i++) { if (SysConvert.ToString(gridView4.GetRowCellValue(i, "Item")) != string.Empty) { entitydts[index] = new VendorNews(); entitydts[index].MainID = HTDataID; entitydts[index].Seq = i + 1; entitydts[index].SelectByID(); entitydts[index].Item = SysConvert.ToString(gridView4.GetRowCellValue(i, "Item")); entitydts[index].ItemPrice = SysConvert.ToString(gridView4.GetRowCellValue(i, "ItemPrice")); index++; } } return(entitydts); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { VendorNews MasterEntity = (VendorNews)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_VendorNews WHERE " + "MainID=" + SysString.ToDBString(MasterEntity.MainID) + " AND Seq=" + SysString.ToDBString(MasterEntity.Seq); //执行 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_TableName">表名</param> /// <param name="p_FieldName">字段名</param> /// <param name="p_FieldValue">字段值</param> /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param> /// <param name="p_KeyValue">主键值</param> /// <param name="p_sqlTrans"></param> /// <returns></returns> private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans) { VendorNews entity = (VendorNews)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, VendorNews.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.MainID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { VendorNews MasterEntity = (VendorNews)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_VendorNews("); MasterValue.Append(" VALUES("); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); MasterField.Append("Item" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Item) + ","); MasterField.Append("ItemPrice" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemPrice) + ","); MasterField.Append("Remark" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ")"); //执行 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> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); VendorNews entity = (VendorNews)p_BE; VendorNewsCtl control = new VendorNewsCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { VendorNews MasterEntity = (VendorNews)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Data_VendorNews SET "); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" Item=" + SysString.ToDBString(MasterEntity.Item) + ","); UpdateBuilder.Append(" ItemPrice=" + SysString.ToDBString(MasterEntity.ItemPrice) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark)); UpdateBuilder.Append(" WHERE " + "MainID=" + SysString.ToDBString(MasterEntity.MainID) + " AND Seq=" + SysString.ToDBString(MasterEntity.Seq)); //执行 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 RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); VendorNews entity = (VendorNews)p_BE; VendorNewsCtl control = new VendorNewsCtl(sqlTrans); //entity.ID=(int)EntityIDTable.GetID((long)SysEntity.Data_VendorNews,sqlTrans); control.AddNew(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 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); } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { VendorNews entity = (VendorNews)p_BE; }