/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { CustomInvoiceDts MasterEntity = (CustomInvoiceDts)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Ship_CustomInvoiceDts 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_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RSubmit(Custom p_BE, IDBTransAccess sqlTrans) { try { if (p_BE.SubmitFlag == 0) { p_BE.SubmitFlag = 1; RUpdate(p_BE, sqlTrans); #region 自动产生清关文件 string sql = "SELECT MainID,Seq FROM Ship_CustomInvoiceDts WHERE MainID=" + p_BE.ID; //准备明细数据源 DataTable dtdts1 = sqlTrans.Fill(sql); //准备明细数据源 string sqlcheck = "SELECT ID FROM Ship_Custom WHERE InvoiceNo=" + SysString.ToDBString(p_BE.InvoiceNo) + " AND CompanyTypeID=3"; DataTable dtcheck = sqlTrans.Fill(sqlcheck); //检查是否已经自动产生了清关文件 if (dtcheck.Rows.Count == 0) //没有产生的情况下才执行 { p_BE.CompanyTypeID = 3; p_BE.ID = 0; RAdd(p_BE, sqlTrans); foreach (DataRow dr in dtdts1.Rows)//增加发票明细 { CustomInvoiceDts entitydts1 = new CustomInvoiceDts(sqlTrans); entitydts1.MainID = SysConvert.ToInt32(dr["MainID"]); entitydts1.Seq = SysConvert.ToInt32(dr["Seq"]); entitydts1.SelectByID(); entitydts1.MainID = p_BE.ID; CustomInvoiceDtsRule ruledts1 = new CustomInvoiceDtsRule(); ruledts1.RAdd(entitydts1, sqlTrans); } //后面可以增加其他明细数据,代码和上面类似。。。 } #endregion } else { throw new Exception("单据不是未提交状态请检查!"); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); CustomInvoiceDts entity = (CustomInvoiceDts)p_BE; CustomInvoiceDtsCtl control = new CustomInvoiceDtsCtl(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); CustomInvoiceDts entity = (CustomInvoiceDts)p_BE; CustomInvoiceDtsCtl control = new CustomInvoiceDtsCtl(sqlTrans); //entity.ID=(int)EntityIDTable.GetID((long)SysEntity.Ship_CustomDts,sqlTrans); control.AddNew(entity); } 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 { CustomInvoiceDts MasterEntity = (CustomInvoiceDts)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Ship_CustomInvoiceDts("); MasterValue.Append(" VALUES("); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); 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("PackPlanID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.PackPlanID) + ","); MasterField.Append("PackPlanCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.PackPlanCode) + ","); MasterField.Append("DSN" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DSN) + ","); MasterField.Append("SSN" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SSN) + ","); MasterField.Append("StyleNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.StyleNo) + ","); MasterField.Append("SStyleNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SStyleNo) + ","); MasterField.Append("Qty" + ","); if (MasterEntity.Qty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ICheckedQty" + ","); if (MasterEntity.ICheckedQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ICheckedQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ICheckedAmount" + ","); if (MasterEntity.ICheckedAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ICheckedAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ILeftQty" + ","); if (MasterEntity.ILeftQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ILeftQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ILeftAmount" + ","); if (MasterEntity.ILeftAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.ILeftAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Style" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Style) + ","); MasterField.Append("Unit" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Unit) + ","); MasterField.Append("Country" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Country) + ","); MasterField.Append("NetQty" + ","); if (MasterEntity.NetQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.NetQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ZM" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ZM) + ","); MasterField.Append("NetWeight" + ","); if (MasterEntity.NetWeight != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.NetWeight) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("GrossWeight" + ","); if (MasterEntity.GrossWeight != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.GrossWeight) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("USPrice" + ","); if (MasterEntity.USPrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.USPrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("BoxNum" + ","); if (MasterEntity.BoxNum != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.BoxNum) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Model" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Model) + ","); MasterField.Append("AmountUnit" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.AmountUnit) + ","); MasterField.Append("PCSUnit" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.PCSUnit) + ","); MasterField.Append("SinglePrice" + ","); if (MasterEntity.SinglePrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SinglePrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Amount" + ","); if (MasterEntity.Amount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Amount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SKAmount" + ","); if (MasterEntity.SKAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.SKAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SKDate" + ","); if (MasterEntity.SKDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.SKDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SKOP" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SKOP) + ","); MasterField.Append("QGSinglePrice" + ","); if (MasterEntity.QGSinglePrice != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.QGSinglePrice) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("QGAmount" + ","); if (MasterEntity.QGAmount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.QGAmount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("QGQty" + ","); if (MasterEntity.QGQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.QGQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("ColorNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ","); MasterField.Append("PieceQty" + ","); if (MasterEntity.PieceQty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.PieceQty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Volume" + ","); if (MasterEntity.Volume != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Volume) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MWidth" + ","); if (MasterEntity.MWidth != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MWeight" + ")"); if (MasterEntity.MWeight != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ")"); } 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 { CustomInvoiceDts MasterEntity = (CustomInvoiceDts)p_Entity; if (MasterEntity.MainID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Ship_CustomInvoiceDts SET "); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ","); UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ","); UpdateBuilder.Append(" ItemStd=" + SysString.ToDBString(MasterEntity.ItemStd) + ","); UpdateBuilder.Append(" PackPlanID=" + SysString.ToDBString(MasterEntity.PackPlanID) + ","); UpdateBuilder.Append(" PackPlanCode=" + SysString.ToDBString(MasterEntity.PackPlanCode) + ","); UpdateBuilder.Append(" DSN=" + SysString.ToDBString(MasterEntity.DSN) + ","); UpdateBuilder.Append(" SSN=" + SysString.ToDBString(MasterEntity.SSN) + ","); UpdateBuilder.Append(" StyleNo=" + SysString.ToDBString(MasterEntity.StyleNo) + ","); UpdateBuilder.Append(" SStyleNo=" + SysString.ToDBString(MasterEntity.SStyleNo) + ","); if (MasterEntity.Qty != 0) { UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ","); } else { UpdateBuilder.Append(" Qty=null,"); } if (MasterEntity.ICheckedQty != 0) { UpdateBuilder.Append(" ICheckedQty=" + SysString.ToDBString(MasterEntity.ICheckedQty) + ","); } else { UpdateBuilder.Append(" ICheckedQty=null,"); } if (MasterEntity.ICheckedAmount != 0) { UpdateBuilder.Append(" ICheckedAmount=" + SysString.ToDBString(MasterEntity.ICheckedAmount) + ","); } else { UpdateBuilder.Append(" ICheckedAmount=null,"); } if (MasterEntity.ILeftQty != 0) { UpdateBuilder.Append(" ILeftQty=" + SysString.ToDBString(MasterEntity.ILeftQty) + ","); } else { UpdateBuilder.Append(" ILeftQty=null,"); } if (MasterEntity.ILeftAmount != 0) { UpdateBuilder.Append(" ILeftAmount=" + SysString.ToDBString(MasterEntity.ILeftAmount) + ","); } else { UpdateBuilder.Append(" ILeftAmount=null,"); } UpdateBuilder.Append(" Style=" + SysString.ToDBString(MasterEntity.Style) + ","); UpdateBuilder.Append(" Unit=" + SysString.ToDBString(MasterEntity.Unit) + ","); UpdateBuilder.Append(" Country=" + SysString.ToDBString(MasterEntity.Country) + ","); if (MasterEntity.NetQty != 0) { UpdateBuilder.Append(" NetQty=" + SysString.ToDBString(MasterEntity.NetQty) + ","); } else { UpdateBuilder.Append(" NetQty=null,"); } UpdateBuilder.Append(" ZM=" + SysString.ToDBString(MasterEntity.ZM) + ","); if (MasterEntity.NetWeight != 0) { UpdateBuilder.Append(" NetWeight=" + SysString.ToDBString(MasterEntity.NetWeight) + ","); } else { UpdateBuilder.Append(" NetWeight=null,"); } if (MasterEntity.GrossWeight != 0) { UpdateBuilder.Append(" GrossWeight=" + SysString.ToDBString(MasterEntity.GrossWeight) + ","); } else { UpdateBuilder.Append(" GrossWeight=null,"); } if (MasterEntity.USPrice != 0) { UpdateBuilder.Append(" USPrice=" + SysString.ToDBString(MasterEntity.USPrice) + ","); } else { UpdateBuilder.Append(" USPrice=null,"); } if (MasterEntity.BoxNum != 0) { UpdateBuilder.Append(" BoxNum=" + SysString.ToDBString(MasterEntity.BoxNum) + ","); } else { UpdateBuilder.Append(" BoxNum=null,"); } UpdateBuilder.Append(" Model=" + SysString.ToDBString(MasterEntity.Model) + ","); UpdateBuilder.Append(" AmountUnit=" + SysString.ToDBString(MasterEntity.AmountUnit) + ","); UpdateBuilder.Append(" PCSUnit=" + SysString.ToDBString(MasterEntity.PCSUnit) + ","); if (MasterEntity.SinglePrice != 0) { UpdateBuilder.Append(" SinglePrice=" + SysString.ToDBString(MasterEntity.SinglePrice) + ","); } else { UpdateBuilder.Append(" SinglePrice=null,"); } if (MasterEntity.Amount != 0) { UpdateBuilder.Append(" Amount=" + SysString.ToDBString(MasterEntity.Amount) + ","); } else { UpdateBuilder.Append(" Amount=null,"); } if (MasterEntity.SKAmount != 0) { UpdateBuilder.Append(" SKAmount=" + SysString.ToDBString(MasterEntity.SKAmount) + ","); } else { UpdateBuilder.Append(" SKAmount=null,"); } if (MasterEntity.SKDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" SKDate=" + SysString.ToDBString(MasterEntity.SKDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" SKDate=null,"); } UpdateBuilder.Append(" SKOP=" + SysString.ToDBString(MasterEntity.SKOP) + ","); if (MasterEntity.QGSinglePrice != 0) { UpdateBuilder.Append(" QGSinglePrice=" + SysString.ToDBString(MasterEntity.QGSinglePrice) + ","); } else { UpdateBuilder.Append(" QGSinglePrice=null,"); } if (MasterEntity.QGAmount != 0) { UpdateBuilder.Append(" QGAmount=" + SysString.ToDBString(MasterEntity.QGAmount) + ","); } else { UpdateBuilder.Append(" QGAmount=null,"); } if (MasterEntity.QGQty != 0) { UpdateBuilder.Append(" QGQty=" + SysString.ToDBString(MasterEntity.QGQty) + ","); } else { UpdateBuilder.Append(" QGQty=null,"); } UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ","); if (MasterEntity.PieceQty != 0) { UpdateBuilder.Append(" PieceQty=" + SysString.ToDBString(MasterEntity.PieceQty) + ","); } else { UpdateBuilder.Append(" PieceQty=null,"); } if (MasterEntity.Volume != 0) { UpdateBuilder.Append(" Volume=" + SysString.ToDBString(MasterEntity.Volume) + ","); } else { UpdateBuilder.Append(" Volume=null,"); } if (MasterEntity.MWidth != 0) { UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ","); } else { UpdateBuilder.Append(" MWidth=null,"); } if (MasterEntity.MWeight != 0) { UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight)); } else { UpdateBuilder.Append(" MWeight=null"); } 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> private void CheckCorrect(BaseEntity p_BE) { CustomInvoiceDts entity = (CustomInvoiceDts)p_BE; }
/// <summary> /// 保存(传入事务处理) /// </summary> /// <param name="p_Entity"></param> /// <param name="p_BE"></param> /// <param name="sqlTrans"></param> public void RSave(Custom p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { string sql = "DELETE FROM Ship_CustomInvoiceDts WHERE MainID=" + p_Entity.ID.ToString(); sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据 // sql = "DELETE FROM Ship_CustomDts WHERE MainID=" + p_Entity.ID.ToString(); //sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据 for (int i = 0; i < p_BE.Length; i++) { CustomInvoiceDts entitydts = (CustomInvoiceDts)p_BE[i]; sql = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM Ship_CustomInvoiceDts 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); //sql = " UPDATE Ship_Ship_PackPlan Set LoadFlag=1 WHERE ID=" + entitydts.PackPlanID;//更新已加载标志 //sqlTrans.ExecuteNonQuery(sql); } /////根据保存汇总信息保存到 Ship_CustomDts中 //sql = "select Style,Model,MWidth,MWeight,Unit,SinglePrice,QGSinglePrice, SUM(Qty) Qty,SUM(Amount) Amount,SUM(QGQty) QGQty,SUM(QGAmount) QGAmount "; //sql += " ,SUM(Volume) Volume,SUM(GrossWeight) GrossWeight,SUM(NetWeight) NetWeight from Ship_CustomInvoiceDts where 1=1"; //sql += " AND MainID=" + p_Entity.ID; //sql += " Group By Style,Model,MWidth,MWeight,Unit,SinglePrice,QGSinglePrice"; //DataTable dtDts = sqlTrans.Fill(sql); //if (dtDts.Rows.Count != 0) //{ // CustomDtsRule ruleDts = new CustomDtsRule(); // for (int i = 0; i < dtDts.Rows.Count; i++) // { // CustomDts entityDts = new CustomDts(sqlTrans); // entityDts.MainID = p_Entity.ID; // entityDts.Seq = i + 1; // entityDts.Style = SysConvert.ToString(dtDts.Rows[i]["Style"]); // entityDts.Model = SysConvert.ToString(dtDts.Rows[i]["Model"]); // //entityDts.MWidth = SysConvert.ToString(dtDts.Rows[i]["MWidth"]); // //entityDts.MWeight = SysConvert.ToString(dtDts.Rows[i]["MWeight"]); // entityDts.Unit = SysConvert.ToString(dtDts.Rows[i]["Unit"]); // entityDts.SinglePrice = SysConvert.ToDecimal(dtDts.Rows[i]["SinglePrice"]); // //entityDts.QGSinglePrice = SysConvert.ToString(dtDts.Rows[i]["QGSinglePrice"]); // entityDts.Qty = SysConvert.ToInt32(dtDts.Rows[i]["Qty"]); // ruleDts.RAdd(entityDts, sqlTrans); // } //} } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }