/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RSave(string p_OrderFormNo, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { FormNoControlRule rule = new FormNoControlRule(); string sql = "DELETE FROM Finance_PaymentHandle WHERE OrderFormNo =" + SysString.ToDBString(p_OrderFormNo); sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE)); sqlTrans.ExecuteNonQuery(sql); for (int i = 0; i < p_BE.Length; i++) { PaymentHandle entitydts = (PaymentHandle)p_BE[i]; if (entitydts.ID > 0) { this.RUpdate(entitydts, sqlTrans); } else { string FormNo = rule.RGetFormNo("Finance_PaymentHandle", "FormNo", sqlTrans); entitydts.FormNo = FormNo; this.RAdd(entitydts, sqlTrans); rule.RAddSort("Finance_PaymentHandle", "FormNo", 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, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SampleSODts entity = (SampleSODts)p_BE; SampleSODtsCtl control = new SampleSODtsCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Dev_SampleSODts, sqlTrans); //if (entity.DesignNo == string.Empty) //{ FormNoControlRule fnrule = new FormNoControlRule(); string formcode = fnrule.RGetFormNo("Dev_SampleSODts", "DesignNo", sqlTrans); entity.DesignNo = formcode; fnrule.RAddSort("Dev_SampleSODts", "DesignNo", 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 RAdd(int p_ID, decimal p_Qty, string p_OPID, IDBTransAccess sqlTrans) { try { PackBoxKPRule rule = new PackBoxKPRule(); PackBox entity = new PackBox(sqlTrans); entity.ID = p_ID; entity.SelectByID(); FormNoControlRule frule = new FormNoControlRule(); PackBoxKP pentity = new PackBoxKP(); pentity.FormNo = frule.RGetFormNo((int)FormNoControlEnum.开匹单号, sqlTrans); pentity.FormDate = DateTime.Now; pentity.MakeDate = DateTime.Now; pentity.MakeOPID = p_OPID; pentity.SaleOPID = p_OPID; pentity.KPOPID = p_OPID; pentity.BoxNo = entity.BoxNo; pentity.Qty = entity.Qty; pentity.TargetQty = p_Qty; rule.RAdd(pentity, sqlTrans); rule.RSubmit(pentity.ID, 1, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 扫描数据(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public int RScan(int p_ID, string p_ISN, int p_YPQty, string p_Vendorid, int p_ZHID, DateTime p_Time, IDBTransAccess sqlTrans) { int outi = 0; try { CheckForm entity = new CheckForm(sqlTrans); if (p_ID == 0) { FormNoControlRule prule = new FormNoControlRule(); //entity.FormCode = prule.RGetFormNo("ADH_CheckForm", "FormCode", sqlTrans); entity.FormCode = prule.RGetFormNo((int)FormNoControlEnum.样品报价单号); entity.DVendorID = p_Vendorid; entity.FormDate = DateTime.Now; entity.DataDHID = p_ZHID; entity.BJHL = 1; this.RAdd(entity, sqlTrans); outi = entity.ID; CheckFormDtsRule dtsrule = new CheckFormDtsRule(); dtsrule.RScan(entity.ID, p_ISN, p_YPQty, p_Time, sqlTrans); } else { outi = p_ID; entity.ID = p_ID; if (entity.SelectByID())//找到订货单 { if (entity.SubmitFlag == (int)YesOrNo.Yes) { throw new Exception("单据已完成,不能操作"); } CheckFormDtsRule dtsrule = new CheckFormDtsRule(); dtsrule.RScan(entity.ID, p_ISN, p_YPQty, p_Time, sqlTrans); } } //记录扫描历史 string sql = string.Empty; sql = "INSERT INTO ADH_ScanHis(ISN,DataDHID,DVendorID) VALUES(" + SysString.ToDBString(p_ISN) + "," + SysString.ToDBString(p_ZHID) + "," + SysString.ToDBString(p_Vendorid) + ")"; sqlTrans.ExecuteNonQuery(sql); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } return(outi); }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); PackBox entity = (PackBox)p_BE; PackBoxCtl control = new PackBoxCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WH_PackBox, sqlTrans); if (entity.BoxNo == string.Empty)//条码号不存在 { entity.CreateTime = DateTime.Now; FormNoControlRule rulest = new FormNoControlRule(); //处理生成箱号 entity.BoxNo = rulest.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans); rulest.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans); } else//已存在 { string sql = "SELECT BoxNo FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(entity.BoxNo); if (sqlTrans.Fill(sql).Rows.Count != 0)//条码号已存在,则生成新条码 { entity.CreateTime = DateTime.Now; FormNoControlRule rulest = new FormNoControlRule(); //处理生成箱号 entity.BoxNo = rulest.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans); rulest.RAddSort((int)FormNoControlEnum.码单箱号, 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 RSave(int p_ID, int p_MainID, int p_Seq, BaseEntity[] p_BE, bool p_UpdateFlag, IDBTransAccess sqlTrans) { try { string sql = ""; if (p_UpdateFlag) //修改状态下首先清除被删除的码单明细 { string idStr = string.Empty; //ID字符串 idStr = "0"; for (int i = 0; i < p_BE.Length; i++) { IOFormDtsPack entity = (IOFormDtsPack)p_BE[i]; if (entity.ID != 0)//有ID { if (idStr != string.Empty) { idStr += ","; } idStr += entity.ID.ToString(); } } if (idStr != string.Empty) { sql = "DELETE FROM WH_PackBox WHERE BoxNo IN (SELECT BoxNo FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ") )"; sqlTrans.ExecuteNonQuery(sql); //执行条形码删除 sql = "DELETE FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ")"; //WH_IOFormDtsPack WH_PackBox sqlTrans.ExecuteNonQuery(sql); } } else//新增状态 { sql = "SELECT TOP 1 ID FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("不能重复保存!"); } } IOForm p_Main = new IOForm(sqlTrans); p_Main.ID = p_MainID; p_Main.SelectByID(); IOFormDts p_MainDts = new IOFormDts(sqlTrans); p_MainDts.ID = p_ID; p_MainDts.SelectByID(); IOFormDtsPackRule rule = new IOFormDtsPackRule(); PackBoxRule Brule = new PackBoxRule(); decimal Qty = 0; decimal Weight = 0; decimal Yard = 0; decimal PieceQty = 0; for (int i = 0; i < p_BE.Length; i++) { FormNoControlRule frule = new FormNoControlRule(); IOFormDtsPack entity = (IOFormDtsPack)p_BE[i]; int boxNoCreateTypeID = 0;//箱号条码来源 if (entity.ID == 0) { if (entity.BoxNo == string.Empty)//没有箱号条码 { entity.BoxNo = frule.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans); rule.RAdd(entity, sqlTrans); frule.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans); } else//有箱号条码说明是验布产生的条码 { boxNoCreateTypeID = 1;//验布来源 } } else { rule.RUpdate(entity, sqlTrans); } PackBox entityBox = new PackBox(); if (entity.ID != 0)//仓库明细已生成,则寻找箱号ID 此处判断其实无意义,经过上面的代码肯定有ID值了 { sql = "SELECT ID FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(entity.BoxNo); DataTable dtPackBox = sqlTrans.Fill(sql); if (dtPackBox.Rows.Count != 0)//如果找到条码 { entityBox.ID = SysConvert.ToInt32(dtPackBox.Rows[0]["ID"]); } else//如果未找到条码 { entityBox.CreateSourceID = boxNoCreateTypeID;////原始条码表加个字段表示来源 0:表示入库录入 } } entityBox.BoxNo = entity.BoxNo; entityBox.WHID = p_MainDts.WHID; entityBox.SectionID = p_MainDts.SectionID; entityBox.SBitID = p_MainDts.SBitID; entityBox.ColorName = p_MainDts.ColorName; entityBox.ColorNum = p_MainDts.ColorNum; entityBox.CompanyTypeID = p_MainDts.CompanyTypeID; entityBox.GoodsCode = p_MainDts.GoodsCode; // entityBox.GoodsLevel = p_MainDts.GoodsLevel; entityBox.ItemCode = p_MainDts.ItemCode; entityBox.ItemModel = p_MainDts.ItemModel; entityBox.ItemName = p_MainDts.ItemName; entityBox.ItemStd = p_MainDts.ItemStd; entityBox.JarNum = p_MainDts.JarNum; entityBox.Batch = p_MainDts.Batch; entityBox.VendorBatch = p_MainDts.VendorBatch; entityBox.MWeight = p_MainDts.MWeight; entityBox.MWidth = p_MainDts.MWidth; entityBox.Qty = entity.Qty; entityBox.Weight = entity.Weight; entityBox.Yard = entity.Yard; entityBox.GoodsLevel = entity.GoodsLevel; entityBox.Unit = p_MainDts.Unit; entityBox.BoxStatusID = (int)EnumBoxStatus.未入库; entityBox.DID = p_ID; entityBox.InFormNo = p_Main.FormNo; entityBox.OrderFormNo = p_MainDts.DtsOrderFormNo; //合同号明细 entityBox.SubSeq = entity.SubSeq; //卷号 if (entityBox.ID == 0) //没有ID则新增 { Brule.RAdd(entityBox, sqlTrans); } else//有ID则修改 { Brule.RUpdate(entityBox, sqlTrans); } Qty += entity.Qty; Weight += entity.Weight; Yard += entity.Yard; PieceQty++; } //if (PieceQty == 0) //{ // throw new BaseException("请填写细码后点击保存"); //} sql = "UPDATE WH_IOFormDts SET Qty=" + SysString.ToDBString(Qty); sql += ",Weight=" + SysString.ToDBString(Weight); sql += ",Yard=" + SysString.ToDBString(Yard); sql += ",PieceQty=" + SysString.ToDBString(PieceQty); sql += ",PackFlag=1 "; sql += " WHERE ID=" + SysString.ToDBString(p_ID); sqlTrans.ExecuteNonQuery(sql); sql = "UPDATE WH_IOFormDts SET Amount=ISNULL(SinglePrice,0)*("; sql += "CASE"; sql += " WHEN Unit='RMB/KG' OR Unit='USD/KG' THEN ISNULL(Weight,0)"; sql += " WHEN Unit='RMB/Y' OR Unit='USD/Y' THEN ISNULL(Yard,0) "; sql += " WHEN Unit='RMB/M' OR Unit='USD/M' THEN ISNULL(Qty,0) "; sql += " ELSE 0 END)"; sql += " WHERE ID=" + SysString.ToDBString(p_ID); sqlTrans.ExecuteNonQuery(sql); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RAddLR(int HTDataID, IDBTransAccess sqlTrans) { try { string sql = "SELECT ID FROM Dev_GBJCLR WHERE DID=" + SysString.ToDBString(HTDataID); if (sqlTrans.Fill(sql).Rows.Count > 0) { throw new BaseException("已经同步,请撤销后再同步"); } GBJC entity = new GBJC(sqlTrans); entity.ID = HTDataID; entity.SelectByID(); sql = "SELECT * FROM Dev_GBJCDts WHERE MainID=" + SysString.ToDBString(HTDataID); sql += " AND ISNULL(LYVendorID,'')<>''"; DataTable dt = sqlTrans.Fill(sql); DataTable dtVendor = new DataTable(); dtVendor.Columns.Add("VendorID", typeof(string)); dtVendor.Columns.Add("GBCode", typeof(string)); for (int i = 0; i < dt.Rows.Count; i++) { string VendorIDStr = SysConvert.ToString(dt.Rows[i]["LYVendorID"]); string[] VendorID = VendorIDStr.Split(','); for (int j = 0; j < VendorID.Length; j++) { DataRow dr = dtVendor.NewRow(); dr["VendorID"] = VendorID[j].ToString(); dr["GBCode"] = SysConvert.ToString(dt.Rows[i]["GBCode"]); dtVendor.Rows.Add(dr); } } ArrayList list = new ArrayList(); for (int i = 0; i < dtVendor.Rows.Count; i++) { string VendorID = SysConvert.ToString(dtVendor.Rows[i]["VendorID"]); bool Find = false; for (int j = 0; j < list.Count; j++) { if (VendorID == list[j].ToString()) { Find = true; } } if (!Find) { list.Add(VendorID); } } for (int i = 0; i < list.Count; i++) { DataRow[] drVendor = dtVendor.Select(" VendorID=" + SysConvert.ToString(list[i])); FormNoControlRule frule = new FormNoControlRule(); GBJCLRRule rule = new GBJCLRRule(); GBJCLR entityLR = new GBJCLR(); entityLR.FormNo = frule.RGetFormNo((int)FormNoControlEnum.挂板借出录入单号, sqlTrans); entityLR.DID = HTDataID; entityLR.DNo = entity.FormNo; entityLR.MakeDate = entity.MakeDate; entityLR.MakeOPID = entity.MakeOPID; entityLR.SaleOPID = entity.SaleOPID; entityLR.VendorID = list[i].ToString(); entityLR.SubmitFlag = 1; entityLR.Remark = "自动回填,回填单号:" + entity.FormNo + ",日期:" + entity.MakeDate.ToString("yyyy-MM-dd"); rule.RAdd(entityLR, sqlTrans); frule.RAddSort((int)FormNoControlEnum.挂板借出录入单号, sqlTrans); for (int j = 0; j < drVendor.Length; j++) { GBJCLRDtsRule DRule = new GBJCLRDtsRule(); GBJCLRDts entityDts = new GBJCLRDts(sqlTrans); entityDts.MainID = entityLR.ID; entityDts.Seq = 1; entityDts.GBCode = SysConvert.ToString(drVendor[j]["GBCode"]); entityDts.JCTime = entity.MakeDate; entityDts.LYFlag = 1; DRule.RAdd(entityDts, sqlTrans); } } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }