Пример #1
0
    private string ProcessConfirm(string strStAcceptDate, string strDisNo)
    {
        #region
        string strCallbackResult = "";

        string strResult = "", strErrMsg = "";
        string strPrefixed = "POP_DisApproveError";
        string strApproveDate = "";
        string strITEM_PERIOD_RESERVE_QTY = "";

        try
        {
            #region
            //2009-11-04 cyhsu add for 門市進貨日檢查
            #region 檢查門市進貨日
            if (DateTime.Parse(strStAcceptDate) < DateTime.Today.AddDays(1))
            {
                throw new Exception("門市進貨日必須大於系統日");
            }
            if (DateTime.Parse(strStAcceptDate).DayOfWeek == DayOfWeek.Sunday)
            {
                throw new Exception("門市進貨日不可為星期日");
            }
            #endregion
            fmStatus = FormStatus.fmProcess;

            ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(strStAcceptDate);
            ParameterList.Add(strDisNo);
            ParameterList.Add("VDS_ALO_DIS_STORE");
            ParameterList.Add(Session["UID"].ToString());

            BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null);
            // 2009-06-17 cyhsu change
            if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功
            {
                strApproveDate = DateTime.Now.ToString("yyyy/MM/dd");
                ConfirmIsTrueAndRemoveIsFalse = true;


                #region
                //20091202
                ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add(strDisNo == "" ? null : strDisNo);
                DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList);

                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

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


            strCallbackResult = string.Format("{0}-{1}-{2}-{3}-{4};{5}-{6}-{7}-{8}",
                ((TextBox)SLP_SLPDate4_ApproveDate.FindControl("TextBoxCode")).ClientID,
                btn_Confirm.ClientID,
                btn_Remove.ClientID,
                ResultMsgLabel.ClientID,
                hiddenFrmStatus.ClientID,
                strApproveDate,
                strResult,
                FormStatus.fmBrowse.ToString(),
                strITEM_PERIOD_RESERVE_QTY
                );
            #endregion
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return strCallbackResult;
        #endregion
    }
Пример #2
0
    private bool ConfirmDisAgain(string strDisNo, string strStAcceptDate, string strUserID)
    {
        #region
        Int32 iErrCount = 0;

        try
        {
            string strResult = "", strErrMsg = "";
            string strDisNo_Err = "";
            string strPrefixed = "POP_DisApproveError";
            bool bResultCheck = false;

            string[] strAryDisNO = strDisNo.Split(",".ToCharArray());

            ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
            ArrayList ParameterList = new ArrayList();

            for (Int32 i = 0; i <= strAryDisNO.GetUpperBound(0); i++)
            {
                ParameterList.Clear();
                ParameterList.Add(strStAcceptDate);
                ParameterList.Add(strAryDisNO[i]);
                ParameterList.Add("VDS_ALO_DIS_STORE");
                ParameterList.Add(strUserID);
                BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null);

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

            if (iErrCount != 0)
            {
                Session[string.Format("{0}_DISNO_{1}", strPrefixed, PageTimeStamp.Value)] = strDisNo_Err;
                Session[string.Format("{0}_OPTYPE_{1}", strPrefixed, PageTimeStamp.Value)] = "1";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return iErrCount == 0 ? true : false;
        #endregion
    }
Пример #3
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}", "ALO191_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
                    ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
                    ArrayList ParameterList = new ArrayList();
                    ParameterList.Clear();
                    ParameterList.Add(strStAcceptDate);
                    ParameterList.Add(strDisNo);
                    ParameterList.Add("VDS_ALO_DIS_STORE");
                    ParameterList.Add(strUserID);

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

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

                        #region
                        ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
                        ParameterList.Clear();
                        ParameterList.Add(strDisNo == "" ? null : strDisNo);
                        DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList);
                        BCO2.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
    }
Пример #4
0
    /// <summary>
    /// 配本確認 2009-07-02
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SetupConfirmBtn_Click(object sender, EventArgs e)
    {
        #region

        string strResult = "", strErrMsg = "", strErrMsgCheck = "";
        bool bResultCheck = false;
        string strPrefixed = "POP_DisApproveError";
        try
        {
            #region

            #region 門市進貨日判斷

            if (DateTime.Parse(SLP_STAcceptDate.Text) < DateTime.Today.AddDays(1))//2010/04/06 added : 門市進貨日必須大於等於系統日+1日
            {
                throw new Exception("門市進貨日必須大於等於系統日+1日!!");
            }

            #endregion

            #region
            ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
            ArrayList ParameterList = new ArrayList();


            //---------------------------------------------------------------------
            //2010/02/08 added:確認前檢核
            ParameterList.Clear();
            ParameterList.Add(DateTime.Parse(SLP_STAcceptDate.Text).ToShortDateString());
            ParameterList.Add(DISNOTxt.Text);
            bResultCheck = BCO.Pick_Control_Check(ParameterList, out strErrMsgCheck);
            //---------------------------------------------------------------------

            ParameterList.Clear();
            ParameterList.Add(DateTime.Parse(SLP_STAcceptDate.Text).ToShortDateString());
            ParameterList.Add(DISNOTxt.Text);
            ParameterList.Add("VDS_ALO_DIS_STORE");
            ParameterList.Add(Session["UID"].ToString());
            BCO.ProcessConfirm(ParameterList, out strResult, out strErrMsg, null);

            if ((strResult == "1") && (strErrMsg.Trim() == ""))//確認成功
            {
                #region 確認成功
                SLP_ApproveDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
                Int32 iReserveQty = 0; //保留數
                Int32 iMdcQty = 0;     //預留數(理論) = 到貨數-保留數-實配數
                Int32 iAcceptQTY = 0;  //到貨數
                Int32 iDisQty = 0;     //實配數
                //取舊值
                iReserveQty = Int32.Parse(this.ReserveQTYtxt.Text);
                iMdcQty = Int32.Parse(this.DIS_MDCQTYtxt.Text);
                iAcceptQTY = Int32.Parse(this.AcceptQTYtxt.Text);
                iDisQty = Int32.Parse(this.DISQTYtxt.Text);
                //算新值
                iReserveQty = iReserveQty + iDisQty;
                iMdcQty = iAcceptQTY - iReserveQty;//預留數(實際) = 到貨數-新保留數

                this.ReserveQTYtxt.Text = iReserveQty.ToString();
                this.OLD_ReserveQTYtxtHidden.Value = iReserveQty.ToString();
                this.DIS_MDCQTYtxt.Text = iMdcQty.ToString();
                this.OLD_DISMDCQTYHidden.Value = iMdcQty.ToString();


                //Gridview
                SessionIDName = "ALO111ItemGridViewDv_" + PageTimeStamp.Value;
                DataView dv = (DataView)Session[SessionIDName];

                for (Int32 i = 0; i <= dv.Table.Rows.Count - 1; i++)
                {
                    if (dv.Table.Rows[i]["ITEM"].ToString().Trim() == SLP_SKU1.TextBox_Code.Text.Trim() &&
                       dv.Table.Rows[i]["PERIOD"].ToString().Trim() == SLP_ItemPeriod1.TextBox_Code.Text.Trim())
                    {
                        dv.Table.Rows[i]["RESERVE_QTY"] = iReserveQty;
                        dv.Table.Rows[i]["DIS_MDC_QTY"] = iMdcQty;
                        break;
                    }
                }

                Session[SessionIDName] = dv;
                GridView_ItemList.DataSource = dv;
                GridView_ItemList.DataBind();

                //2010/04/20 modified
                if (!bResultCheck && strErrMsgCheck != "")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');alert('確認成功!');", strErrMsgCheck), true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('確認成功!');", true);
                }


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


            if (bResultCheck)
            {
                #region check ok && confirm fail
                if (strResult != "1")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "POP_DisApproveError();", true);
                }
                #endregion
            }
            else
            {
                #region check fail && confirm fail
                if (strResult != "1")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');POP_DisApproveError();", strErrMsgCheck), true);
                }
                #endregion
            }


            FormStatusControl(FormStatus.View);
            UpdatePanel_ALODisMain.Update();
            UpdatePanel_Item.Update();
            #endregion

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

            if (!bResultCheck && strErrMsgCheck != "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", string.Format("alert('{0}');", strErrMsgCheck), true);
            }

        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }

        #endregion
    }