private void ReLoadPrice() { try { if (txtStore.Text.Trim() != "" && txtSignDate.Text.Trim() != "" && this.ddlIOType.Text.Trim() != "") { MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB); DataTable dtPriceInfo = null; for (int i = 0; i < GridView1.Rows.Count; i++) { string strItem = GridView1.Rows[i].Cells[0].Text; string strPeriod = GridView1.Rows[i].Cells[2].Text; ArrayList parameterList = new ArrayList(); parameterList.Add(Session.SessionID); parameterList.Add(txtStore.Text); parameterList.Add(strItem); parameterList.Add(strPeriod); parameterList.Add(Convert.ToDateTime(txtSignDate.Text).ToString("yyyyMMdd")); if (int.Parse(ddlIOType.Text) == 24) parameterList.Add(31); else if (int.Parse(ddlIOType.Text) == 25) parameterList.Add(33); else parameterList.Add(int.Parse(ddlIOType.Text)); //dtPriceInfo = bco.GetPriceInfoList(true, parameterList); dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList); if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0") { ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString(); return; } if (i == 0) { string taxType, rootNo, isSchedule; rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString(); taxType = dtPriceInfo.Rows[0]["TaxType"].ToString(); int iPriceDiscountKind = int.Parse(dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString()); isSchedule = iPriceDiscountKind >= 64 ? "1" : "0"; InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString(); SLP_COL_DAYS.Text = InvoiceDateRange; rblTaxType.Text = taxType; txtRootNo.Text = rootNo; rblIsSchedule.Text = isSchedule; ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange; slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString(); } string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind; listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString(); listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString(); retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString(); srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString(); priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString(); DataRow[] dra = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", strItem, strPeriod)); dra[0]["Cost"] = srcCostPrice; dra[0]["Cost_Dis_Rate"] = decimal.Parse(listDisRate); dra[0]["Cost_Dis"] = decimal.Parse(listPrice); dra[0]["Price"] = decimal.Parse(retailPrice); dra[0]["PDKIND"] = int.Parse(priceDiscountKind); } DiffData.AcceptChanges(); } } catch(Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } }
protected void DoAddDetail() { try { txtCheckQty.Text = txtAdjQty.Text; MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB); DataTable dtPriceInfo = null; //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期 //並更新對應欄位的值 ArrayList parameterList = new ArrayList(); parameterList.Add(Session.SessionID); parameterList.Add(txtStore.Text); parameterList.Add(txtItem.Text); parameterList.Add(txtPeriod.Text); parameterList.Add(Convert.ToDateTime(txtSignDate.Text).ToString("yyyyMMdd")); if (int.Parse(ddlIOType.Text) == 24) parameterList.Add(31); else if (int.Parse(ddlIOType.Text) == 25) parameterList.Add(33); else parameterList.Add(int.Parse(ddlIOType.Text)); dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList); if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0") { ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString(); return; } if (GridView1.Rows.Count == 0) { string taxType, rootNo, isSchedule; rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString(); taxType = dtPriceInfo.Rows[0]["TaxType"].ToString(); int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); isSchedule = i >= 64 ? "1" : "0"; InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString(); SLP_COL_DAYS.Text = InvoiceDateRange; rblTaxType.Text = taxType; txtRootNo.Text = rootNo; rblIsSchedule.Text = isSchedule; ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange; slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString(); } else { if (RowMode == RowEditMode.Add) { int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); string isSchedule = i >= 64 ? "1" : "0"; if (dtPriceInfo.Rows[0]["RootNo"].ToString() + dtPriceInfo.Rows[0]["TaxType"].ToString() + isSchedule + dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey) { ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增"; return; } if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim()) { ErrorMsgLabel.Text = "檔期編號不同無法新增"; return; } } } //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫 //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice //品名 進貨數 退貨數 牌價折扣率 牌價 零售價 MaintainCodeFile BCO = new MaintainCodeFile(ConnectionDB); ArrayList parameters = new ArrayList(); DataTable dt = null; switch (RowMode) { case RowEditMode.Add: MaintainSKU sku = new MaintainSKU(ConnectionDB); ArrayList list = new ArrayList(); list.Add(txtItem.Text); DataTable dtItem = sku.QuerySKUByCode(list); string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString(); IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text); string stAcceptQty, backwardQty = ""; if (!dr.Read()) { stAcceptQty = "0"; backwardQty = "0"; } else { stAcceptQty = dr["ST_ACCEPT_QTY"].ToString(); backwardQty = dr["BACKWARD_QTY"].ToString(); } dr.Close(); string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind; listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString(); listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString(); retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString(); srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString(); priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString(); DataRow row = DiffData.NewRow(); row["Item"] = txtItem.Text; row["ITEM_NAME"] = itemName; row["Period"] = txtPeriod.Text; row["PSS_ST_ACCEPT_QTY"] = stAcceptQty; row["PSS_BACKWARD_QTY"] = backwardQty; row["DIFF_QTY"] = txtAdjQty.Text; if (txtCheckQty.Text.Length > 0) { row["CHECK_QTY"] = txtCheckQty.Text; } else { row["CHECK_QTY"] = System.DBNull.Value; } row["Cost"] = srcCostPrice; row["Cost_Dis_Rate"] = decimal.Parse(listDisRate); row["Cost_Dis"] = decimal.Parse(listPrice); row["Price"] = decimal.Parse(retailPrice); row["PDKIND"] = int.Parse(priceDiscountKind); if (txtReason.Text.Length > 0) { row["CHECK_REASON"] = txtReason.Text; } else { row["CHECK_REASON"] = System.DBNull.Value; } parameters.Add("1"); /* 1是原因判斷的Category */ parameters.Add(txtReason.Text); dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP, parameters ); row["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString(); DiffData.Rows.Add(row); break; case RowEditMode.Edit: DataRow[] dra = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); parameters.Add("1"); /* 1是原因判斷的Category */ parameters.Add(txtReason.Text); dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP, parameters ); if (txtReason.Text.Length > 0) { dra[0]["CHECK_REASON"] = txtReason.Text; } else { dra[0]["CHECK_REASON"] = System.DBNull.Value; } dra[0]["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString(); dra[0]["DIFF_QTY"] = txtAdjQty.Text; if (txtCheckQty.Text.Length > 0) { dra[0]["CHECK_QTY"] = txtCheckQty.Text; } else { dra[0]["CHECK_QTY"] = System.DBNull.Value; } break; } GridView1.DataSource = DiffData; GridView1.DataBind(); txtItem.Text = txtPeriod.Text = txtAdjQty.Text = txtCheckQty.Text = txtReason.Text = ""; pnlAddDiffItem1.Visible = false; btnAddDiffItem.Visible = true; } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }
//新增明細 protected void DoAddDetail() { try { if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text) || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text)) { ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值"; return; } if (RowMode == RowEditMode.Add) { DataRow[] dra1 = TransferItem.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); if (dra1.Length > 0) { ErrorMsgLabel.Text = "店號及期別不能重複"; return; } } MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB); DataTable dtPriceInfo = null; ArrayList parameterList = new ArrayList(); parameterList.Add(Session.SessionID); parameterList.Add(txtStore.Text); parameterList.Add(txtItem.Text); parameterList.Add(txtPeriod.Text); parameterList.Add(Convert.ToDateTime(slpTransferDate.Text).ToString("yyyyMMdd")); if (int.Parse(ddlIOType.Text) == 24) parameterList.Add(41); else if (int.Parse(ddlIOType.Text) == 25) parameterList.Add(42); else parameterList.Add(int.Parse(ddlIOType.Text)); dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList); if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0") { ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString(); return; } if (GridView1.Rows.Count == 0) { //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期 //並更新對應欄位的值 string taxType, rootNo, isSchedule; rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString(); taxType = dtPriceInfo.Rows[0]["TaxType"].ToString(); int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); isSchedule = i >= 64 ? "1" : "0"; InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString(); SLP_COL_DAYS.Text = InvoiceDateRange; rblTaxType.Text = taxType; txtRootNo.Text = rootNo; txtIsSchedule.Text = (isSchedule == "1" ? "檔期" : "非檔期"); ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange; slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString(); } else { if (RowMode == RowEditMode.Add) { int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString()); string isSchedule = i >= 64 ? "1" : "0"; if (dtPriceInfo.Rows[0]["RootNo"].ToString() + dtPriceInfo.Rows[0]["TaxType"].ToString() + isSchedule + dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey) { ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增"; return; } if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim()) { ErrorMsgLabel.Text = "檔期編號不同無法新增"; return; } } } //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫 //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice //品名 進貨數 退貨數 牌價折扣率 牌價 零售價 switch (RowMode) { case RowEditMode.Add: MaintainSKU sku = new MaintainSKU(ConnectionDB); ArrayList list = new ArrayList(); list.Add(txtItem.Text); DataTable dtItem = sku.QuerySKUByCode(list); string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString(); IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text); string stAcceptQty, backwardQty = ""; if (!dr.Read()) { stAcceptQty = "0"; backwardQty = "0"; } else { stAcceptQty = dr["ST_ACCEPT_QTY"].ToString(); backwardQty = dr["BACKWARD_QTY"].ToString(); } dr.Close(); string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind; listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString(); listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString(); retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString(); srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString(); priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString(); DataRow row = TransferItem.NewRow(); row["Item"] = txtItem.Text; row["Name"] = itemName; row["Period"] = txtPeriod.Text; row["ST_Accept_Qty"] = stAcceptQty; row["Backward_Qty"] = backwardQty; row["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text); row["Cost"] = srcCostPrice; row["Cost_Dis_Rate"] = decimal.Parse(listDisRate); row["Cost_Dis"] = decimal.Parse(listPrice); row["Price"] = decimal.Parse(retailPrice); row["PriceDiscountKind"] = int.Parse(priceDiscountKind); TransferItem.Rows.Add(row); break; case RowEditMode.Edit: DataRow[] dra = TransferItem.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text)); dra[0]["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text); break; } GridView1.DataSource = TransferItem; GridView1.DataBind(); txtItem.Text = txtPeriod.Text = txtAdjQty.Text = ""; pnlAddTransferItem1.Visible = false; btnAddTransferItem.Visible = true; ddlIOType.Enabled = false; ddlIOType.CssClass = "readtxtbox"; } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }