private DataTable Get_CodeFile(string strCategory) { ParameterList.Clear(); SYSModel.MaintainCodeFile BCO = new SYSModel.MaintainCodeFile(ConntionDB); ParameterList.Add(strCategory); //Category ParameterList.Add(""); //_Code DataTable dt = BCO.QueryLineSwitch(SYSModel.MaintainCodeFile.QueryType.SLP, ParameterList); return dt; }
private void GetCodeFileData(string Code) { ParameterList.Clear(); SYSModel.MaintainCodeFile BCO = new SYSModel.MaintainCodeFile(ConntionDB); ParameterList.Add(Code); DataTable Dt = BCO.QueryLineSwitch(SYSModel.MaintainCodeFile.QueryType.CODE, ParameterList); if (Dt.Rows.Count > 0) foreach (DataRow dr in Dt.Rows) SLP_CodeFile3.Items.Add(new ListItem(dr["EXPLAIN"].ToString().Trim(), dr["SCODE"].ToString().Trim())); UpdatePanel5.Update(); }
public string CodeFileName(string Code, string Category ) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainCodeFile BCO = new MaintainCodeFile(ConnectionDBStr); if (Code != "") { ArrayList ParameterList = new ArrayList(); ParameterList.Add(Category); ParameterList.Add(Code); DataTable Dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP, ParameterList ); if (Dt.Rows.Count > 0) { Name = Dt.Rows[0]["EXPLAIN"].ToString().Trim(); } else { Name = "查無資料"; } } return Name; }
}//Initiziatoin_Component private DataTable Linedata() { ParameterList.Clear(); SYSModel.MaintainCodeFile BCO = new SYSModel.MaintainCodeFile(ConntionDB); ParameterList.Add(Category); ParameterList.Add(_Code); DataTable Dt = BCO.QueryLineSwitch(SYSModel.MaintainCodeFile.QueryType.SLP, ParameterList ); return Dt; }
}//ButtonNewLine2_Click /// <summary> /// 明細插入鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Btn_Insert_Click(object sender, EventArgs e) { DataTable Dt = new DataTable(); DataSet Ds = new DataSet(); DataTable Ds_detl = new DataTable(); if (dt_DetailOLDData != null) { Ds_detl = dt_DetailOLDData; } try { if (Ds_detl.Rows.Count == 0) //if (Ds.Tables.Count == 0) { //從DB讀取一空table回來 string SessionIDName = "SYS202_" + PageTimeStamp.Value; SYSModel.MaintainCodeFile BCO = new SYSModel.MaintainCodeFile(ConnectionDB); ParameterList.Clear(); Dt = BCO.QueryLineSwitch(SYSModel.MaintainCodeFile.QueryType.Empty, ParameterList); } else { Dt = Ds_detl;//Ds.Tables[0]; } tempID_dtl = 0; DataView tempDT = new DataView(); tempDT.Table = Dt.Copy(); tempDT.Sort = "ID ASC"; if (Dt.Rows.Count != 0) { tempID_dtl = Convert.ToInt32(tempDT[Dt.Rows.Count - 1]["ID"].ToString()); } //ID和PID暫自訂, 真正寫入CO時會重取 //LineItem畫面元件內容 string v_Code = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim(); string v_Scode = this.TextBoxScode_Uniq.Text.Trim(); string v_Explain = this.TextBoxExplain_Fvm.Text.Trim(); int v_PID = int.Parse(((TextBox)FormView1.FindControl("TextBoxID")).Text.Trim()); int v_ID = tempID_dtl + 1; //檢查SCODE 是否已存在Dt DataRow[] ins = Dt.Select(string.Format("SCODE='{0}'", v_Scode)); if (ins.Length <= 0) //1:已存在Dt 0:不存在Dt { DataRow dRow = Dt.NewRow(); dRow["ID"] = v_ID; dRow["PID"] = v_PID; dRow["CREATEDATE"] = DateTime.Now; dRow["UPDATEDATE"] = DateTime.Now; dRow["CREATEUID"] = Session["UID"]; dRow["UPDATEUID"] = Session["UID"]; dRow["ENABLE"] = "1"; dRow["CATEGORY"] = v_Code; dRow["SCODE"] = v_Scode; dRow["EXPLAIN"] = v_Explain; Dt.Rows.Add(dRow); } else { this.ShowErrorMessage("明細代碼重覆!"); } this.TextBoxScode_Uniq.Text = " "; this.TextBoxExplain_Fvm.Text = " "; this.PanelDetail.Visible = false; #region 使用XML放置到前端資料 dt_DetailOLDData = Dt; #endregion BindTempTable_Dtl(); this.ButtonNewLine.Visible = true; Dtl_Status = "readonly"; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } }
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(); } }