Esempio n. 1
0
    }//btn_Add_Click

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region

            if (CheckDetailIsExisted())
            {
                if (CurrentPageMode == PageCurrentMode.Insert || CurrentPageMode == PageCurrentMode.Edit)
                {
                    SaveCurrentGridviewValue();
                }

                //if (CheckDetailIsDuplicated())
                //{
                #region Variables
                string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
                DataTable dtTemp = (DataTable)Session[SessionIDName];

                TRNModel.VDS_TRN14_BCO BCO = new TRNModel.VDS_TRN14_BCO(ConnectionDB);
                string strErrMsg = "";
                bool bResult = false;

                //WUI.SLP.SLP_Route SLP_Route1;
                //WUI.SLP.SLPNumber SLP_SLPNumber1;
                //WUI.SLP.SLPNumber SLP_SLPNumber2;
                ArrayList ParameterList = new ArrayList();
                TRNModel.TRNCommon BCOCommon = new TRNModel.TRNCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                #endregion

                if (CurrentPageMode == PageCurrentMode.Insert)
                {
                    #region
                    try
                    {
                        //先把舊資料都刪除
                        ParameterList.Clear();
                        ParameterList = GetQueryParams();
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(Session["UID"].ToString());
                        BCO.DEL_CAL_MONTH_ROUTE(ParameterList, DBT);

                        #region 新增
                        for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++)
                        {
                            if (dtTemp.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //SLP_Route1 = (WUI.SLP.SLP_Route)GridView1.Rows[i].FindControl("SLP_Route1");
                                    //SLP_SLPNumber1 = (WUI.SLP.SLPNumber)GridView1.Rows[i].FindControl("SLP_SLPNumber1");
                                    //SLP_SLPNumber2 = (WUI.SLP.SLPNumber)GridView1.Rows[i].FindControl("SLP_SLPNumber2");
                                    ParameterList.Clear();
                                    ParameterList = GetQueryParams();
                                    //ParameterList.Add(SLP_Route1.Text);
                                    //ParameterList.Add(SLP_SLPNumber1.Text);
                                    //ParameterList.Add(SLP_SLPNumber2.Text);
                                    ParameterList.Add(dtTemp.Rows[i]["ROUTE"].ToString());
                                    ParameterList.Add(dtTemp.Rows[i]["ADD_STORE_CNT"].ToString());
                                    ParameterList.Add(dtTemp.Rows[i]["STORE_CNT"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.ADD_CAL_MONTH_ROUTE(ParameterList, DBT, out strErrMsg);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        #region 刪除
                        //DataTable dtDeleted = dtTemp.GetChanges(DataRowState.Deleted); ;

                        //if (dtDeleted != null)
                        //{
                        //    for (Int32 j = 0; j <= dtDeleted.Rows.Count - 1; j++)
                        //    {
                        //        if (bResult)
                        //        {
                        //            ParameterList.Clear();
                        //            ParameterList = GetQueryParams();
                        //            ParameterList.Add(dtDeleted.Rows[j]["ROUTE", DataRowVersion.Original].ToString());
                        //            ParameterList.Add(Session["UID"].ToString());
                        //            BCO.DEL_CAL_MONTH_ROUTE(ParameterList, DBT);
                        //        }
                        //        else
                        //        {
                        //            break;
                        //            DBT.Rollback();//交易失敗
                        //        }
                        //    }
                        //}
                        #endregion

                        DBT.Commit();//交易成功

                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        QueryData();
                        ErrorMsgLabel.Text = "新增成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                else if (CurrentPageMode == PageCurrentMode.Edit)
                {
                    #region
                    try
                    {
                        #region 修改
                        for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++)
                        {
                            if (dtTemp.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //SLP_Route1 = (WUI.SLP.SLP_Route)GridView1.Rows[i].FindControl("SLP_Route1");
                                    //SLP_SLPNumber1 = (WUI.SLP.SLPNumber)GridView1.Rows[i].FindControl("SLP_SLPNumber1");
                                    //SLP_SLPNumber2 = (WUI.SLP.SLPNumber)GridView1.Rows[i].FindControl("SLP_SLPNumber2");
                                    ParameterList.Clear();
                                    ParameterList = GetQueryParams();
                                    //ParameterList.Add(SLP_Route1.Text);
                                    //ParameterList.Add(SLP_SLPNumber1.Text);
                                    //ParameterList.Add(SLP_SLPNumber2.Text);
                                    ParameterList.Add(dtTemp.Rows[i]["ROUTE"].ToString());
                                    ParameterList.Add(dtTemp.Rows[i]["ADD_STORE_CNT"].ToString());
                                    ParameterList.Add(dtTemp.Rows[i]["STORE_CNT"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.UPDATE_CAL_MONTH_ROUTE(ParameterList, DBT, out strErrMsg);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        #region 刪除
                        DataTable dtDeleted = dtTemp.GetChanges(DataRowState.Deleted); ;

                        if (dtDeleted != null)
                        {
                            for (Int32 j = 0; j <= dtDeleted.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    ParameterList.Clear();
                                    ParameterList = GetQueryParams();
                                    ParameterList.Add(dtDeleted.Rows[j]["ROUTE", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_CAL_MONTH_ROUTE(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功

                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        QueryData();
                        ErrorMsgLabel.Text = "更新成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                //}
            }
            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel1.Update();
        }
        #endregion
    }//btn_Save_Click
Esempio n. 2
0
    }//btn_Add_Click

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region

            SaveCurrentGridviewValue();

            if (CheckDetailIsExisted())
            {
                //if (CheckDetailIsDuplicated())
                //{
                #region Variables
                TRNModel.VDS_TRN17_BCO BCO = new TRNModel.VDS_TRN17_BCO(ConnectionDB);
                string strErrMsg = "";
                string[] strAryTRANS_STEP_SELECTED = null;
                bool bResult = false;
                Int32 i32ID;
                ArrayList ParameterList = new ArrayList();
                TRNModel.TRNCommon BCOCommon = new TRNModel.TRNCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                #endregion

                if (CurrentPageMode == PageCurrentMode.Insert)
                {
                    #region
                    try
                    {
                        #region 新增
                        for (Int32 i = 0; i <= dtCAR.Rows.Count - 1; i++)
                        {
                            if (dtCAR.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //TRN_TRANS_CAR_MAIN
                                    ParameterList.Clear();
                                    ParameterList.Add(SLP_YearMonth1.Text);
                                    ParameterList.Add(dtCAR.Rows[i]["TRANS_NO"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["ST_ACCEPT_DATE"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["DRIVER_NAME"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["趟數"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["下站補貼"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["備註"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.ADD_TRN_TRANS_CAR_MAIN(ParameterList, DBT, out i32ID, out strErrMsg);

                                    strAryTRANS_STEP_SELECTED = dtCAR.Rows[i]["TRANS_STEP_SELECTED"].ToString().Split(";".ToCharArray());

                                    if (strAryTRANS_STEP_SELECTED != null && strAryTRANS_STEP_SELECTED.Length > 0)
                                    {
                                        for (Int32 j = 0; j <= strAryTRANS_STEP_SELECTED.GetUpperBound(0); j++)
                                        {
                                            if (strAryTRANS_STEP_SELECTED[j].ToString().Trim() != "")
                                            {
                                                //TRN_TRANS_CAR_DETL
                                                ParameterList.Clear();
                                                ParameterList.Add(i32ID);
                                                ParameterList.Add(SLP_YearMonth1.Text);
                                                ParameterList.Add(dtCAR.Rows[i]["TRANS_NO"].ToString());
                                                ParameterList.Add(dtCAR.Rows[i]["ST_ACCEPT_DATE"].ToString());
                                                ParameterList.Add(dtCAR.Rows[i]["DRIVER_NAME"].ToString());
                                                ParameterList.Add(strAryTRANS_STEP_SELECTED[j].ToString().Trim());
                                                ParameterList.Add(Session["UID"].ToString());
                                                bResult = BCO.ADD_TRN_TRANS_CAR_DETL(ParameterList, DBT, out strErrMsg);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功
                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        //bExecutedSuccessfully = true;
                        //QueryData();
                        //bExecutedSuccessfully = false;
                        //改寫的原因:隱藏控制項會不受控制地出現
                        Response.Redirect("TRN171.aspx?Code=TRN17&SHOWMSG=新增成功&CALMONTH=" + SLP_YearMonth1.Text + "&freshid=" + Guid.NewGuid().ToString());
                        ErrorMsgLabel.Text = "新增成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                else if (CurrentPageMode == PageCurrentMode.Edit)
                {
                    #region
                    try
                    {

                        bResult = true;

                        #region 刪除
                        DataTable dtDeleted_CAR = dtCAR.GetChanges(DataRowState.Deleted); ;
                        if (dtDeleted_CAR != null)
                        {
                            //DETL
                            for (Int32 j = 0; j <= dtDeleted_CAR.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    //TRN_TRANS_CAR_DETL
                                    ParameterList.Clear();
                                    ParameterList.Add(SLP_YearMonth1.Text);
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["ST_ACCEPT_DATE", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["DRIVER_NAME", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_TRN_TRANS_CAR_DETL(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }

                            //MAIN
                            for (Int32 j = 0; j <= dtDeleted_CAR.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(SLP_YearMonth1.Text);
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["ST_ACCEPT_DATE", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_CAR.Rows[j]["DRIVER_NAME", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_TRN_TRANS_CAR_MAIN(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        #region 修改
                        for (Int32 i = 0; i <= dtCAR.Rows.Count - 1; i++)
                        {
                            if (dtCAR.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //TRN_TRANS_CAR_MAIN
                                    ParameterList.Clear();
                                    ParameterList.Add(SLP_YearMonth1.Text);
                                    ParameterList.Add(dtCAR.Rows[i]["TRANS_NO"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["ST_ACCEPT_DATE"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["DRIVER_NAME"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["趟數"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["下站補貼"].ToString());
                                    ParameterList.Add(dtCAR.Rows[i]["備註"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.ADD_TRN_TRANS_CAR_MAIN(ParameterList, DBT, out i32ID, out strErrMsg);

                                    strAryTRANS_STEP_SELECTED = dtCAR.Rows[i]["TRANS_STEP_SELECTED"].ToString().Split(";".ToCharArray());

                                    if (strAryTRANS_STEP_SELECTED != null && strAryTRANS_STEP_SELECTED.Length > 0)
                                    {
                                        for (Int32 j = 0; j <= strAryTRANS_STEP_SELECTED.GetUpperBound(0); j++)
                                        {
                                            if (strAryTRANS_STEP_SELECTED[j].ToString().Trim() != "")
                                            {
                                                //TRN_TRANS_CAR_DETL
                                                ParameterList.Clear();
                                                ParameterList.Add(i32ID);
                                                ParameterList.Add(SLP_YearMonth1.Text);
                                                ParameterList.Add(dtCAR.Rows[i]["TRANS_NO"].ToString());
                                                ParameterList.Add(dtCAR.Rows[i]["ST_ACCEPT_DATE"].ToString());
                                                ParameterList.Add(dtCAR.Rows[i]["DRIVER_NAME"].ToString());
                                                ParameterList.Add(strAryTRANS_STEP_SELECTED[j].ToString().Trim());
                                                ParameterList.Add(Session["UID"].ToString());
                                                bResult = BCO.ADD_TRN_TRANS_CAR_DETL(ParameterList, DBT, out strErrMsg);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功

                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        //bExecutedSuccessfully = true;
                        //QueryData();
                        //bExecutedSuccessfully = false;
                        //改寫的原因:隱藏控制項會不受控制地出現
                        Response.Redirect("TRN171.aspx?Code=TRN17&SHOWMSG=更新成功&CALMONTH=" + SLP_YearMonth1.Text + "&freshid=" + Guid.NewGuid().ToString());
                        ErrorMsgLabel.Text = "更新成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                //}
            }
            #endregion
        }
        catch (Exception ex)
        {
            //2011/04/19 added
            gv_Car.DataSource = dtCAR;
            gv_Car.DataBind();
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ALL.Update();
        }
        #endregion
    }//btn_Save_Click
Esempio n. 3
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        TRNModel.TRNCommon BCOCommon = new TRNModel.TRNCommon();
        System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();

        try
        {

            String slp_dateHidden = SLP_DateHidden.Value;
            String slp_date = SLP_SearchDate.Text;


            int rowCounts = GridView1.Rows.Count;
            for (int i = 0; i < rowCounts; i++)
            {
                String v_ID = ((HtmlInputHidden)GridView1.Rows[i].Cells[4].FindControl("Id")).Value;

                DataTable dtOLD_DATA = (DataTable)Session["TRN041_" + PageTimeStamp.Value];
                DataRow[] FindRows = dtOLD_DATA.Select("ID='" + v_ID + "'");
                //String vOLD_ST_BACK_TYPE = Convert.ToString(((HtmlInputHidden)GridView1.Rows[i].Cells[4].FindControl("OLD_ST_BACK_TYPE")).Value);
                String vOLD_ST_BACK_TYPE = FindRows[0]["ST_BACK_TYPE"].ToString();
                String vST_BACK_TYPE = Convert.ToString(((DropDownList)GridView1.Rows[i].Cells[4].FindControl("ST_BACK_TYPE")).SelectedValue);

                //string vOLD_MAG_BOXNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_MAG_BOXNUM")).Value;
                string vOLD_MAG_BOXNUM = FindRows[0]["MAG_BOXNUM"].ToString();

                if (vOLD_MAG_BOXNUM == "0")
                    vOLD_MAG_BOXNUM = "";

                string vMAG_BOXNUM = "";
                if (GridView1.Columns[5].Visible == true)
                {
                    vMAG_BOXNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("MAG_BOXNUM")).Text;
                }
                else
                {
                    vMAG_BOXNUM = vOLD_MAG_BOXNUM;
                }
                if (vMAG_BOXNUM == "0")
                    vMAG_BOXNUM = "";


                //string vOLD_MAG_PAPERNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_MAG_PAPERNUM")).Value;
                string vOLD_MAG_PAPERNUM = FindRows[0]["MAG_PAPERNUM"].ToString();

                if (vOLD_MAG_PAPERNUM == "0")
                    vOLD_MAG_PAPERNUM = "";
                string vMAG_PAPERNUM = "";
                if (GridView1.Columns[6].Visible == true)
                {
                    vMAG_PAPERNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("MAG_PAPERNUM")).Text;
                }
                else
                {
                    vMAG_PAPERNUM = vOLD_MAG_PAPERNUM;
                }
                if (vMAG_PAPERNUM == "0")
                    vMAG_PAPERNUM = "";


                //string vOLD_BOOK_BOXNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_BOOK_BOXNUM")).Value;
                string vOLD_BOOK_BOXNUM = FindRows[0]["BOOK_BOXNUM"].ToString();

                if (vOLD_BOOK_BOXNUM == "0")
                    vOLD_BOOK_BOXNUM = "";
                string vBOOK_BOXNUM = "";
                if (GridView1.Columns[7].Visible == true)
                {
                    vBOOK_BOXNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("BOOK_BOXNUM")).Text;
                }
                else
                {
                    vBOOK_BOXNUM = vOLD_BOOK_BOXNUM;
                }
                if (vBOOK_BOXNUM == "0")
                    vBOOK_BOXNUM = "";


                //string vOLD_BOOK_PAPERNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_BOOK_PAPERNUM")).Value;
                string vOLD_BOOK_PAPERNUM = FindRows[0]["BOOK_PAPERNUM"].ToString();
                if (vOLD_BOOK_PAPERNUM == "0")
                    vOLD_BOOK_PAPERNUM = "";
                string vBOOK_PAPERNUM = "";
                if (GridView1.Columns[8].Visible == true)
                {
                    vBOOK_PAPERNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("BOOK_PAPERNUM")).Text;
                }
                else
                {
                    vBOOK_PAPERNUM = vOLD_BOOK_PAPERNUM;
                }
                if (vBOOK_PAPERNUM == "0")
                    vBOOK_PAPERNUM = "";


                //string vOLD_MANUAL_DRAYNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_MANUAL_DRAYNUM")).Value;
                string vOLD_MANUAL_DRAYNUM = FindRows[0]["MANUAL_DRAYNUM"].ToString();
                if (vOLD_MANUAL_DRAYNUM == "0")
                    vOLD_MANUAL_DRAYNUM = "";
                string vMANUAL_DRAYNUM = "";
                if (GridView1.Columns[9].Visible == true)
                {
                    vMANUAL_DRAYNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("MANUAL_DRAYNUM")).Text;
                }
                else
                {
                    vMANUAL_DRAYNUM = vOLD_MANUAL_DRAYNUM;
                }
                if (vMANUAL_DRAYNUM == "0")
                    vMANUAL_DRAYNUM = "";


                //string vOLD_MANUAL_BOXNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_MANUAL_BOXNUM")).Value;
                string vOLD_MANUAL_BOXNUM = FindRows[0]["MANUAL_BOXNUM"].ToString();
                if (vOLD_MANUAL_BOXNUM == "0")
                    vOLD_MANUAL_BOXNUM = "";
                string vMANUAL_BOXNUM = "";
                if (GridView1.Columns[9].Visible == true)
                {
                    vMANUAL_BOXNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("MANUAL_BOXNUM")).Text;
                }
                else
                {
                    vMANUAL_BOXNUM = vOLD_MANUAL_BOXNUM;
                }
                if (vMANUAL_BOXNUM == "0")
                    vMANUAL_BOXNUM = "";


                //string vOLD_COMIC_BOXNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_COMIC_BOXNUM")).Value;
                string vOLD_COMIC_BOXNUM = FindRows[0]["COMIC_BOXNUM"].ToString();
                if (vOLD_COMIC_BOXNUM == "0")
                    vOLD_COMIC_BOXNUM = "";
                string vCOMIC_BOXNUM = "";
                if (GridView1.Columns[10].Visible == true)
                {
                    vCOMIC_BOXNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("COMIC_BOXNUM")).Text;
                }
                else
                {
                    vCOMIC_BOXNUM = vOLD_COMIC_BOXNUM;
                }
                if (vCOMIC_BOXNUM == "0")
                    vCOMIC_BOXNUM = "";


                //string vOLD_COMIC_PAPERNUM = ((HtmlInputHidden)GridView1.Rows[i].FindControl("OLD_COMIC_PAPERNUM")).Value;
                string vOLD_COMIC_PAPERNUM = FindRows[0]["COMIC_PAPERNUM"].ToString();
                if (vOLD_COMIC_PAPERNUM == "0")
                    vOLD_COMIC_PAPERNUM = "";
                string vCOMIC_PAPERNUM = "";
                if (GridView1.Columns[11].Visible == true)
                {
                    vCOMIC_PAPERNUM = ((TextBox)GridView1.Rows[i].Cells[6].FindControl("COMIC_PAPERNUM")).Text;
                }
                else
                {
                    vCOMIC_PAPERNUM = vOLD_COMIC_PAPERNUM;
                }
                if (vCOMIC_PAPERNUM == "0")
                    vCOMIC_PAPERNUM = "";


                String vROUTE = GridView1.Rows[i].Cells[0].Text;
                String vSTORE = GridView1.Rows[i].Cells[2].Text;
                String vSTORE_NAME = GridView1.Rows[i].Cells[3].Text;

                if (v_ID.Equals("0"))
                {
                    //當 雜誌手開物流箱 > 0 or 雜誌手開紙箱 > 0 or 圖書手開物流箱 > 0 or 圖書手開紙箱 > 0 才需新增資料
                    if (
                        (vMAG_BOXNUM != "") ||
                        (vMAG_PAPERNUM != "") ||
                        (vBOOK_BOXNUM != "") ||
                        (vBOOK_PAPERNUM != "") ||
                        (vMANUAL_DRAYNUM != "") ||
                        (vMANUAL_BOXNUM != "") ||
                        (vCOMIC_BOXNUM != "") ||
                        (vCOMIC_PAPERNUM != "")
                       )
                    {
                        ParameterList.Clear();
                        ParameterList.Add(vSTORE);
                        ParameterList.Add(DateTime.Now);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(DateTime.Now);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(Convert.ToDateTime(slp_dateHidden));
                        ParameterList.Add(vSTORE);
                        ParameterList.Add(vSTORE_NAME);

                        if (vMAG_BOXNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vMAG_BOXNUM);

                        if (vMAG_PAPERNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vMAG_PAPERNUM);

                        if (vBOOK_BOXNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vBOOK_BOXNUM);

                        if (vBOOK_PAPERNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vBOOK_PAPERNUM);

                        ParameterList.Add(vST_BACK_TYPE);

                        if (vMANUAL_DRAYNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vMANUAL_DRAYNUM);

                        if (vMANUAL_BOXNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vMANUAL_BOXNUM);

                        if (vCOMIC_BOXNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vCOMIC_BOXNUM);

                        if (vCOMIC_PAPERNUM == "")
                            ParameterList.Add(DBNull.Value);
                        else
                            ParameterList.Add(vCOMIC_PAPERNUM);

                        int newID = bco.CreateTransBox(ParameterList, DBT);
                    }
                }
                else
                {
                    //當 有修改 雜誌手開物流箱 or 雜誌手開紙箱 or 圖書手開物流箱 or 圖書手開紙箱   時,才需修改資料
                    if ((vST_BACK_TYPE != vOLD_ST_BACK_TYPE) ||
                         (vMAG_BOXNUM != vOLD_MAG_BOXNUM) || (vMAG_PAPERNUM != vOLD_MAG_PAPERNUM) ||
                         (vBOOK_BOXNUM != vOLD_BOOK_BOXNUM) || (vBOOK_PAPERNUM != vOLD_BOOK_PAPERNUM) ||
                         (vMANUAL_DRAYNUM != vOLD_MANUAL_DRAYNUM) || (vMANUAL_BOXNUM != vOLD_MANUAL_BOXNUM) ||
                         (vCOMIC_BOXNUM != vOLD_COMIC_BOXNUM) || (vCOMIC_PAPERNUM != vOLD_COMIC_PAPERNUM)
                        )
                    {
                        //DataTable dt = bco.ConvertXMLToDataTable(VDS_TRN_BOXNUM.InnerHtml);
                        DataTable dt = (DataTable)Session["searchDt_" + PageTimeStamp.Value];
                        DataRow[] drs = dt.Select(string.Format("ID='{0}'", v_ID));
                        DataRow drOLD = drs[0];

                        ParameterList.Clear();

                        //舊的資料
                        ParameterList.Add(Convert.ToDateTime(drOLD["CREATEDATE"]));
                        ParameterList.Add(drOLD["CREATEUID"].ToString());
                        ParameterList.Add(Convert.ToDateTime(drOLD["UPDATEDATE"]));
                        ParameterList.Add(drOLD["UPDATEUID"].ToString());
                        ParameterList.Add(Convert.ToDateTime(drOLD["ST_BACK_DATE"]).ToString("yyyy/MM/dd"));
                        ParameterList.Add(drOLD["STORE"].ToString());
                        ParameterList.Add(drOLD["ST_BACK_TYPE"].ToString());

                        //新的資料         
                        ParameterList.Add(vSTORE);
                        ParameterList.Add(Convert.ToDateTime(slp_dateHidden));
                        ParameterList.Add(vSTORE);
                        ParameterList.Add(vSTORE_NAME);

                        ParameterList.Add(vMAG_BOXNUM);
                        ParameterList.Add(vMAG_PAPERNUM);
                        ParameterList.Add(vBOOK_BOXNUM);
                        ParameterList.Add(vBOOK_PAPERNUM);

                        ParameterList.Add(vST_BACK_TYPE);
                        ParameterList.Add(DateTime.Now);
                        ParameterList.Add(Session["UID"].ToString());

                        ParameterList.Add(vMANUAL_DRAYNUM);
                        ParameterList.Add(vMANUAL_BOXNUM);
                        ParameterList.Add(vCOMIC_BOXNUM);
                        ParameterList.Add(vCOMIC_PAPERNUM);

                        int id = bco.UpdateTransBox(ParameterList, DBT);
                    }
                }
            }

            DBT.Commit();//交易成功

            databind();
        }
        catch (Exception ex)
        {
            DBT.Rollback();//交易失敗

            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            SetPageStatus();
        }

    }
Esempio n. 4
0
    }//btn_Add_Click

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            SaveCurrentGridviewValue();
            try
            {
                #region



                if (CheckDetailIsExisted())
                {
                    //if (CheckDetailIsDuplicated())
                    //{
                    #region Variables
                    TRNModel.VDS_TRN15_BCO BCO = new TRNModel.VDS_TRN15_BCO(ConnectionDB);
                    string strErrMsg = "";
                    string strPK = "";
                    DataRow[] drAry = null;
                    bool bResult = false;
                    Int32 i32ID, i32ID_C;
                    ArrayList ParameterList = new ArrayList();
                    TRNModel.TRNCommon BCOCommon = new TRNModel.TRNCommon();
                    System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                    #endregion

                    if (CurrentPageMode == PageCurrentMode.Insert)
                    {
                        #region
                        try
                        {
                            #region 新增
                            for (Int32 i = 0; i <= dtFee.Rows.Count - 1; i++)
                            {
                                if (dtFee.Rows[i].RowState != DataRowState.Deleted)
                                {
                                    if (strErrMsg == "")
                                    {
                                        //TRN_OTHER_FEE
                                        ParameterList.Clear();
                                        ParameterList.Add(dtFee.Rows[i]["TRANS_NO"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["CAL_MONTH"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["BUS_DATE"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["ROUTE"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["SUBSIDY_NO"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["SUBSIDY_MONEY"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["MEMO"].ToString());
                                        ParameterList.Add(Session["UID"].ToString());
                                        bResult = BCO.ADD_TRN_OTHER_FEE(ParameterList, DBT, out i32ID, out strErrMsg);
                                    }
                                    else
                                    {
                                        break;
                                        DBT.Rollback();//交易失敗
                                    }
                                }
                            }
                            #endregion

                            DBT.Commit();//交易成功
                        }
                        catch (Exception ex)
                        {
                            DBT.Rollback();//交易失敗
                            throw ex;
                        }


                        if (bResult && strErrMsg == "")
                        {
                            CurrentPageMode = PageCurrentMode.Readonly;
                            SetControlsByCurrentPageMode();
                            QueryData();
                            ErrorMsgLabel.Text = "新增成功";
                        }
                        else
                        {
                            ErrorMsgLabel.Text = strErrMsg;
                        }
                        #endregion
                    }
                    else if (CurrentPageMode == PageCurrentMode.Edit)
                    {
                        #region
                        try
                        {

                            bResult = true;

                            #region 刪除
                            DataTable dtDeleted_FEE = dtFee.GetChanges(DataRowState.Deleted); ;
                            if (dtDeleted_FEE != null)
                            {
                                for (Int32 j = 0; j <= dtDeleted_FEE.Rows.Count - 1; j++)
                                {
                                    if (bResult)
                                    {
                                        ParameterList.Clear();
                                        ParameterList.Add(dtDeleted_FEE.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                        ParameterList.Add(dtDeleted_FEE.Rows[j]["CAL_MONTH", DataRowVersion.Original].ToString());
                                        ParameterList.Add(dtDeleted_FEE.Rows[j]["BUS_DATE", DataRowVersion.Original].ToString());
                                        ParameterList.Add(dtDeleted_FEE.Rows[j]["ROUTE", DataRowVersion.Original].ToString());
                                        ParameterList.Add(dtDeleted_FEE.Rows[j]["SUBSIDY_NO", DataRowVersion.Original].ToString());
                                        ParameterList.Add(Session["UID"].ToString());
                                        BCO.DEL_TRN_OTHER_FEE(ParameterList, DBT);
                                    }
                                    else
                                    {
                                        break;
                                        DBT.Rollback();//交易失敗
                                    }
                                }
                            }
                            #endregion

                            #region 修改
                            for (Int32 i = 0; i <= dtFee.Rows.Count - 1; i++)
                            {
                                if (dtFee.Rows[i].RowState != DataRowState.Deleted)
                                {
                                    if (strErrMsg == "")
                                    {
                                        //TRN_OTHER_FEE
                                        ParameterList.Clear();
                                        ParameterList.Add(dtFee.Rows[i]["TRANS_NO"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["CAL_MONTH"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["BUS_DATE"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["ROUTE"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["SUBSIDY_NO"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["SUBSIDY_MONEY"].ToString());
                                        ParameterList.Add(dtFee.Rows[i]["MEMO"].ToString());
                                        ParameterList.Add(Session["UID"].ToString());
                                        bResult = BCO.ADD_TRN_OTHER_FEE(ParameterList, DBT, out i32ID, out strErrMsg);
                                    }
                                    else
                                    {
                                        break;
                                        DBT.Rollback();//交易失敗
                                    }
                                }
                            }
                            #endregion

                            DBT.Commit();//交易成功

                        }
                        catch (Exception ex)
                        {
                            DBT.Rollback();//交易失敗
                            throw ex;
                        }


                        if (bResult && strErrMsg == "")
                        {
                            CurrentPageMode = PageCurrentMode.Readonly;
                            SetControlsByCurrentPageMode();
                            QueryData();
                            ErrorMsgLabel.Text = "更新成功";
                        }
                        else
                        {
                            ErrorMsgLabel.Text = strErrMsg;
                        }
                        #endregion
                    }
                    //}
                }
                #endregion
            }
            catch (Exception ex)
            {
                gv_Fee.DataSource = dtFee;
                gv_Fee.DataBind();
                ErrorMsgLabel.Text = ex.Message;
                UpdatePanel_ALL.Update();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ALL.Update();
        }
        #endregion
    }//btn_Save_Click
Esempio n. 5
0
    }//btn_Add_Click

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region

            CurrentEditingGridview = EditingGridview.None;

            SaveCurrentGridviewValue();

            if (CheckDetailIsExisted() && CheckDetailDataIntervalIsValid())//2011/04/29 add CheckDetailDataIntervalIsValid() for Checking Interval 
            {

                TRNModel.VDS_TRN13_BCO BCO = new TRNModel.VDS_TRN13_BCO(ConnectionDB);
                string strErrMsg = "";
                ArrayList ParameterList = new ArrayList();

                for (int i = 0; i <= dtRoute.Rows.Count - 1; i++)
                {
                    if (dtRoute.Rows[i].RowState != DataRowState.Deleted)
                    {
                        ParameterList.Clear();
                        ParameterList.Add(dtRoute.Rows[i]["TRANS_NO"].ToString());
                        ParameterList.Add(dtRoute.Rows[i]["ROUTE"].ToString());
                        DataTable dtUse = BCO.CHECK_ROUTE_USE(ParameterList);
                        if (dtUse.Rows.Count > 0)
                        {

                            strErrMsg += "[" + dtRoute.Rows[i]["ROUTE"].ToString() + "]路線已存在路線運費歸屬檔,運輸代碼= " + dtUse.Rows[0]["TRANS_NO"].ToString() + "中<BR>";

                        }

                    }
                }
                if (strErrMsg != "")
                {
                    ErrorMsgLabel.Text = strErrMsg;
                    return;
                }


                string strPK = "";
                DataRow[] drAry = null;
                bool bResult = false;
                Int32 i32PID, i32PID_C;

                TRNModel.TRNCommon BCOCommon = new TRNModel.TRNCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();




                if (CurrentPageMode == PageCurrentMode.Insert)
                {
                    #region
                    try
                    {
                        #region 新增
                        for (Int32 i = 0; i <= dtRoute.Rows.Count - 1; i++)
                        {
                            if (dtRoute.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //TRNAS_ROUTE_MAIN
                                    ParameterList.Clear();
                                    ParameterList.Add(dtRoute.Rows[i]["TRANS_NO"].ToString());
                                    ParameterList.Add(dtRoute.Rows[i]["ROUTE"].ToString());
                                    ParameterList.Add(dtRoute.Rows[i]["STATUS"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.ADD_TRANS_ROUTE_MAIN(ParameterList, DBT, out i32PID, out strErrMsg);

                                    for (Int32 k = 0; k <= dtPay.Rows.Count - 1; k++)
                                    {
                                        if (dtPay.Rows[k].RowState != DataRowState.Deleted)
                                        {
                                            //PAY_CODE
                                            ParameterList.Clear();
                                            ParameterList.Add(i32PID);
                                            ParameterList.Add(dtPay.Rows[k]["TRANS_NO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PAY_NO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PAY_MEMO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["START_DATE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["END_DATE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PRICE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["UNIT"].ToString());
                                            ParameterList.Add(Session["UID"].ToString());
                                            bResult = BCO.ADD_PAY_CODE(ParameterList, DBT, out i32PID_C, out strErrMsg);

                                            if (dtTransPayRoute != null)
                                            {
                                                strPK = string.Format("TRANS_NO = '{0}' and PAY_NO = '{1}'", dtRoute.Rows[i]["TRANS_NO"].ToString(), dtPay.Rows[k]["PAY_NO"].ToString());

                                                drAry = dtTransPayRoute.Select(strPK);

                                                if (drAry != null)
                                                {
                                                    for (Int32 m = 0; m <= drAry.GetUpperBound(0); m++)
                                                    {
                                                        //PAY_ROUTE
                                                        ParameterList.Clear();
                                                        ParameterList.Add(i32PID_C);
                                                        ParameterList.Add(drAry[m]["TRANS_NO"].ToString());
                                                        ParameterList.Add(drAry[m]["PAY_NO"].ToString());
                                                        ParameterList.Add(drAry[m]["ROUTE"].ToString());
                                                        ParameterList.Add(Session["UID"].ToString());
                                                        bResult = BCO.ADD_PAY_ROUTE(ParameterList, DBT, out strErrMsg);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功
                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        QueryData();
                        ErrorMsgLabel.Text = "新增成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                else if (CurrentPageMode == PageCurrentMode.Edit)
                {
                    #region
                    try
                    {

                        bResult = true;

                        #region 刪除
                        DataTable dtDeleted_ROUTE = dtRoute.GetChanges(DataRowState.Deleted); ;
                        DataTable dtDeleted_PAY = dtPay.GetChanges(DataRowState.Deleted); ;
                        DataTable dtDeleted_PAY_ROUTE = dtTransPayRoute.GetChanges(DataRowState.Deleted); ;

                        if (dtDeleted_PAY_ROUTE != null)
                        {
                            for (Int32 j = 0; j <= dtDeleted_PAY_ROUTE.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(dtDeleted_PAY_ROUTE.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_PAY_ROUTE.Rows[j]["PAY_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_PAY_ROUTE.Rows[j]["ROUTE", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_PAY_ROUTE(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }

                        if (dtDeleted_PAY != null)
                        {
                            for (Int32 j = 0; j <= dtDeleted_PAY.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(dtDeleted_PAY.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_PAY.Rows[j]["PAY_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_PAY_CODE(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        if (dtDeleted_ROUTE != null)
                        {
                            for (Int32 j = 0; j <= dtDeleted_ROUTE.Rows.Count - 1; j++)
                            {
                                if (bResult)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(dtDeleted_ROUTE.Rows[j]["TRANS_NO", DataRowVersion.Original].ToString());
                                    ParameterList.Add(dtDeleted_ROUTE.Rows[j]["ROUTE", DataRowVersion.Original].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    BCO.DEL_TRANS_ROUTE_MAIN(ParameterList, DBT);
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        #region 修改
                        for (Int32 i = 0; i <= dtRoute.Rows.Count - 1; i++)
                        {
                            if (dtRoute.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //TRNAS_ROUTE_MAIN
                                    ParameterList.Clear();
                                    ParameterList.Add(dtRoute.Rows[i]["TRANS_NO"].ToString());
                                    ParameterList.Add(dtRoute.Rows[i]["ROUTE"].ToString());
                                    ParameterList.Add(dtRoute.Rows[i]["STATUS"].ToString());
                                    ParameterList.Add(Session["UID"].ToString());
                                    bResult = BCO.ADD_TRANS_ROUTE_MAIN(ParameterList, DBT, out i32PID, out strErrMsg);

                                    for (Int32 k = 0; k <= dtPay.Rows.Count - 1; k++)
                                    {
                                        if (dtPay.Rows[k].RowState != DataRowState.Deleted)
                                        {
                                            //PAY_CODE
                                            ParameterList.Clear();
                                            ParameterList.Add(i32PID);
                                            ParameterList.Add(dtPay.Rows[k]["TRANS_NO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PAY_NO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PAY_MEMO"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["START_DATE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["END_DATE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["PRICE"].ToString());
                                            ParameterList.Add(dtPay.Rows[k]["UNIT"].ToString());
                                            ParameterList.Add(Session["UID"].ToString());
                                            bResult = BCO.ADD_PAY_CODE(ParameterList, DBT, out i32PID_C, out strErrMsg);

                                            if (dtTransPayRoute != null)
                                            {
                                                strPK = string.Format("TRANS_NO = '{0}' and PAY_NO = '{1}'", dtRoute.Rows[i]["TRANS_NO"].ToString(), dtPay.Rows[k]["PAY_NO"].ToString());

                                                drAry = dtTransPayRoute.Select(strPK);

                                                if (drAry != null)
                                                {
                                                    for (Int32 m = 0; m <= drAry.GetUpperBound(0); m++)
                                                    {
                                                        //PAY_ROUTE
                                                        ParameterList.Clear();
                                                        ParameterList.Add(i32PID_C);
                                                        ParameterList.Add(drAry[m]["TRANS_NO"].ToString());
                                                        ParameterList.Add(drAry[m]["PAY_NO"].ToString());
                                                        ParameterList.Add(drAry[m]["ROUTE"].ToString());
                                                        ParameterList.Add(Session["UID"].ToString());
                                                        bResult = BCO.ADD_PAY_ROUTE(ParameterList, DBT, out strErrMsg);
                                                    }
                                                }
                                            }
                                        }
                                    }


                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功

                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        CurrentPageMode = PageCurrentMode.Readonly;
                        SetControlsByCurrentPageMode();
                        QueryData();
                        ErrorMsgLabel.Text = "更新成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion
                }
                //}
            }
            #endregion
        }
        catch (Exception ex)
        {
            gv_Pay.DataSource = dtPay;
            gv_Pay.DataBind();

            gv_Route.DataSource = dtRoute;
            gv_Route.DataBind();

            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ALL.Update();
        }
        #endregion
    }//btn_Save_Click