Exemplo n.º 1
0
    private void QueryData()
    {
        #region
        try
        {
            if (s_DIS_NO == "") return;

            //if (CurrentPageMode == PageCurrentMode.Insert || CurrentPageMode == PageCurrentMode.Edit)
            //{
            #region

            CheckCurrentIndexAndSwitchNavigator(s_DIS_NO);

            ALOModel.MaintainDisMain BCO1 = new ALOModel.MaintainDisMain(ConnectionDB);
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO);
            dtDisMain = BCO1.QueryByDisNo(ParameterList);

            ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO);
            dtDisItem = BCO2.QueryDisCRMItemByDisNo(ParameterList);
            dtDisItemOld = dtDisItem.Copy();

            DataColumn[] PrimaryKeys21 = new DataColumn[3];
            PrimaryKeys21[0] = dtDisItemOld.Columns["DIS_NO"];
            PrimaryKeys21[1] = dtDisItemOld.Columns["ITEM"];
            PrimaryKeys21[2] = dtDisItemOld.Columns["PERIOD"];
            dtDisItemOld.PrimaryKey = PrimaryKeys21;

            DataColumn[] PrimaryKeys22 = new DataColumn[3];
            PrimaryKeys22[0] = dtDisItem.Columns["DIS_NO"];
            PrimaryKeys22[1] = dtDisItem.Columns["ITEM"];
            PrimaryKeys22[2] = dtDisItem.Columns["PERIOD"];
            dtDisItem.PrimaryKey = PrimaryKeys22;


            ALOModel.MaintainDisStore BCO3 = new ALOModel.MaintainDisStore(ConnectionDB);
            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO);

            dtDisStoreAll = BCO3.QueryDisStoreByDisNo(ParameterList);
            dtDisStore = dtDisStoreAll.Copy();
            dtDisStoreAllOld = dtDisStoreAll.Copy();

            DataColumn[] PrimaryKeys31 = new DataColumn[1];
            PrimaryKeys31[0] = dtDisStoreAllOld.Columns["CODE"];
            dtDisStoreAllOld.PrimaryKey = PrimaryKeys31;

            DataColumn[] PrimaryKeys32 = new DataColumn[1];
            PrimaryKeys32[0] = dtDisStoreAll.Columns["CODE"];
            dtDisStoreAll.PrimaryKey = PrimaryKeys32;

            #region Binding Data
            txt_DisNo.Text = s_DIS_NO;
            if (dtDisMain != null && dtDisMain.Rows.Count > 0)
            {
                SLP_StoreChain1.Text = dtDisMain.Rows[0]["RCHAN_NO"].ToString();
                SLP_SLPDate1_DisDate.Text = dtDisMain.Rows[0]["DIS_DATE"].ToString();
                SLP_SLPDate2_StAcceptDate.Text = dtDisMain.Rows[0]["ST_ACCEPT_DATE"].ToString();
                SLP_SLPDate3_TransStAcceptDate.Text = dtDisMain.Rows[0]["TRANS_ST_ACCEPT_DATE"].ToString();
                SLP_SLPDate4_ApproveDate.Text = dtDisMain.Rows[0]["APPROVE_DATE"].ToString();
                SLP_EnumBase1.Text = dtDisMain.Rows[0]["DATA_SOURCE"].ToString();
                txt_POSourceNo.Text = dtDisMain.Rows[0]["PO_SOURCE_NO"].ToString();
            }
            else
            {
                CurrentPageMode = PageCurrentMode.Query;
                throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!");
            }

            currentGvModeDisItem = CurrentGridviewMode.ReadOnly;

            gv_DisItem.DataSource = dtDisItem;
            gv_DisItem.DataBind();

            if (dtDisItem != null && dtDisItem.Rows.Count > 0)
            {
                s_ITEM = dtDisItem.Rows[0]["ITEM"].ToString().Trim(); ;
                s_PERIOD = dtDisItem.Rows[0]["PERIOD"].ToString().Trim(); ;
                s_ITEM_NAME = dtDisItem.Rows[0]["ITEM_NAME"].ToString().Trim(); ;
                s_PMA = dtDisItem.Rows[0]["PMA"].ToString().Trim(); ;
                s_ROOT_NO = dtDisItem.Rows[0]["ROOT_NO"].ToString().Trim(); ;
                s_PATTERN = dtDisItem.Rows[0]["PATTERN_NO"].ToString().Trim(); ;
            }

            string strFilter = string.Format(" ITEM='{0}' and PERIOD='{1}' ", s_ITEM, s_PERIOD);
            DataView dv = dtDisStoreAll.DefaultView;
            dv.RowFilter = strFilter;

            dtDisStore = dv.ToTable().Copy();

            currentGvModeDisStore = CurrentGridviewMode.ReadOnly;

            gv_DisStore.DataSource = dtDisStore;
            gv_DisStore.DataBind();


            CountGvDisStoreInfo();
            #endregion

            #endregion
            //}

            if (CurrentPageMode == PageCurrentMode.Readonly)
            {
                CheckConfirmOrRemove();
            }

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

        #endregion
    }
Exemplo n.º 2
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
    }
Exemplo n.º 3
0
    protected void gv_DisItem_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        #region
        try
        {
            Int32 iRowIndex;
            Int32.TryParse(e.CommandArgument.ToString(), out iRowIndex);

            if (e.CommandName == "View")
            {

                s_ITEM = ((Label)gv_DisItem.Rows[iRowIndex].FindControl("lbl_ITEM")).Text;
                s_PERIOD = ((Label)gv_DisItem.Rows[iRowIndex].FindControl("lbl_PERIOD")).Text;

                string strFilter = string.Format(" ITEM='{0}' and PERIOD='{1}' ", s_ITEM, s_PERIOD);

                if (dtDisStoreAll != null)
                {
                    DataView dv = dtDisStoreAll.DefaultView;
                    dv.RowFilter = strFilter;
                    dtDisStore = dv.ToTable().Copy();
                    gv_DisStore.DataSource = dtDisStore;
                }

                gv_DisStore.DataBind();

                CountGvDisStoreInfo();

                if (CurrentPageMode != PageCurrentMode.Readonly)
                    SwitchGvAddNewBtn(true, true, true);
                else
                    SwitchGvAddNewBtn(false, false, false);

                if (ConfirmIsTrueAndRemoveIsFalse)
                {
                    btn_Confirm.Enabled = false;
                    btn_Remove.Enabled = true;
                    btn_Edit.Enabled = false;
                    btn_Delete.Enabled = false;
                }


                if (s_DIS_NO != "" && btn_Confirm.Enabled == false)
                {
                    ALOModel.MaintainDisCRMRecord BCO2 = new ALOModel.MaintainDisCRMRecord(ConnectionDB);
                    ParameterList.Clear();
                    ParameterList.Add(s_DIS_NO == "" ? null : s_DIS_NO);
                    DataTable dtTemp = BCO2.QueryDisCRMItemByDisNo(ParameterList);
                    if (dtTemp != null && dtTemp.Rows.Count > 0)
                    {
                        gv_DisItem.DataSource = dtTemp;
                        gv_DisItem.DataBind();
                    }
                }

            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Exemplo n.º 4
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
    }