示例#1
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
    }
示例#2
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
    }