/// <summary> /// 手动添加单据细表 /// </summary> /// <param name="infoTableName"></param> /// <param name="id"></param> /// <param name="bill"></param> /// <param name="product"></param> /// <param name="quantity"></param> /// <param name="isUpdate"></param> /// <param name="queryTable"></param> public void InsertDetail(string infoTableName, string id, string bill, string product, decimal quantity, bool isUpdate, string billDetailTable) { using (PersistentManager persistentManager = new PersistentManager()) { UpdateUploadDao dao = new UpdateUploadDao(); dao.SetPersistentManager(persistentManager); DataTable productTable = dao.ProductRate(product); decimal quan = Convert.ToDecimal(quantity * Convert.ToInt32(productTable.Rows[0]["JIANRATE"].ToString()) / Convert.ToInt32(productTable.Rows[0]["TIAORATE"].ToString())); if (isUpdate) { Thread.Sleep(500);//确保数据已经添加 //string sql = string.Format("SELECT ID FROM {2} WHERE PRODUCTCODE='{0}' AND BILLNO='{1}'", product, bill, billDetailTable); //string stokeId = dao.GetDate(sql).ToString(); DataTable table = dao.QueryBusiBill(infoTableName); DataRow newRow = table.NewRow(); newRow["STORE_BILL_DETAIL_ID"] = id; newRow["STORE_BILL_ID"] = bill.ToString().Trim(); newRow["BRAND_CODE"] = product; newRow["BRAND_NAME"] = this.QueryProduceName(product).ToString(); newRow["QUANTITY"] = quan; newRow["IS_IMPORT"] = "0"; newRow["BILL_TYPE"] = "1001"; table.Rows.Add(newRow); dao.InsertMaster(infoTableName, table); } else { string productname = this.QueryProduceName(product).ToString(); string sql = string.Format("UPDATE {0} SET STORE_BILL_ID='{1}',BRAND_CODE='{2}',BRAND_NAME='{3}',QUANTITY='{4}' WHERE STORE_BILL_DETAIL_ID='{5}'", infoTableName, bill, product, productname, Convert.ToDecimal(quan), id.ToString()); dao.UpdateTable(sql); } } }
/// <summary> /// 给上报中烟入库业务表插入数据 /// </summary> /// <param name="tableBull"></param> public void InsertBull(DataTable tableAllotDetail, string masterTableName, string detailTableName, string outInfoTabel, string employeeCode) { DataTable table = null; using (PersistentManager persistentManager = new PersistentManager()) { UpdateUploadDao dao = new UpdateUploadDao(); dao.SetPersistentManager(persistentManager); table = dao.QueryBusiBill(outInfoTabel); int s = 0; decimal quantity = 0.00M; string product = "1";//判断是否是同一个品牌 DataRow[] tableAllotDr = tableAllotDetail.Select("1=1", "PRODUCTCODE"); foreach (DataRow row in tableAllotDr) { s++; if (row["PRODUCTCODE"].ToString() != product) { quantity = 0.00M;//计算这个品牌分配的总数 } DataTable detailTable = dao.GetByOutInfo(row["BILLNO"].ToString(), row["PRODUCTCODE"].ToString(), detailTableName); DataTable masterTable = dao.GetByOutInfo(row["BILLNO"].ToString(), masterTableName); DataTable productStandArdrate = dao.ProductRate(row["PRODUCTCODE"].ToString()); //获取产品的比例STANDARDRATE string unitCode = dao.GetCellCodeCodeByName(row["CELLCODE"].ToString()); ///获取货位的单位 decimal pieceBarQuantity = dao.FindPieceQuantity(row["PRODUCTCODE"].ToString(), "0"); //查询原库存件的条数 decimal barQuantity = dao.FindBarQuantity(row["PRODUCTCODE"].ToString(), "1"); //查询原库存条的数量 decimal beginQuantity = pieceBarQuantity + barQuantity; //原库存 decimal endBarQuantity = 0.00M; //当前分配的数量 decimal endQuntity = 0.00M; //当前库存=原库存+当前分配数量 if (unitCode == productStandArdrate.Rows[0]["JIANCODE"].ToString()) //判断是件还是条,件就要转换,条不需要 { decimal endPieceQuantity = Convert.ToDecimal(row["QUANTITY"]) * Convert.ToDecimal(productStandArdrate.Rows[0]["JIANRATE"].ToString()); //把当前分配的数量转换为支 endBarQuantity = (Convert.ToDecimal(endPieceQuantity) / Convert.ToDecimal(productStandArdrate.Rows[0]["TIAORATE"].ToString())); //把当前分配的支转换条 quantity = quantity + endBarQuantity; } else { endBarQuantity = Convert.ToDecimal(row["QUANTITY"]); quantity = quantity + endBarQuantity; } if (outInfoTabel == "DWV_IWMS_OUT_BUSI_BILL") { endQuntity = beginQuantity - quantity;//出库减去 } else { endQuntity = beginQuantity + quantity;//入库加上 } DataRow newRow = table.NewRow(); newRow["BUSI_ACT_ID"] = DateTime.Now.ToString("yyMMddssff") + s; newRow["BUSI_BILL_DETAIL_ID"] = detailTable.Rows[0]["STORE_BILL_DETAIL_ID"].ToString(); newRow["BUSI_BILL_ID"] = row["BILLNO"]; newRow["RELATE_BUSI_BILL_ID"] = row["BILLNO"]; newRow["STORE_BILL_ID"] = row["BILLNO"]; newRow["BRAND_CODE"] = row["PRODUCTCODE"]; newRow["BRAND_NAME"] = detailTable.Rows[0]["BRAND_NAME"].ToString(); newRow["QUANTITY"] = endBarQuantity; newRow["DIST_CTR_CODE"] = "0101"; newRow["ORG_CODE"] = this.QueryOrgCode().ToString(); newRow["STORE_ROOM_CODE"] = "001"; newRow["STORE_PLACE_CODE"] = "1002"; newRow["TARGET_NAME"] = Convert.ToString(dao.GetCellCodeByName(row["CELLCODE"].ToString())); newRow["IN_OUT_TYPE"] = masterTable.Rows[0]["IN_OUT_TYPE"].ToString(); newRow["BILL_TYPE"] = masterTable.Rows[0]["BILL_TYPE"].ToString(); newRow["BEGIN_STOCK_QUANTITY"] = Convert.ToInt32(beginQuantity); newRow["END_STOCK_QUANTITY"] = Convert.ToInt32(endQuntity); newRow["DISUSE_STATUS"] = "0"; newRow["RECKON_STATUS"] = ""; newRow["RECKON_DATE"] = ""; newRow["UPDATE_CODE"] = "050000"; newRow["UPDATE_DATE"] = DateTime.Now.ToString("yyyyMMddHHmmss"); newRow["IS_IMPORT"] = "0"; table.Rows.Add(newRow); product = row["PRODUCTCODE"].ToString(); } dao.InsertBull(table, outInfoTabel); } }