}//Page_Load

    private void QueryData()
    {
        #region

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        DataTable Dt = new DataTable();
        ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);

        ArrayList ParameterList = new ArrayList();

        ParameterList.Clear();
        ParameterList.Add(SLP_SLPDate1.Text.Trim());
        ParameterList.Add(SLP_User1.Text.Trim());
        ParameterList.Add(txt_OldDisNo.Text.Trim());
        ParameterList.Add(SLP_SKU1.Text.Trim());
        ParameterList.Add(SLP_ItemPeriod1.Text.Trim());

        Dt = BCO.QueryCopyErrorRecord(ParameterList);

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();
        GridView1.SelectedIndex = -1;

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString());


        if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
        {
            ResultMsgLabel.Text = "查無資料";
            btn_Export.Enabled = false;
            //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
        }
        else 
        {
            btn_Export.Enabled = true;
        }

        #endregion
    }//QueryData
Пример #2
0
    /// <summary>
    /// 把值傳到Client端
    /// </summary>
    /// <returns></returns>
    public string GetCallbackResult()
    {
        #region

        string rtn = "", strResult = "";
        string strErrMsg = "";
        string[] strAryArg;
        try
        {
            ALOModel.QueryALOCommon BCO = new ALOModel.QueryALOCommon(ConnectionDB);
            ALOModel.MaintainDisCopy BCO2 = new ALOModel.MaintainDisCopy(ConnectionDB);

            s_CallServerData_STORE = "";

            if (ObjectFrom.IndexOf("ITEM") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());
                GetItemNameByItem(strAryArg[0]);
                rtn = string.Format("{0}-{1}", s_ITEM_NAME, s_PMA_NAME);
                #endregion
            }
            else if (ObjectFrom.IndexOf("STORE") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());

                s_STORE_NAME = "";
                s_STORE_OPEN_DATE = "";
                s_ROUTE = "";
                s_STEP = "";
                strErrMsg = "";

                if (strAryArg[1] != "")
                {
                    GetStorePOSetting(strAryArg[0], strAryArg[1]);

                    if (GetOpenDateByStore(strAryArg[0], strAryArg[1]))
                    {
                        if (!GetRouteStepByStore(strAryArg[0], strAryArg[1], strAryArg[2]))
                        {
                            strErrMsg = "此門市無有效路線路順";
                        }
                    }
                    else
                    {
                        strErrMsg = "無此門市資訊";
                    }
                }

                rtn = string.Format("{0}-{1}-{2}-{3}-{4}", s_STORE_NAME, s_STORE_OPEN_DATE, s_ROUTE, s_STEP, strErrMsg);
                #endregion
            }
            else if (ObjectFrom.IndexOf("CHAN") != -1)
            {
                #region
                GetChanPOSetting(CallServerValue);
                #endregion
            }
            else if (ObjectFrom.IndexOf("PERIOD") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());

                if (GetTaxType(strAryArg[0], strAryArg[1]))
                {
                    if (CheckItemPeriodIsDuplicated(strAryArg[0], strAryArg[1]))
                    {
                        if (GetItemPeriodStock(strAryArg[0], strAryArg[1]))
                        {
                            rtn = string.Format("{0}||{1}||{2}||X", i_ONHD_QTY, i_RESERVE_QTY, i_DIS_ENABLE);
                        }
                        else
                        {
                            rtn = string.Format("{0}||{1}||{2}||無可出庫商品,請輸入其他品項", i_ONHD_QTY, i_RESERVE_QTY, i_DIS_ENABLE);
                        }
                    }
                    else
                    {
                        rtn = string.Format("{0}||{1}||{2}||品號、期別重複輸入", i_ONHD_QTY, i_RESERVE_QTY, i_DIS_ENABLE);
                    }
                }
                else
                {
                    rtn = string.Format("{0}||{1}||{2}||無此期別,請輸入其他期別", i_ONHD_QTY, i_RESERVE_QTY, i_DIS_ENABLE);
                }
                #endregion
            }
            else if (ObjectFrom.IndexOf("PROCESSCONFIRM") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());

                rtn = ProcessConfirm(strAryArg[0], strAryArg[1]);
                #endregion
            }

            #region 附加相關控制項
            if (ObjectFrom.IndexOf("ITEM") != -1)
            {
                strAryArg = CallServerValue.Split(";".ToCharArray());
                strResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6};{7}",
                    strAryArg[1], strAryArg[2], strAryArg[3], strAryArg[4], strAryArg[5], strAryArg[6], strAryArg[7],
                            rtn);
            }
            else if (ObjectFrom.IndexOf("STORE") != -1)
            {
                strAryArg = CallServerValue.Split(";".ToCharArray());
                strResult = string.Format("{0}-{1}-{2}-{3};{4}",
                    strAryArg[3], strAryArg[4], strAryArg[5], strAryArg[6],
                    rtn);

                s_CallServerData_STORE = strResult;
            }
            else if (ObjectFrom.IndexOf("CHAN") != -1)
            {
                //不回傳值
            }
            else if (ObjectFrom.IndexOf("PERIOD") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());
                strResult = string.Format("{0}-{1}-{2}-{3};{4}", strAryArg[2], strAryArg[3], strAryArg[4], strAryArg[5], rtn);
                #endregion
            }
            else if (ObjectFrom.IndexOf("PROCESSCONFIRM") != -1)
            {
                //回傳結果格式為:
                //確認日期ClientID,確認按鈕ClientID,解除按鈕ClientID,結果訊息區ClientID,執行狀態隱藏欄位ClientID,確認日期,執行結果,執行狀態訊息
                strResult = rtn;
            }
            #endregion
        }
        catch (Exception ex)
        {
            throw ex;//直接拋出給前端處理
        }


        return strResult;
        #endregion
    }
Пример #3
0
    /// <summary>
    /// 把值傳到Client端
    /// </summary>
    /// <returns></returns>
    public string GetCallbackResult()
    {
        #region

        string rtn = "", strResult = "";
        string strErrMsg = "";
        Int32 iIncludeNonEffChecked = 0;
        Int32 iResult=0;
        Int32 iStAcceptQty = 0;
        Int32 iBackwardQty = 0;
        Int32 iRealMerit = 0;
        double iRealSalesRate = 0;

        string[] strAryArg;
        try
        {
            ALOModel.QueryALOCommon BCO = new ALOModel.QueryALOCommon(ConnectionDB);
            ALOModel.MaintainDisCopy BCO2 = new ALOModel.MaintainDisCopy(ConnectionDB);


            if (ObjectFrom.IndexOf("ITEM") != -1)
            {
                #region
                if (ObjectFrom.IndexOf("NAME") != -1)
                {
                    strAryArg = CallServerValue.Split(";".ToCharArray());
                    rtn = string.Format("{0}", GetItemNameByItem(strAryArg[0]));
                }
                else
                {
                    if (GetRootPmaPatternByItem(CallServerValue, out iIncludeNonEffChecked))
                        rtn = string.Format("{0}-{1}-{2}", "1", iIncludeNonEffChecked, s_PATTERN);
                    else
                        rtn = string.Format("{0}-{1}-{2}", "0", iIncludeNonEffChecked, s_PATTERN);
                }
                #endregion
            }
            else if (ObjectFrom.IndexOf("PERIOD") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());

                if (strAryArg[0].Trim() != "" && strAryArg[1].Trim() != "" && strAryArg[2].Trim() != "")
                {
                    s_ISS_DATE = "";
                    i_DIS_ISU_QTY = 0;
                    i_ONHD_QTY = 0;

                    if (GetItemPeriodDisStateByItemPeriod(strAryArg[0], strAryArg[1], strAryArg[2], out strErrMsg))
                        rtn = string.Format("{0}-{1}-{2}-{3}-{4}", "1", strErrMsg, s_ISS_DATE, i_DIS_ISU_QTY, i_ONHD_QTY);
                    else
                        rtn = string.Format("{0}-{1}-{2}-{3}-{4}", "0", strErrMsg, s_ISS_DATE, i_DIS_ISU_QTY, i_ONHD_QTY);

                }
                else 
                {
                    rtn = string.Format("{0}-{1}-{2}-{3}-{4}", "0", string.Format("(品號/品名,期別,門市進貨日)=({0},{1},{2})輸入不完整", strAryArg[0], strAryArg[1], strAryArg[2]), "", "", "");
                }

                #endregion
            }
            else if (ObjectFrom.IndexOf("PARAM") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());

                if (strAryArg[0] == "1")//要清除 dtDisItemRefer 
                {
                    //dtDisItemRefer.Clear();

                    for (Int32 i = dtDisItemRefer.Rows.Count - 1; i >= 0; i--)
                    {
                        dtDisItemRefer.Rows.RemoveAt(i);
                    }

                    hiddenDtDisItemReferCounts.Value = dtDisItemRefer.Rows.Count.ToString();

                    gv_ItemRefer.DataBind();
                    UpdatePanel1.Update();
                }

                if (GetDisParameter(strAryArg[1], out iResult))
                {
                    rtn = string.Format("{0}-{1}-{2}", "1", iResult, strAryArg[0]);
                }
                else
                {
                    rtn = string.Format("{0}-{1}-{2}", "0", iResult, strAryArg[0]);
                }

                #endregion
            }
            else if (ObjectFrom.IndexOf("DELETENEWGVROW") != -1)
            {
                #region
                dtDisItemRefer.Rows.RemoveAt(iEditingRowIndex);
                gv_ItemRefer.EditIndex = -1;
                gv_ItemRefer.DataSource = dtDisItemRefer;
                gv_ItemRefer.DataBind();

                if (dtDisItemRefer.Rows.Count <= 0) 
                {
                    dtDisItemRefer.Clear();
                }
                #endregion
            }
            else if (ObjectFrom.IndexOf("SALESINFO") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());
                if (strAryArg[0].Trim() != "" && strAryArg[1].Trim() != "")
                {
                    if (CheckDisItemAndDisItemReferIsAlreadyExisted(strAryArg[0], strAryArg[1]))
                    {
                        if (GetItemPeriodSalesInfo(strAryArg[0], strAryArg[1], out iStAcceptQty, out iBackwardQty, out iRealMerit, out iRealSalesRate))
                        {
                            rtn = string.Format("{0}||{1}||{2}||{3}||{4}||X", iStAcceptQty, iBackwardQty, iRealMerit, iRealSalesRate, GetItemReferRate());
                        }
                        else
                        {
                            rtn = string.Format("{0}||{1}||{2}||{3}||{4}||查無銷售實績,不可做為參考品項", iStAcceptQty, iBackwardQty, iRealMerit, iRealSalesRate, GetItemReferRate());
                        }
                    }
                    else
                    {
                        rtn = string.Format("{0}||{1}||{2}||{3}||{4}||參照品項不可與配本品項同期別或重複參照", iStAcceptQty, iBackwardQty, iRealMerit, iRealSalesRate, GetItemReferRate());
                    }
                }
                else 
                {
                    rtn = string.Format("{0}||{1}||{2}||{3}||{4}||(品號,期別)=({5},{6})輸入不完整", iStAcceptQty, iBackwardQty, iRealMerit, iRealSalesRate, GetItemReferRate(), strAryArg[0], strAryArg[1]);
                }
                #endregion
            }


            //附加相關控制項
            if (ObjectFrom.IndexOf("ITEM") != -1)
            {
                #region
                if (ObjectFrom.IndexOf("NAME") != -1)
                {
                    strAryArg = CallServerValue.Split(";".ToCharArray());
                    strResult = string.Format("{0}-{1};{2}",strAryArg[1],strAryArg[2],
                                rtn);
                }
                else
                {
                    strResult = string.Format("{0}-{1}-{2};{3}",
                        hiddenItemIsAvailable.ClientID,
                        ((CheckBox)SLP_Boolean1.FindControl("C1")).ClientID,
                        hiddenPatternNo.ClientID,
                        rtn);
                }
                #endregion
            }
            else if (ObjectFrom.IndexOf("PERIOD") != -1)
            {
                #region
                strResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6};{7}",
                    hiddenDisplayMode.ClientID,
                    Panel_AddNewItem.ClientID,
                    ((TextBox)SLP_SLPDate3.FindControl("TextBoxCode")).ClientID,
                    ((TextBox)SLP_SLPNumber1.FindControl("TextBoxCode")).ClientID,
                    ((TextBox)SLP_SLPNumber2.FindControl("TextBoxCode")).ClientID,
                    ((TextBox)SLP_PARAM1.FindControl("TextBoxCode")).ClientID,
                    ((TextBox)SLP_ItemPeriod1.FindControl("TextBoxCode")).ClientID,
                    rtn);
                #endregion
            }
            else if (ObjectFrom.IndexOf("PARAM") != -1)
            {
                #region
                strResult = string.Format("{0}-{1};{2}",
                    ((TextBox)SLP_PARAM1.FindControl("TextBoxCode")).ClientID,
                    hiddenItemReferCountAllowed.ClientID,
                    rtn);
                #endregion
            }
            else if (ObjectFrom.IndexOf("DELETENEWGVROW") != -1)
            {
                #region
                //無需回傳結果
                #endregion
            }
            else if (ObjectFrom.IndexOf("SALESINFO") != -1)
            {
                #region
                strAryArg = CallServerValue.Split(";".ToCharArray());
                strResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6};{7}", 
                    strAryArg[2], strAryArg[3], strAryArg[4], strAryArg[5], strAryArg[6], strAryArg[7], strAryArg[8], rtn);
                #endregion
            }
        }
        catch (Exception ex)
        {
            throw ex;//直接拋出給前端處理
        }
     
        
        return strResult;
        #endregion
    }
Пример #4
0
    /// <summary>
    ///回傳結果格式為:
    ///下一筆將要執行的RowIndex;要被關閉的動畫ClientID;要被開啟的動畫ClientID;CopyResultClientID-Processing結果值;NewDisNoClientID-NewDisNo值;ResultMsg;ProcessingErrCounts;最後一個執行列的hidden控制項ID
    /// </summary>
    /// <param name="iProcessingRowCallback">目前執行之RowIndex</param>
    /// <returns></returns>
    private string ProcessCopyDisRecordCallBack(Int32 iProcessingRowCallback)
    {
        #region

        string strCallBackResult = "";

        fmStatus = FormStatus.fmProcess;

        string strIDProcessing = "";
        string strUserID = Session["UID"].ToString();
        string strResultProcessing = "", strErrMsgProcessing = "";
        string strDynamicJs = "", strResultMsg = "", strNewDisNoProcessing = "";
        Int32 iErrCountProcessing = 0, iGvRowsCount = 0;
        bool bResult = false;
        iGvRowsCount = gv_Temp.Rows.Count;
        DataTable dtTemp = dtForMasterAndDetail;
        DataTable dtErr = null;
        System.Web.UI.HtmlControls.HtmlInputHidden hiddenToClose = null;
        System.Web.UI.HtmlControls.HtmlInputHidden hiddenToOpen = null;
        System.Web.UI.HtmlControls.HtmlInputHidden hiddenFinal = null;
        ArrayList ParameterList = new ArrayList();//20091113
        ArrayList ParameterList3 = new ArrayList();//20091113

        try
        {

            ALOModel.MaintainDisCopy BCO2 = new ALOModel.MaintainDisCopy(ConnectionDB);


            if (iProcessingRowCallback < iGvRowsCount && iGvRowsCount != 0)
            {
                strIDProcessing = ((Label)gv_Temp.Rows[iProcessingRowCallback].FindControl("lbl_ID")).Text;

                ParameterList.Clear();
                ParameterList.Add(strIDProcessing);
                ParameterList.Add(strUserID);
                ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

                switch (iProcessingRowCallback)
                {
                    #region
                    case 0:
                        hiddenToClose = hiddenDisplayModeProcessing0;
                        hiddenToOpen = hiddenDisplayModeProcessing1;
                        break;
                    case 1:
                        hiddenToClose = hiddenDisplayModeProcessing1;
                        hiddenToOpen = hiddenDisplayModeProcessing2;
                        break;
                    case 2:
                        hiddenToClose = hiddenDisplayModeProcessing2;
                        hiddenToOpen = hiddenDisplayModeProcessing3;
                        break;
                    case 3:
                        hiddenToClose = hiddenDisplayModeProcessing3;
                        hiddenToOpen = hiddenDisplayModeProcessing4;
                        break;
                    case 4:
                        hiddenToClose = hiddenDisplayModeProcessing4;
                        hiddenToOpen = null;
                        break;
                    #endregion
                }
                iErrCountProcessing = 0;
                bResult = BCO2.ProcessCopyDisRecord(ParameterList, ref strResultProcessing, ref strNewDisNoProcessing, ref strErrMsgProcessing, ref iErrCountProcessing, null);

                if (!bResult)
                {
                    iProcessingErrorCount = iProcessingErrorCount + 1;
                }
                else
                {
                    if (iErrCountProcessing > 0)
                        iProcessingErrorCount = iProcessingErrorCount + 1;  
                }

                //完成時筆數加1
                iProcessingRowCallback = iProcessingRowCallback + 1;

                if (iGvRowsCount == iProcessingRowCallback) //執行到最後一筆時
                {
                    #region

                    switch (iGvRowsCount)//取得最後一個控制項
                    {
                        case 1:
                            hiddenFinal = hiddenDisplayModeProcessing0;
                            break;
                        case 2:
                            hiddenFinal = hiddenDisplayModeProcessing1;
                            break;
                        case 3:
                            hiddenFinal = hiddenDisplayModeProcessing2;
                            break;
                        case 4:
                            hiddenFinal = hiddenDisplayModeProcessing3;
                            break;
                        case 5:
                            hiddenFinal = hiddenDisplayModeProcessing4;
                            break;
                    }

                    ParameterList3.Clear();
                    ParameterList3.Add(SLP_SLPDate1.Text);
                    ParameterList3.Add(strUserID);
                    ParameterList3.Add(PageTimeStamp.Value);

                    dtErr = BCO2.QueryCopyErrorCount(ParameterList3);

                    if (dtErr != null && dtErr.Rows.Count > 0)
                    {
                        if (dtErr.Rows[0][0].ToString() == "0")
                        {
                            strResultMsg = "複製完成無錯誤資料";
                        }
                        else
                        {
                            //iProcessingErrorCount = iProcessingErrorCount + 1;

                            strResultMsg = string.Format("複製完成,錯誤筆數{0}筆", iProcessingErrorCount);
                            btn_ErrorPop.Enabled = true;
                            Session["POP_ALOCopyError_ST_ACCEPT_DATE"] = SLP_SLPDate1.Text;
                            Session["POP_ALOCopyError_ExecuteID"] = Session["UID"].ToString();
                        }
                    }


                    //QueryData();//重新取得Processing資料

                    hiddenProcessingMsg.Value = strResultMsg;//ShowHiddenProcessingMsg();
                    #endregion
                }



                //組出結果字串:
                //下一筆將要執行的RowIndex;
                //要被關閉的動畫ClientID;
                //要被開啟的動畫ClientID;
                //CopyResultClientID-Processing結果值;
                //NewDisNoClientID-NewDisNo值;
                //ResultMsg;
                //ProcessingErrCounts;
                //最後一個執行列的hidden控制項ID
                strCallBackResult = string.Format("{0};{1};{2};{3}-{4};{5}-{6};{7};{8};{9}",
                    iProcessingRowCallback,
                    hiddenToClose == null ? "" : hiddenToClose.ClientID,
                    hiddenToOpen == null ? "" : hiddenToOpen.ClientID,
                    ((Label)gv_Temp.Rows[iProcessingRowCallback - 1].FindControl("lbl_COPY_RESULT_SHOW")).ClientID, strResultProcessing,
                    ((Label)gv_Temp.Rows[iProcessingRowCallback - 1].FindControl("lbl_NEW_DIS_NO")).ClientID, strNewDisNoProcessing,
                    strResultMsg,
                    iErrCountProcessing,
                    hiddenFinal == null ? "" : hiddenFinal.ClientID);



            }


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            fmStatus = FormStatus.fmBrowse;
            ResultMsgLabel.Text = strResultMsg;
        }


        return strCallBackResult;

        #endregion
    }
Пример #5
0
    private bool CheckDisCopyCanAdd(ArrayList ParameterList)
    {
        #region

        ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);
        string strErrMsg = "";
        bool bResult = false;
        bResult = BCO.CheckDisCopyCanAdd(ParameterList, ref strErrMsg);
        hiddenErrMsg.Value = strErrMsg;
        if (!bResult) 
        {
            ErrorMsgLabel.Text = strErrMsg;
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("ShowHiddenErrMsg();", strErrMsg), true);
        }

        return bResult;

        #endregion
    }
Пример #6
0
    private void QueryData()
    {
        #region
        DataTable dt = null;
        try
        {
            ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);
            ArrayList ParameterList2 = new ArrayList();//20091113
            ParameterList2.Clear();
            ParameterList2.Add(PageTimeStamp.Value);
            dt = BCO.QueryDisCopyAfterSetting(ParameterList2);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        dtForMasterAndDetail = dt;
        gv_Temp.DataSource = dt;
        gv_Temp.DataBind();

        if (dt == null || (dt != null && dt.Rows.Count <= 0))
        {
            //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
            ResultMsgLabel.Text = "查無資料";
            CurrentPageMode = PageCurrentMode.Readonly;
        }
        else
        {
            if (!btn_ErrorPop.Enabled)//如果檢視異常報表未啟用,則轉換模式,反之,表示已執行複製完畢不再轉換模式
            {
                LastPageMode = PageCurrentMode.Query;
                CurrentPageMode = PageCurrentMode.Readonly;
            }
        }

        #endregion
    }
Пример #7
0
    /// <summary>
    /// 舊Method不再使用~
    /// </summary>
    private void ProcessCopyDisRecord()
    {
        #region

        fmStatus = FormStatus.fmProcess;

        string strIDProcessing = "";
        string strUserID = Session["UID"].ToString();
        string strResultProcessing = "", strErrMsgProcessing = "";
        string strDynamicJs = "", strResultMsg = "", strNewDisNoProcessing = "";
        Int32 iErrCountProcessing = 0, iGvRowsCount = 0;
        bool bResult = false;
        iGvRowsCount = gv_Temp.Rows.Count;
        DataTable dtTemp = dtForMasterAndDetail;
        DataTable dtErr = null;
        System.Web.UI.HtmlControls.HtmlInputHidden hiddenFinal = null;

        try
        {
            switch (iGvRowsCount)//取得最後一個控制項
            {
                case 1:
                    hiddenFinal = hiddenDisplayModeProcessing0;
                    break;
                case 2:
                    hiddenFinal = hiddenDisplayModeProcessing1;
                    break;
                case 3:
                    hiddenFinal = hiddenDisplayModeProcessing2;
                    break;
                case 4:
                    hiddenFinal = hiddenDisplayModeProcessing3;
                    break;
                case 5:
                    hiddenFinal = hiddenDisplayModeProcessing4;
                    break;
            }

            ALOModel.MaintainDisCopy BCO2 = new ALOModel.MaintainDisCopy(ConnectionDB);


            if (iProcessingRow < iGvRowsCount && iGvRowsCount != 0)
            {
                strIDProcessing = ((Label)gv_Temp.Rows[iProcessingRow].FindControl("lbl_ID")).Text;
                ArrayList ParameterList = new ArrayList();//20091113

                ParameterList.Clear();
                ParameterList.Add(strIDProcessing);
                ParameterList.Add(strUserID);
                ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

                switch (iProcessingRow)//設定相關行數javascript
                {
                    case 0:
                        strDynamicJs = string.Format("setProcessingVisible('{0}',0);setProcessingVisible('{1}',1);", hiddenDisplayModeProcessing0.ClientID, hiddenDisplayModeProcessing1.ClientID);
                        break;
                    case 1:
                        strDynamicJs = string.Format("setProcessingVisible('{0}',0);setProcessingVisible('{1}',1);", hiddenDisplayModeProcessing1.ClientID, hiddenDisplayModeProcessing2.ClientID);
                        break;
                    case 2:
                        strDynamicJs = string.Format("setProcessingVisible('{0}',0);setProcessingVisible('{1}',1);", hiddenDisplayModeProcessing2.ClientID, hiddenDisplayModeProcessing3.ClientID);
                        break;
                    case 3:
                        strDynamicJs = string.Format("setProcessingVisible('{0}',0);setProcessingVisible('{1}',1);", hiddenDisplayModeProcessing3.ClientID, hiddenDisplayModeProcessing4.ClientID);
                        break;
                    case 4:
                        strDynamicJs = string.Format("setProcessingVisible('{0}',0);", hiddenDisplayModeProcessing4.ClientID);
                        break;

                }

                bResult = BCO2.ProcessCopyDisRecord(ParameterList, ref strResultProcessing, ref strNewDisNoProcessing, ref strErrMsgProcessing, ref iErrCountProcessing, null);

                if (!bResult)
                {
                    iProcessingErrorCount = iProcessingErrorCount + 1;
                }

                //完成時筆數加1
                iProcessingRow = iProcessingRow + 1;

                ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("{0};__doPostBack('doProcessCopyDisRecord','');", strDynamicJs), true);

                if (iGvRowsCount == iProcessingRow) //執行到最後一筆時
                {
                    #region

                    ArrayList ParameterList3 = new ArrayList();//20091113
                    ParameterList3.Clear();
                    ParameterList3.Add(SLP_SLPDate1.Text);
                    ParameterList3.Add(strUserID);
                    ParameterList3.Add(PageTimeStamp.Value);

                    dtErr = BCO2.QueryCopyErrorCount(ParameterList3);

                    if (dtErr != null && dtErr.Rows.Count > 0)
                    {
                        if (dtErr.Rows[0][0].ToString() == "0")
                        {
                            strResultMsg = "複製完成無錯誤資料";
                        }
                        else
                        {
                            iProcessingErrorCount = iProcessingErrorCount + 1;

                            strResultMsg = string.Format("複製完成,錯誤筆數{0}筆", iProcessingErrorCount);
                            btn_ErrorPop.Enabled = true;

                            string strQueryParams = string.Format("ST_ACCEPT_DATE={0}&ExecuteID={1}", SLP_SLPDate1.Text, Session["UID"].ToString());
                            btn_ErrorPop.Attributes.Add("onclick", string.Format("window.open('POP/POP_ALOCopyError.aspx?{0}','POP_ALOCopyError','width=800,height=600');", strQueryParams));

                        }
                    }

                    QueryData();//重新取得Processing資料

                    hiddenProcessingMsg.Value = strResultMsg;//ShowHiddenProcessingMsg();
                    strDynamicJs = string.Format("setProcessingVisible('{0}',0);", hiddenFinal.ClientID);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), string.Format("Processing_{0}", iProcessingRow), string.Format("{0};", strDynamicJs), true);
                    #endregion
                }

            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            ResultMsgLabel.Text = strResultMsg;
            fmStatus = FormStatus.fmBrowse;
        }

        #endregion
    }
Пример #8
0
    protected void gv_Temp_RowEditing(object sender, GridViewEditEventArgs e)
    {
        #region

        try
        {
            CurrentPageMode = PageCurrentMode.Edit;

            GridView gv = sender as GridView;
            DataTable dtTemp = dtForMasterAndDetail;
            iEditingRowIndex = e.NewEditIndex;
            ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);


            txt_DIS_NO_OLD.Text = dtTemp.Rows[e.NewEditIndex]["SRC_DIS_NO"].ToString().Trim();
            SLP_SKU1.Text = dtTemp.Rows[e.NewEditIndex]["SRC_ITEM"].ToString().Trim();
            SLP_ItemPeriod1.Text = dtTemp.Rows[e.NewEditIndex]["SRC_PERIOD"].ToString().Trim();
            SLP_SKU2.Text = dtTemp.Rows[e.NewEditIndex]["NEW_ITEM"].ToString().Trim();
            SLP_ItemPeriod2.Text = dtTemp.Rows[e.NewEditIndex]["NEW_PERIOD"].ToString().Trim();
            ddl_OpType.SelectedValue = dtTemp.Rows[e.NewEditIndex]["DIS_OP_TYPE"].ToString().Trim();
            Label lbl_ID = (Label)gv.Rows[e.NewEditIndex].FindControl("lbl_ID");
            Int32 iChanNo;
            Int32.TryParse(dtTemp.Rows[e.NewEditIndex]["CHAN_TYPE"].ToString().Trim(), out iChanNo);


            //20090731 added 重新取得該配本序號下之通路

            ArrayList ParameterList2 = new ArrayList();//20091113
            ParameterList2.Clear();
            ParameterList2.Add(txt_DIS_NO_OLD.Text.Trim());
            ALOModel.QueryALOCommon BCO2 = new ALOModel.QueryALOCommon(ConnectionDB);
            dtDisChanByDisNo = BCO2.QueryDisChanByDisNo(ParameterList2);


            if (iChanNo == 0)//全通路
            {
                rbtn_ChanAll.Checked = true;
                rbtn_ChanSingle.Checked = false;
                btn_ChanSetting.Enabled = false;
            }
            else if (iChanNo == 1)//個別通路
            {
                rbtn_ChanAll.Checked = false;
                rbtn_ChanSingle.Checked = true;
                btn_ChanSetting.Enabled = true;

                ArrayList ParameterList1 = new ArrayList();//20091113
                ParameterList1.Clear();
                ParameterList1.Add(lbl_ID.Text);
                
                //取得目前設定之通路
                dtCurrentDisChanData = BCO.QueryChanByPID(ParameterList1);
                gv_DisChan.DataSource = dtDisChanByDisNo;
            }

            gv_DisChan.DataBind();

            iChanTypeOriginal = iChanNo;

            if (dtTemp.Rows[e.NewEditIndex]["IS_COPY_PO"].ToString().Trim() == "0")
                ((CheckBox)SLP_Boolean1.FindControl("C1")).Checked = false;
            else
                ((CheckBox)SLP_Boolean1.FindControl("C1")).Checked = true;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Пример #9
0
    protected void gv_Temp_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        #region
        try
        {
            bool bResult = false;
            DataTable dtTemp = dtForMasterAndDetail;
            Label lbl_ID = (Label)gv_Temp.Rows[e.RowIndex].FindControl("lbl_ID");
            string strUser = Session["UID"].ToString();

            ArrayList ParameterList1 = new ArrayList();//20091113

            #region Master
            for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++)
            {
                if (dtTemp.Rows[i]["ID"].ToString().Trim() == lbl_ID.Text)
                {
                    ParameterList1.Clear();
                    ParameterList1.Add(dtTemp.Rows[i]["ID"]);
                    ParameterList1.Add(dtTemp.Rows[i]["CODE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["CREATEDATE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["CREATEUID"]);
                    ParameterList1.Add(dtTemp.Rows[i]["UPDATEDATE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["UPDATEUID"]);
                    ParameterList1.Add(dtTemp.Rows[i]["STATUS"]);
                    ParameterList1.Add(dtTemp.Rows[i]["SRC_DIS_NO"]);
                    ParameterList1.Add(dtTemp.Rows[i]["SRC_ITEM"]);
                    ParameterList1.Add(dtTemp.Rows[i]["SRC_PERIOD"]);
                    ParameterList1.Add(dtTemp.Rows[i]["ST_ACCEPT_DATE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["NEW_DIS_NO"]);
                    ParameterList1.Add(dtTemp.Rows[i]["NEW_ITEM"]);
                    ParameterList1.Add(dtTemp.Rows[i]["NEW_PERIOD"]);
                    ParameterList1.Add(dtTemp.Rows[i]["DIS_OP_TYPE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["CHAN_TYPE"]);
                    ParameterList1.Add(dtTemp.Rows[i]["IS_COPY_PO"]);
                    ParameterList1.Add(dtTemp.Rows[i]["COPY_RESULT"]);
                    ParameterList1.Add(dtTemp.Rows[i]["OP_CODE"]);
                    //log                    
                    ParameterList1.Add(strUser);
                    break;
                }
            }

            #endregion

            #region Detail
            ArrayList ParameterList2 = new ArrayList();//20091113
            ParameterList2.Clear();
            ParameterList2.Add(lbl_ID.Text);
            ParameterList2.Add(strUser);
            #endregion

            ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);

            bResult = BCO.DeleteMasterAndDetail(ParameterList1, ParameterList2, null);

            if (bResult)
            {
                ResultMsgLabel.Text = "刪除成功";
            }
            else
            {
                ResultMsgLabel.Text = "刪除失敗";
            }

            QueryData();//取出儲存後資料

            CurrentPageMode = PageCurrentMode.Readonly;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }


        hiddenRowCounts.Value = gv_Temp.Rows.Count.ToString();

        #endregion
    }
Пример #10
0
    /// <summary>
    /// ��ȶǨClient�
    /// </summary>
    /// <returns></returns>
    public string GetCallbackResult()
    {
        #region
        string rtn = "", strOpType = "", strResult = "";
        ALOModel.QueryALOCommon BCO = new ALOModel.QueryALOCommon(ConnectionDB);
        ALOModel.MaintainDisCopy BCO2 = new ALOModel.MaintainDisCopy(ConnectionDB);

        DataTable dt = null;
        string[] strAryArg;
        ArrayList ParameterList = new ArrayList();//20091113

        if (CallServerValue.IndexOf("DA") != -1)
        {
            strOpType = "DA";
        }
        else
        {
            if (CallServerValue.IndexOf("D") != -1)
            {
                strOpType = "D";
            }
        }

        if (ObjectFrom.IndexOf("DISNO") != -1)
        {
            #region
            if (CallServerValue.Trim() != "")
            {
                #region old
                //2009-07-25 cyhsu mark ���Ӧb�J餰t���Ǹ��B�~���B��O���~ᤨq�  
                //ParameterList.Clear();
                //ParameterList.Add(CallServerValue);
                //dt = BCO.QueryDisChanByDisNo(ParameterList);
                //if (dt != null && dt.Rows.Count > 0)
                //{
                //    rtn = string.Format("{0}-{1}", dt.Rows.Count, strOpType);
                //    dtDisChanByDisNo = dt;
                //}
                //else
                //{
                //    rtn = string.Format("{0}-{1}", 0, strOpType);
                //    dtDisChanByDisNo = null;
                //}
                #endregion

                // Get VDS_ALO_DIS_ITEM info by Dis_No
                GetDisItemByDisNo(CallServerValue);
                if (dtDisItem != null && dtDisItem.Rows.Count > 0)
                {
                    // Get VDS_ALO_DIS_CHAN by DIS_NO + ITEM + PERIOD
                    GetDisChan(CallServerValue.ToString(),
                               dtDisItem.Rows[0]["ITEM"].ToString(),
                               dtDisItem.Rows[0]["PERIOD"].ToString());

                    if (dtDisChanByDisNo != null && dtDisChanByDisNo.Rows.Count > 0)
                    {
                        rtn = string.Format("{0}-{1}-{2};", dtDisItem.Rows[0]["ITEM"].ToString(),
                                                            dtDisItem.Rows[0]["PERIOD"].ToString(), strOpType);
                    }
                    else
                    {
                        rtn = string.Format("{0}-{1}-{2};無配本通路資料不可複製", "", "", "");
                    }
                }
                else
                {
                    rtn = string.Format("{0}-{1}-{2};無配本商品資料不可複製", "", "", "");
                }
            }
            else
            {
                rtn = string.Format("{0}-{1}-{2};CallBackForDisNo發生異常", "", "", "");
            }
            #endregion
        }
        else if (ObjectFrom.IndexOf("PROCESS") != -1)
        {
            #region
            Int32 iProcessingRowIndex;
            Int32.TryParse(CallServerValue, out iProcessingRowIndex);

            rtn = ProcessCopyDisRecordCallBack(iProcessingRowIndex);
            #endregion
        }
        else if (ObjectFrom.IndexOf("PERIOD") != -1)
        {
            #region
            strAryArg = CallServerValue.Split(";".ToCharArray());

            if (GetTaxType(strAryArg[0], strAryArg[1]))
            {
                rtn = "X";
                #region �ӷ���O
                if (ObjectFrom.IndexOf("1") != -1)
                {
                    #region  2009-07-25 �t�q��T
                    GetDisChan(strAryArg[2], strAryArg[0], strAryArg[1]);

                    dt = dtDisChanByDisNo;

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        rtn = string.Format("{0}-{1}", "X", dt.Rows.Count.ToString());
                    }
                    else
                    {
                        rtn = string.Format("{0}-{1}", "X", "0");
                    }
                    #endregion
                }
                #endregion

            }
            else
            {
                rtn = string.Format("{0}-{1}",
                                     "無此期別 [" + strAryArg[1].ToString() + "] 設定,請輸入其他期別", "");

                //rtn = "無此期別 [" + strAryArg[1].ToString() + "] 設定,請輸入其他期別";

            }
            #endregion
        }




        //附加相關控制項
        if (ObjectFrom.IndexOf("DISNO") != -1)
        {
            #region
            //strResult = string.Format("{0}-{1}-{2};{3}",
            //    hiddenDisChanCounts.ClientID,
            //    ddl_OpType.ClientID,
            //    txt_DIS_NO_OLD.ClientID,
            //    rtn);

            strResult = string.Format("{0}-{1}-{2};{3}",
                SLP_SKU1.TextBox_Code.ClientID,        //�~쫸�
                SLP_ItemPeriod1.TextBox_Code.ClientID, //���O
                ddl_OpType.ClientID,                   //�t���O
                rtn);
            #endregion
        }
        else if (ObjectFrom.IndexOf("PROCESS") != -1)
        {
            //回傳結果格式為:
            ///下一筆將要執行的RowIndex;要被關閉的動畫ClientID;要被開啟的動畫ClientID;CopyResultClientID-Processing結果值;NewDisNoClientID-NewDisNo值;ResultMsg;ProcessingErrCounts;最後一個執行列的hidden控制項ID
            strResult = rtn;
        }
        else if (ObjectFrom.IndexOf("PERIOD") != -1)
        {
            #region
            strAryArg = CallServerValue.Split(";".ToCharArray());

            if (ObjectFrom.IndexOf("1") != -1)
            {
                //strResult = string.Format("{0}-{1};{2}", strAryArg[2], SLP_ItemPeriod1.TextBox_Code.ClientID, rtn);
                strResult = string.Format("{0}-{1};{2}",
                    SLP_ItemPeriod1.TextBox_Code.ClientID,//���O
                    hiddenDisChanCounts.ClientID,         //�t���q��
                    rtn);
            }
            else if (ObjectFrom.IndexOf("2") != -1)
            {
                strResult = string.Format("{0}-{1};{2}", strAryArg[2], SLP_ItemPeriod2.TextBox_Code.ClientID, rtn);
            }
            #endregion
        }


        return strResult;
        #endregion
    }
Пример #11
0
    protected void btn_AddOK_Click(object sender, EventArgs e)
    {
        #region

        try
        {

            ResetDisplayModeForProcessing();

            ArrayList ParameterList1 = new ArrayList();//20091113
            ParameterList1.Clear();
            ParameterList1.Add(txt_DIS_NO_OLD.Text.Trim());
            ParameterList1.Add(SLP_SKU1.Text.Trim());
            ParameterList1.Add(SLP_ItemPeriod1.Text.Trim());
            ParameterList1.Add(SLP_SKU2.Text.Trim());
            ParameterList1.Add(SLP_ItemPeriod2.Text.Trim());

            if (CheckDisCopyCanAdd(ParameterList1))
            {
                string strUser = Session["UID"].ToString();
                string strCode = string.Format("AF_{0}_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), strUser);
                Int32 iChanType = GetChanType();
                int iResult = 0;
                bool bResult = false;
                DataTable dtDetail = dtDetailData;
                DataTable dtDetailDeleted = dtForDetailDeleted;
                DataRow dr = null;
                CheckBox chk = null;
                DateTime processtime = DateTime.Now;
                ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);
                ALOModel.QueryALOCommon BCO2 = new ALOModel.QueryALOCommon(ConnectionDB);
                ArrayList ParameterList = new ArrayList();//20091113
                ArrayList ParameterList2 = new ArrayList();//20091113


                if (CurrentPageMode == PageCurrentMode.Insert)
                {
                    #region

                    //if (CheckItemIsAvailable(SLP_SKU1.Text.Trim(), SLP_ItemPeriod1.Text.Trim()))
                    //{
                    #region Master
                    ParameterList.Clear();
                    ParameterList.Add(strCode);
                    ParameterList.Add(processtime);
                    ParameterList.Add(strUser);
                    ParameterList.Add(processtime);
                    ParameterList.Add(strUser);
                    ParameterList.Add(txt_DIS_NO_OLD.Text.Trim());
                    ParameterList.Add(SLP_SKU1.Text.Trim());
                    ParameterList.Add(SLP_ItemPeriod1.Text.Trim());
                    ParameterList.Add(SLP_SLPDate1.Text.Trim());
                    ParameterList.Add(null);
                    ParameterList.Add(SLP_SKU2.Text.Trim());
                    ParameterList.Add(SLP_ItemPeriod2.Text.Trim());
                    ParameterList.Add(ddl_OpType.SelectedValue.ToString());
                    ParameterList.Add(iChanType);
                    ParameterList.Add(((CheckBox)SLP_Boolean1.FindControl("C1")).Checked ? 1 : 0);
                    ParameterList.Add(PageTimeStamp.Value);
                    #endregion

                    #region Detail

                    dtDetail.Clear();

                    ParameterList2.Clear();
                    ParameterList2.Add(txt_DIS_NO_OLD.Text.Trim());
                    dtDisChanByDisNo = BCO2.QueryDisChanByDisNo(ParameterList2);


                    if (iChanType == 0)//全通路
                    {
                        if (dtDisChanByDisNo != null)
                        {
                            for (Int32 i = 0; i <= dtDisChanByDisNo.Rows.Count - 1; i++)
                            {
                                dr = dtDetail.NewRow();
                                dr["CHAN_NO"] = dtDisChanByDisNo.Rows[i]["CHAN_NO"].ToString();
                                dr["USERID"] = strUser;
                                dtDetail.Rows.Add(dr);
                            }
                        }
                    }
                    else if (iChanType == 1)//個別通路
                    {
                        for (Int32 i = 0; i <= gv_DisChan.Rows.Count - 1; i++)
                        {
                            chk = ((CheckBox)gv_DisChan.Rows[i].FindControl("chk_Single"));

                            if (chk.Checked)
                            {
                                dr = dtDetail.NewRow();
                                dr["CHAN_NO"] = chk.Text;
                                dr["USERID"] = strUser;
                                dtDetail.Rows.Add(dr);
                            }
                        }
                    }

                    #endregion

                    iResult = BCO.CreateMasterAndDetail(ParameterList, dtDetail, null);

                    if (iResult != 0)
                    {
                        ResultMsgLabel.Text = "新增成功";
                    }
                    else
                    {
                        ResultMsgLabel.Text = "新增失敗";
                    }
                    //}
                    //else
                    //{
                    //    throw new Exception("輸入之原商品/品號、原期別與資料庫不相符!");
                    //}

                    #endregion
                }
                else if (CurrentPageMode == PageCurrentMode.Edit)
                {
                    #region
                    #region Master

                    DataTable dtTemp = dtForMasterAndDetail;
                    string strPID = dtTemp.Rows[iEditingRowIndex]["ID"].ToString().Trim();
                    ParameterList.Clear();
                    //old params
                    ParameterList.Add(strPID);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["CODE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["CREATEDATE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["CREATEUID"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["UPDATEDATE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["UPDATEUID"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["STATUS"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["SRC_DIS_NO"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["SRC_ITEM"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["SRC_PERIOD"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["ST_ACCEPT_DATE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["NEW_DIS_NO"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["NEW_ITEM"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["NEW_PERIOD"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["DIS_OP_TYPE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["CHAN_TYPE"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["IS_COPY_PO"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["COPY_RESULT"]);
                    ParameterList.Add(dtTemp.Rows[iEditingRowIndex]["OP_CODE"]);
                    //new params
                    ParameterList.Add(iChanType);
                    ParameterList.Add(((CheckBox)SLP_Boolean1.FindControl("C1")).Checked ? 1 : 0);
                    ParameterList.Add(processtime);
                    ParameterList.Add(strUser);



                    #endregion

                    #region Detail
                    dtDetail.Clear();
                    dtDetailDeleted.Clear();


                    ParameterList2.Clear();
                    ParameterList2.Add(txt_DIS_NO_OLD.Text.Trim());
                    dtDisChanByDisNo = BCO2.QueryDisChanByDisNo(ParameterList2);

                    if (iChanType == 0)//全通路
                    {
                        #region
                        if (dtDisChanByDisNo != null)
                        {
                            for (Int32 i = 0; i <= dtDisChanByDisNo.Rows.Count - 1; i++)
                            {
                                dr = dtDetail.NewRow();
                                dr["PID"] = strPID;
                                dr["CHAN_NO"] = dtDisChanByDisNo.Rows[i]["CHAN_NO"].ToString();
                                dtDetail.Rows.Add(dr);
                            }
                        }

                        dtDetailDeleted = null;
                        #endregion
                    }
                    else if (iChanType == 1)//個別通路 
                    {
                        #region
                        if (iChanTypeOriginal == 0)//原來是全通路
                        {
                            for (Int32 i = 0; i <= gv_DisChan.Rows.Count - 1; i++)
                            {
                                chk = ((CheckBox)gv_DisChan.Rows[i].FindControl("chk_Single"));

                                if (chk.Checked)
                                {
                                    dr = dtDetail.NewRow();
                                    dr["PID"] = strPID;
                                    dr["CHAN_NO"] = chk.Text;
                                    dtDetail.Rows.Add(dr);
                                }
                            }

                            dtDetailDeleted = null;
                        }
                        else//原來是個別通路
                        {
                            #region 比對舊資料是否有刪除
                            for (Int32 i = 0; i <= gv_DisChan.Rows.Count - 1; i++)
                            {
                                chk = ((CheckBox)gv_DisChan.Rows[i].FindControl("chk_Single"));

                                for (Int32 k = 0; k <= dtCurrentDisChanData.Rows.Count - 1; k++)
                                {
                                    if (dtCurrentDisChanData.Rows[k]["CHAN_NO"].ToString() == chk.Text)
                                    {
                                        if (!chk.Checked)//跟原來資料的比較未勾選的則進行刪除
                                        {
                                            dr = dtDetailDeleted.NewRow();

                                            dr["ID"] = dtCurrentDisChanData.Rows[k]["ID"];
                                            dr["PID"] = dtCurrentDisChanData.Rows[k]["PID"];
                                            dr["CREATEDATE"] = dtCurrentDisChanData.Rows[k]["CREATEDATE"];
                                            dr["CREATEUID"] = dtCurrentDisChanData.Rows[k]["CREATEUID"];
                                            dr["UPDATEDATE"] = dtCurrentDisChanData.Rows[k]["UPDATEDATE"];
                                            dr["UPDATEUID"] = dtCurrentDisChanData.Rows[k]["UPDATEUID"];
                                            dr["CHAN_NO"] = dtCurrentDisChanData.Rows[k]["CHAN_NO"];
                                            dr["UIDFORLOG"] = Session["UID"].ToString();
                                            dtDetailDeleted.Rows.Add(dr);
                                        }
                                        //else
                                        //{
                                        //    dr = dtDetail.NewRow();//只要有被勾選就列為新增,重複時會在PKG處理
                                        //    dr["PID"] = strPID;
                                        //    dr["CHAN_NO"] = chk.Text;
                                        //    dtDetail.Rows.Add(dr);
                                        //}
                                    }
                                }

                                if (chk.Checked)//只要有被勾選就列為新增,重複時會在PKG處理
                                {
                                    dr = dtDetail.NewRow();
                                    dr["PID"] = strPID;
                                    dr["CHAN_NO"] = chk.Text;
                                    dtDetail.Rows.Add(dr);
                                }
                            }
                            #endregion
                        }
                        #endregion
                    }
                    #endregion

                    bResult = BCO.UpdateMasterAndDetail(ParameterList, dtDetail, strUser, dtDetailDeleted, null);

                    if (bResult)
                    {
                        ResultMsgLabel.Text = "更新成功";
                    }
                    else
                    {
                        ResultMsgLabel.Text = "更新失敗";
                    }
                    #endregion
                }


                QueryData();//取出儲存後資料
                CurrentPageMode = PageCurrentMode.Readonly;

            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            hiddenRowCounts.Value = gv_Temp.Rows.Count.ToString();
        }
        #endregion
    }
Пример #12
0
    protected void btn_CancelSettings_Click(object sender, EventArgs e)
    {
        #region


        bool bResult = false;
        DataTable dtTemp = dtForMasterAndDetail;
        string strUser = Session["UID"].ToString();
        ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);
        try
        {
            bResult = BCO.DeleteMultiDisCopy(dtTemp, strUser, null);

            if (bResult)
            {
                //todo need to complete
                hiddenRowCounts.Value = "0";
                dtForMasterAndDetail = null;
                gv_Temp.DataBind();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            CurrentPageMode = PageCurrentMode.Readonly;
        }
        #endregion
    }