private void databind() { try { //抓取本頁初次登記的時間 SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session[SessionIDName] = null; PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); string v_PICK_CNT = "0"; string v_RESTRAIN_CNT = "0"; string vPICK_SELECT_1 = "0"; string vPICK_SELECT_2 = "0"; //固定傳 1 vPICK_SELECT_1 = "1"; vPICK_SELECT_2 = "1"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); ParameterList.Add(GetValueSetParameter(this.txtPLAN_ACCEPT_DATE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.txtPICK_BATCH.Text, "string", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_1, "int", false)); ParameterList.Add(GetValueSetParameter(vPICK_SELECT_2, "int", false)); ParameterList.Add(getDataType()); DataTable Dt = BCO.QueryDeliveryGoodsByFind_1(ParameterList, out v_PICK_CNT, out v_RESTRAIN_CNT); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; this.hid_PICK_CNT.Value = v_PICK_CNT; this.hid_RESTRAIN_CNT.Value = v_RESTRAIN_CNT; //將明細資料放至DetailDt中 detailTmpDt = Dt; //將空白的資料做處理 Dt = ProcessDBNull(Dt); #region 使用XML放置到前端資料 DataSet Ds = Dt.DataSet; DetailOLDData.InnerHtml = Ds.GetXml(); #endregion //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ErrorMsgLabel.Text = "查無資料"; LabelQueryRecordCount.Text = ""; } SetPageStatus(); UpdatePanel1.Update(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
private void LoadFromDate2() { if (hid_PageStatus.Text == "VIEW") LockControlChk();//對ControlChk鎖定編輯 DataTable Dt = (DataTable)Session["LoadFromDate1" + PageTimeStamp.Value]; DataTable dt_main_tmp = (DataTable)Session["dt_main_tmp" + PageTimeStamp.Value]; #region 移除匯入主檔品號、期別的通路管制資料 DataTable dt_Pick = (DataTable)Session[SessionIDName_Pick]; if (dt_Pick != null) if (dt_Pick.Rows.Count > 0) foreach (DataRow dr in Dt.Rows) { DataRow[] ddrs = dt_Pick.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (ddrs.Length > 0) foreach (DataRow drDetail in ddrs) dt_Pick.Rows.Remove(drDetail); } Session[SessionIDName_Pick] = dt_Pick; #endregion //2009/9/17 修改流程:「品項載入」後即可經由管制鈕的選擇而ENABLE「通路管制設定」鈕,所以要先Reset該DB的資料 //新增 ParameterList.Clear(); ParameterList.Add(txtPLAN_ACCEPT_DATE.Text); //匯入日期同主頁的進貨日 ParameterList.Add(txtPICK_BATCH.Text); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add("1"); // 2010/3/8 By Tony 新增資料來源條件:1:正常品 2:客服查補 3:正常品 + 客服查補(匯入的資料一律使用正常品) DateTime dNow = DateTime.Now; //CreateDetail、QuerySwitch使用統一的時間 PURModel.MaintainPurchaseDeliveryGoods BCO = new PURModel.MaintainPurchaseDeliveryGoods(ConnectionDB); //逐筆寫入未存在於主檔的資料 foreach (DataRow dr in Dt.Rows) BCO.CreateDetail(ParameterList, dr, null, dNow, "0"); //第二次查詢,為了找出BCO.CreateDetail後的Update資訊 string v_PICK_CNT = "0"; string v_RESTRAIN_CNT = "0"; ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int", false)); //0 N_ROWNUM ParameterList.Add(GetValueSetParameter(txtPLAN_ACCEPT_DATE.Text, "string", false)); //1 V_ST_ACCEPT_DATE ParameterList.Add(txtPICK_BATCH.Text); //2 V_PICK_BATCH ParameterList.Add(GetValueSetParameter("1", "int", false)); //3 N_PICK_SELECT_1 ParameterList.Add(GetValueSetParameter("1", "int", false)); //4 N_PICK_SELECT_2 ParameterList.Add("1"); //5 V_DATATYPE Dt = BCO.QueryDeliveryGoodsByFind_1(ParameterList, out v_PICK_CNT, out v_RESTRAIN_CNT); #region 製作新的原始資料 //處理DBNull的資料 Dt = ProcessDBNull(Dt); DataSet Ds = Dt.DataSet; DetailOLDData.InnerHtml = Ds.GetXml(); #endregion //復原理貨、管制的狀態(因異動理貨、管制鈕時並未存檔((只存在Session裏)) if (dt_main_tmp.Rows.Count > 0) foreach (DataRow dr in Dt.Rows) { DataRow[] drs = dt_main_tmp.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (drs.Length > 0) dr["Pick_Select"] = drs[0]["Pick_Select"]; } if (ButtonQuery.Visible) { btnSave.Visible = true; btnCancel.Visible = true; ButtonQuery.Visible = false; btnLoad.Visible = false; } SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); if (Session[SessionIDName] != "" && Session[SessionIDName] != null) { DataTable DetailDt = (DataTable)Session[SessionIDName]; DataRow[] drsDetail = DetailDt.Select("DataType='0'"); DataTable DtCopy = Dt.Copy(); foreach (DataRow dr in drsDetail) { DataRow[] drs = DtCopy.Select("VIRTUAL_CODE = '" + dr["VIRTUAL_CODE"].ToString() + "' and PERIOD = '" + dr["PERIOD"].ToString() + "'"); if (drs.Length == 0) Dt.ImportRow(dr); } } Session[SessionIDName] = Dt; GridView1.DataSource = Dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.DataBind(); if (hid_PageStatus.Text != "LOAD") hid_PageStatus.Text = "EDIT"; GridView1_Control(); UpdatePanel1.Update(); string outPick = "", outRestrain = ""; getGridPickCnt(out outPick, out outRestrain); LabelQueryRecordCount.Text = "品項數:理貨品:" + outPick + " 筆 管制品:" + outRestrain + " 筆 "; this.txtPLAN_ACCEPT_DATE.ReadOnly = true; this.txtPICK_BATCH.ReadOnly = true; this.txtPICK_BATCH.CssClass = "readtxtbox"; this.chkPICK_SELECT_1.Enabled = false; this.chkPICK_SELECT_2.Enabled = false; }