protected void Button1_Click(object sender, EventArgs e) { try { //if (lblErrQty.Text.Trim() != "0") //{ // ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' 檔案有異常資料 ');", true); // return; //} if (lblQty.Text.Trim() == "") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' 請先預覽欲轉入檔案 ');", true); return; } if (lblQty.Text.Trim() == "0")//正常筆數等於0 { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' 無正常資料可轉入 ');", true); return; } VGRModel.MaintainChanReturnData BCO = new PIC.VDS2G.LGT.VGR.MaintainChanReturnData(ConntionDB); string strBatchNo = ""; int iPID = 0; //================================================================================================ switch (Request["PageMode"]) { case "2": for (int i = 0; i < gv_Result.Rows.Count; i++) { ParameterList.Clear(); bool bl = true; //string strPID = ((Label)this.GridView1.Rows[i].FindControl("Label1")).Text; string strITEM = ((Label)this.gv_Result.Rows[i].FindControl("Label1")).Text; string strPERIOD = ((Label)this.gv_Result.Rows[i].FindControl("Label3")).Text; string strCREATEUID = Session["UID"].ToString(); string strUPDATEUID = Session["UID"].ToString(); //string strUPDATEDATE = ((Label)this.GridView1.Rows[i].FindControl("")).Text; //string strCREATEDATE = ((Label)this.GridView1.Rows[i].FindControl("")).Text; string strBACKWARD_QTY = ((Label)this.gv_Result.Rows[i].FindControl("Label6")).Text; string strCHAN_PRICE = ((Label)this.gv_Result.Rows[i].FindControl("Label4")).Text; string strChanEndDate = ((Label)this.gv_Result.Rows[i].FindControl("Label5")).Text; ParameterList.Clear(); if (Request.QueryString["ID"] != null) { ParameterList.Add(int.Parse(Request.QueryString["ID"].ToString())); } else { ParameterList.Add(int.Parse("999999")); } DataTable OldDt = BCO.QueryByID(ParameterList); foreach (DataRow dr in OldDt.Rows) { bl = true; if (dr["ITEM"].ToString() == strITEM && dr["PERIOD"].ToString() == strPERIOD && dr["BACKWARD_QTY"].ToString() != strBACKWARD_QTY) { ParameterList.Clear(); ParameterList.Add(int.Parse(Request.QueryString["ID"].ToString())); ParameterList.Add(strITEM); ParameterList.Add(strPERIOD); //ParameterList.Add(strCREATEUID); //ParameterList.Add(strUPDATEUID); //ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); //ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); ParameterList.Add(int.Parse(strBACKWARD_QTY)); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); BCO.UpdChanReturnData(ParameterList, DBT); bl = false; break; } else if (dr["ITEM"].ToString() == strITEM && dr["PERIOD"].ToString() == strPERIOD) { bl = false; break; } } if (bl) { //string strBatchNo = ""; //int iPID = 0; ParameterList.Clear(); ParameterList.Add(int.Parse(Request.QueryString["ID"].ToString())); ParameterList.Add(strITEM); ParameterList.Add(strPERIOD); ParameterList.Add(Decimal.Parse(strCHAN_PRICE)); ParameterList.Add(DateTime.Parse(strChanEndDate)); ParameterList.Add(int.Parse(strBACKWARD_QTY)); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); BCO.DoInsertDetl(ParameterList, DBT); } } Session["PageMode"] = "1"; break; case "3": //string strBatchNo = ""; //int iPID = 0; ParameterList.Clear(); ParameterList.Add(DateTime.Parse(Request.QueryString["BackWardDate"].ToString())); ParameterList.Add(DateTime.Parse(Request.QueryString["P_Date"].ToString())); //ParameterList.Add(Request.QueryString["ChanNo"].ToString()); //ParameterList.Add(Request.QueryString["Store"].ToString()); //ParameterList.Add(Request.QueryString["ChanSourceNo"].ToString()); ParameterList.Add(Session["StoreChain"].ToString()); ParameterList.Add(Session["Store"].ToString()); ParameterList.Add(Session["ChanSourceNo"].ToString()); ParameterList.Add("25"); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Parse(PageTimeStamp.Value)); BCO.CreateChanReturnData(ParameterList, dtForBrowse, DBT, Session["UID"].ToString(), DateTime.Parse(PageTimeStamp.Value), out strBatchNo, out iPID); //this.txtBatchNo.Text = strBatchNo; Session["PID"] = iPID.ToString(); Session["BatchNo"] = strBatchNo; Session["PageMode"] = "2"; Session["STATUS_EXPLAIN"] = "25"; #region ArrayList IDList = new ArrayList(); ArrayList Batch_NoList = new ArrayList(); ArrayList Chan_NoList = new ArrayList(); ArrayList Sign_DateList = new ArrayList(); ArrayList P_DATEList = new ArrayList(); ArrayList StoreList = new ArrayList(); ArrayList Chan_Source_NoList = new ArrayList(); ArrayList STATUS_EXPLAINList = new ArrayList(); ArrayList UPDATEDATEList = new ArrayList(); ArrayList UPDATEUIDList = new ArrayList(); IDList.Add(iPID.ToString()); Batch_NoList.Add(strBatchNo); Chan_NoList.Add(Session["StoreChain"].ToString()); Sign_DateList.Add(DateTime.Parse(Request.QueryString["BackWardDate"].ToString())); P_DATEList.Add(Request.QueryString["P_Date"].ToString()); StoreList.Add(Session["Store"].ToString()); Chan_Source_NoList.Add(Session["ChanSourceNo"].ToString()); STATUS_EXPLAINList.Add("25"); UPDATEDATEList.Add(DateTime.Parse(PageTimeStamp.Value).ToString("yyyyMMddHHmmssfffff")); UPDATEUIDList.Add(Session["UID"].ToString()); Session["VGR02QueryID"] = IDList; Session["VGR02QueryBatch_No"] = Batch_NoList; Session["VGR02QueryChan_No"] = Chan_NoList; Session["VGR02QuerySign_Date"] = Sign_DateList; Session["VGR02QueryP_DATE"] = P_DATEList; Session["VGR02QueryStore"] = StoreList; Session["VGR02QueryChan_Source_No"] = Chan_Source_NoList; Session["VGR02QuerySTATUS_EXPLAIN"] = STATUS_EXPLAINList; Session["VGR02QueryUPDATEDATE"] = UPDATEDATEList; Session["VGR02QueryUPDATEUID"] = UPDATEUIDList; #endregion break; default: break; } //================================================================================================ Response.Write("<script>window.returnValue= 'test';window.close();</script>"); //Response.Redirect(string.Format("VGR022.aspx?ID=" + iPID.ToString() + "&PageMode=1&Batch_No=" + strBatchNo + "&Chan_No=" + Session["StoreChain"].ToString() + "&Sign_Date=" + Request.QueryString["BackWardDate"].ToString() + "&P_DATE=" + Request.QueryString["P_Date"].ToString() + "&Store=" + Session["Store"].ToString() + "&Chan_Source_No=" + Session["ChanSourceNo"].ToString() + "&STATUS_EXPLAIN=" + "25" + "")); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
private void databind_Dtl() { try { string SessionIDName = "VGR02_DTL_" + PageTimeStamp.Value; VGRModel.MaintainChanReturnData BCO = new PIC.VDS2G.LGT.VGR.MaintainChanReturnData(ConntionDB); ParameterList.Clear(); if (Request.QueryString["ID"] != null) { ParameterList.Add(int.Parse(Request.QueryString["ID"].ToString())); } else if (Session["PID"] != null && Session["PID"].ToString() != "") { ParameterList.Add(int.Parse(Session["PID"].ToString())); } else { ParameterList.Add(int.Parse("999999")); } DataTable Dt = BCO.QueryByID(ParameterList); iDetlRowsCount = Dt.Rows.Count; Session[SessionIDName] = Dt; GridView1.DataSource = Dt; OldDt = Dt; dtForBrowse = Dt; GridView1.PageIndex = 0; GridView1.DataBind(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }