Exemplo n.º 1
0
    private string ProcessMultiConfirm(string strStAcceptDate, string strDisNoForAry, Int32 iProcessingAryIndex, string strUserID, string strPageTimeStamp)
    {
        #region
        string strDisNo = "", strNextDisNo = "";
        string[] strAryDisAry = strDisNoForAry.Split(";".ToCharArray());
        string strCallbackResult = "";
        string strResult = "", strErrMsg = "", strErrMsgFinal = "";
        string strPrefixed = "POP_DisApproveError";
        string strApproveDate = "";
        string strITEM_PERIOD_RESERVE_QTY = "";
        

        try
        {
            //於執行多筆確認、解除時清空,為了於換頁時可以取得最新資料
            string SessionIDName = string.Format("{0}_{1}", "CRM211_MST", strPageTimeStamp);
            Session[SessionIDName] = null;


            #region 檢查門市進貨日
            if (DateTime.Parse(strStAcceptDate) < DateTime.Today.AddDays(1))
            {
                strErrMsg += "門市進貨日必須大於系統日 ";
            }

            if (DateTime.Parse(strStAcceptDate).DayOfWeek == DayOfWeek.Sunday)
            {
                strErrMsg += "門市進貨日不可為星期日 ";
            }
            #endregion

            fmStatus = FormStatus.fmProcess;

            if (iProcessingAryIndex < strAryDisAry.Length)
            {
                //取得當前執行之 DISNO
                strDisNo = strAryDisAry[iProcessingAryIndex];

                if (strErrMsg == "")
                {
                    #region
                    CRMModel.VDS_CRM21_BCO BCO = new CRMModel.VDS_CRM21_BCO(ConnectionDB);
                    ArrayList ParameterList = new ArrayList();
                    ParameterList.Clear();
                    ParameterList.Add(strStAcceptDate);
                    ParameterList.Add(strDisNo);
                    ParameterList.Add("VDS_ALO_DIS_STORE");
                    ParameterList.Add(strUserID);

                    BCO.ProcessConfirmForCrm21(ParameterList, out strResult, out strErrMsg, null);

                    if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功
                    {
                        strApproveDate = DateTime.Now.ToString("yyyy/MM/dd");

                        #region
                        ParameterList.Clear();
                        ParameterList.Add(strDisNo == "" ? null : strDisNo);
                        DataTable dtTemp = BCO.QueryDisCRMItemByDisNoForCrm21(ParameterList);
                        BCO.CloseConnection();

                        if (dtTemp != null && dtTemp.Rows.Count > 0)
                        {
                            for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++)
                            {
                                strITEM_PERIOD_RESERVE_QTY += string.Format("{0}||{1}||{2},",
                                    dtTemp.Rows[i]["ITEM"].ToString(), dtTemp.Rows[i]["PERIOD"].ToString(), dtTemp.Rows[i]["RESERVE_QTY"].ToString());
                            }

                            if (strITEM_PERIOD_RESERVE_QTY.Trim() != "")
                            {
                                if (strITEM_PERIOD_RESERVE_QTY.Substring(strITEM_PERIOD_RESERVE_QTY.Length - 1, 1) == ",")
                                {
                                    strITEM_PERIOD_RESERVE_QTY = strITEM_PERIOD_RESERVE_QTY.Substring(0, strITEM_PERIOD_RESERVE_QTY.Length - 1);
                                }
                            }
                        }


                        #endregion

                    }
                    else if ((strResult == "1") && (strErrMsg.Trim() != ""))//確認失敗
                    {
                        #region 只要成功完成檢核,無論筆數 strResult 都=1, 所以要另外檢查strErrMsg 不為空值代表有檢核錯誤資料需要開POP
                        //Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] = strDisNo;
                        //Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, strPageTimeStamp)] = "1";

                        Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] += string.Format("{0},", strDisNo);
                        Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, strPageTimeStamp)] = "1";
                        Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] += string.Format("配本序號:{0},{1};\r\n", strDisNo, strErrMsg);

                        strResult = "0";
                        #endregion
                    }
                    #endregion
                }
                else 
                {
                    Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] += string.Format("配本序號:{0},{1};\r\n", strDisNo, strErrMsg);
                }

                iProcessingAryIndex = iProcessingAryIndex + 1;

                if (iProcessingAryIndex < strAryDisAry.Length)
                {
                    strNextDisNo = strAryDisAry[iProcessingAryIndex];
                }
                else
                {
                    strNextDisNo = "X";//表示已執行到最後一筆
                    strErrMsgFinal = Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] == null ? "" : Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)].ToString();
                    Session[string.Format("{0}_ERRMSG_{1}", strPrefixed, strPageTimeStamp)] = null;
                }

                //0:DIS_NO字串For陣列用-
                //1:下一筆陣列Index-
                //2:執行結果-
                //3:錯誤訊息-
                //4:要關閉執行狀態的DIS_NO-
                //5:要開啟執行狀態的DIS_NO-
                //6:是否有累積執行錯誤之DIS_NO
                strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}",
                    strDisNoForAry,
                    iProcessingAryIndex,
                    strResult == "1" ? "OK" : "NG",
                    strErrMsgFinal,
                    strDisNo,
                    strNextDisNo,
                    Session[string.Format("{0}_DISNO_{1}", strPrefixed, strPageTimeStamp)] == null ? "0" : "1"
                    );
            }
        }
        catch (Exception ex)
        {
            throw new Exception(string.Format("{0}||{1}", strDisNo, ex.Message));
        }

        return strCallbackResult;
        #endregion
    }
Exemplo n.º 2
0
    private string ProcessMultiRemove(string strDisNoForAry, Int32 iProcessingAryIndex, string strUserID, string strPageTimeStamp)
    {
        #region

        bool bResult = false;
        string strDisNo = "", strNextDisNo = "";
        string[] strAryDisAry = strDisNoForAry.Split(";".ToCharArray());
        string strCallbackResult = "";
        string strResult = "", strErrMsg = "";
        string strPrefixed = "POP_DisApproveError";

        try
        {

            //於執行多筆確認、解除時清空,為了於換頁時可以取得最新資料
            string SessionIDName = string.Format("{0}_{1}", "CRM211_MST", strPageTimeStamp);
            Session[SessionIDName] = null;

            fmStatus = FormStatus.fmProcess;

            if (iProcessingAryIndex < strAryDisAry.Length)
            {

                strDisNo = strAryDisAry[iProcessingAryIndex];

                CRMModel.VDS_CRM21_BCO BCO = new CRMModel.VDS_CRM21_BCO(ConnectionDB);
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();
                ParameterList.Add(strDisNo);
                ParameterList.Add(strUserID);
                ParameterList.Add(DateTime.Now);

                BCO.ProcessCancelConfirmForCrm21(ParameterList, out strResult, out strErrMsg, null);

                if (strResult == "1")//解除成功
                {
                    bResult = true;
                }
                else//解除失敗
                {
                    Session[string.Format("{0}_REMOVE_{1}", strPrefixed, strPageTimeStamp)] = strDisNo;
                    bResult = false;
                }

                iProcessingAryIndex = iProcessingAryIndex + 1;

                if (iProcessingAryIndex < strAryDisAry.Length)
                {
                    strNextDisNo = strAryDisAry[iProcessingAryIndex];
                }
                else
                {
                    strNextDisNo = "X";//表示已執行到最後一筆
                }

                //0:DIS_NO字串For陣列用-
                //1:下一筆陣列Index-
                //2:執行結果-
                //3:錯誤訊息-
                //4:要關閉執行狀態的DIS_NO-
                //5:要開啟執行狀態的DIS_NO-
                //6:是否有累積執行錯誤之DIS_NO


                strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}",
                    strDisNoForAry,
                    iProcessingAryIndex,
                    bResult ? "OK" : "NG",
                    string.Format("{0}", strErrMsg),
                    strDisNo,
                    strNextDisNo,
                    Session[string.Format("{0}_REMOVE_{1}", strPrefixed, strPageTimeStamp)] == null ? "0" : "1"
                    );
            }

        }
        catch (Exception ex)
        {
            throw new Exception(string.Format("{0}||{1}", strDisNo, ex.Message));
        }

        return strCallbackResult;
        #endregion
    }
Exemplo n.º 3
0
    private void QueryData()
    {
        #region
        try
        {



            CRMModel.VDS_CRM21_BCO BCO = new CRMModel.VDS_CRM21_BCO(ConnectionDB);
            DataTable dt = BCO.QueryDisCRMMainByFindForCrm21(GetQueryParams());

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

            aryParamsPKey.Clear();

            LabelQueryRecordCount.Visible = false;

            if (dt != null && dt.Rows.Count > 0)
            {
                gv_Result.PageSize = iCurrentGvPageSize;
                gv_Result.PageIndex = iCurrentGvPageIndex;

                gv_Result.DataSource = dt;
                gv_Result.DataBind();

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

                foreach (DataRow dr in dt.Rows)
                {
                    #region

                    aryParamsPKey.Add(dr["DIS_NO"]);

                    #endregion
                }

                //有資料才可執行多筆確認、解除
                btn_ConfirmMulti.Visible = true;
                btn_RemoveMulti.Visible = true;

            }
            else
            {
                btn_ConfirmMulti.Visible = false;
                btn_RemoveMulti.Visible = false;

                gv_Result.DataBind();
                ResultMsgLabel.Text = "查無資料";
            }

            Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey;
        }
        catch (Exception ex)
        {
            gv_Result.DataBind();
            ErrorMsgLabel.Text = ex.Message;
        }
        finally 
        {
            UpdatePanel2.Update();
        }

        #endregion
    }