Example #1
0
    /// <summary>
    /// 將變更後的內部變量this.CallBackValue返回給前台JavaScript方法ReceiveServerData(string Value)。

    /// </summary>
    /// <returns></returns>
    string ICallbackEventHandler.GetCallbackResult()
    {
        if (CallBackValue != string.Empty)
        {
            try
            {
                #region 取得頁面元件
                TextBox txt_up_CHAN_NO = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxCode");//通路
                TextBox txt_up_CHAN_NAME = (TextBox)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("TextBoxName");//通路名稱

                TextBox txt_up_STORE = (TextBox)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("TextBoxCode");//門市

                TextBox txt_up_Z_O = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxCode");//營業所
                TextBox txt_up_Z_O_NAME = (TextBox)((ASP.sys_slp_slp_codefile_ascx)slp_up_Z_O).FindControl("TextBoxName");//營業所名稱

                TextBox txt_up_BUSDATE = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("TextBoxCode");//訂單日期
                TextBox txt_up_SALE_ID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxCode");//營業人員
                TextBox txt_up_SALE_NAME = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("TextBoxName");//營業人員名稱

                TextBox txt_up_BUSUID = (TextBox)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("TextBoxCode");//訂單維護者

                Image img_up_CHAN_NO = (Image)((ASP.stm_slp_slp_storechain_ascx)slp_up_CHAN_NO).FindControl("Image1");//通路img
                Image img_up_STORE = (Image)((ASP.stm_slp_slp_store_ascx)slp_up_STORE).FindControl("Image1");//門市img
                Image img_up_BUSDATE = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_up_BUSDATE).FindControl("Image1");//訂單日期img
                Image img_up_SALE_ID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_SALE_ID).FindControl("Image1");//營業人員img
                Image img_up_BUSUID = (Image)((ASP.sys_slp_slp_user_ascx)slp_up_BUSUID).FindControl("Image1");//訂單維護者img
                Image img_down_ITEM = (Image)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("Image1");//品號img
                Image img_down_REQUEST_QTY = (Image)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("Image1");//訂貨量img
                Image img_down_RTN_DDL = (Image)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("Image1");//退書截止日img

                TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號
                TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名
                TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量
                TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱
                TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日
                CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂
                #endregion
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Remove(0, sb.Length);
                CallBackValue = CallBackValue.Trim();
                string[] s_Client_String = System.Text.RegularExpressions.Regex.Split(CallBackValue, "<partition>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                ArrayList ParameterList = new ArrayList();//20091117

                #region 新增模式下異動欄位[門市]

                if (s_Client_String[0] == "新增模式下異動欄位[門市]")
                {
                    if (dtChainPOSetting != null)
                    { dtChainPOSetting = null; }

                    s_STORE = s_Client_String[1].ToString().Trim();//門市
                    s_CHAN_NO = s_Client_String[2].ToString().Trim();//通路

                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//門市
                    ParameterList.Add(s_Client_String[2]);//通路
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.MaintainStore bco = new BCO.MaintainStore(ConntionDB);
                    dt_Return = bco.QUERY_STORE_BY_STOREANDCHAN(ParameterList);

                    #endregion

                    #region 設定回傳Client端資訊
                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增模式下異動欄位[門市]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無門市資料<partition>");
                        sb.Append(txt_up_STORE.ClientID + "<partition>");//設定焦點的欄位
                        sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");
                        sb.Append(txt_up_Z_O.ClientID + "<partition>");
                        sb.Append(txt_up_SALE_ID.ClientID);
                    }
                    else
                    {
                        sb.Append("新增模式下異動欄位[門市]<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["CHAN_NO"].ToString() + "<partition_Detail>" + txt_up_CHAN_NO.ClientID + "<partition>");
                        sb.Append(dt_Return.Rows[0]["Z_O"].ToString() + "<partition_Detail>" + txt_up_Z_O.ClientID + "<partition>");
                        //sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID);
                        sb.Append(dt_Return.Rows[0]["SAL_ID"].ToString() + "<partition_Detail>" + txt_up_SALE_ID.ClientID + "<partition>");

                        sb.Append("<partition_Detail>" + txt_up_CHAN_NAME.ClientID + "<partition>");
                        sb.Append("<partition_Detail>" + txt_up_Z_O_NAME.ClientID + "<partition>");
                        sb.Append("<partition_Detail>" + txt_up_SALE_NAME.ClientID);

                        #region 取得通路PO控制設定

                        GetChainPOSetting(dt_Return.Rows[0]["CHAN_NO"].ToString(),
                                          dt_Return.Rows[0]["STORE"].ToString());

                        #endregion
                    }
                    #endregion
                }

                #endregion

                #region 新增或編輯模式下異動欄位[二段碼]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[二段碼]")
                {
                    #region 從資料庫查詢資料:群分類、品號、期別

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_Client_String[2]);//一段碼
                    ParameterList.Add(s_Client_String[3]);//二段碼

                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return = bco.QueryItemPeriodInfoByBarcode(ParameterList);

                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("此一段碼/二段碼不存在對應商品期別資訊,請重新輸入<partition>");
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(txt_down_RTN_DDL.ClientID);
                    }
                    else
                    {
                        sb.Append("新增或編輯模式下異動欄位[二段碼]<partition>");
                        sb.Append("TRUE<partition>");
                        sb.Append(dt_Return.Rows[0]["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(dt_Return.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);

                        //期別或品號有異動時,重取庫存
                        if (s_ITEM != dt_Return.Rows[0]["ITEM"].ToString() ||
                            s_PERIOD != dt_Return.Rows[0]["PERIOD"].ToString()
                           )

                        { dtStock = null; }
                        s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();
                        s_ITEM = dt_Return.Rows[0]["ITEM"].ToString();
                        s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString();

                        GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[一段碼]onchange

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[一段碼]onchange")
                {
                    #region  根據一段碼帶出品號,最大發行期別,二段碼
                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_STORE);//通路
                    ParameterList.Add(s_Client_String[3]);//一段碼
                    ParameterList.Add(string.Empty);//二段碼
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return = bco.QueryItemPeriodInfoByBarcode2(ParameterList);


                    #endregion

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("此一段碼不存在已發行對應商品期別資訊,請重新輸入<partition>");
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                        sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位

                    }
                    else
                    {
                        if (dt_Return.Rows[0]["CAN_DELIVER"].ToString() == "1")
                        {
                            //期別或品號有異動時,重取庫存
                            dtStock = null;
                            s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();
                            s_ITEM = dt_Return.Rows[0]["ITEM"].ToString();
                            s_PERIOD = dt_Return.Rows[0]["PERIOD"].ToString();

                            GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);

                            sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");//找到對應商品期別資訊,設定商品期別
                            sb.Append("TRUE<partition>");
                            sb.Append(s_ITEM + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");
                            sb.Append(dt_Return.Rows[0]["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                            sb.Append(DateTime.Parse(dt_Return.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>");
                            sb.Append(s_PERIOD + "<partition_Detail>" + this.txt_down_PERIOD.ClientID);
                        }
                        else
                        {
                            sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                            sb.Append("FALSE<partition>");
                            sb.Append("此一段碼對應品號" + s_ITEM + "客服區域限制不可出貨,請重新輸入<partition>");
                            sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");
                            sb.Append(txt_down_ITEM.ClientID + "<partition>");
                            sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");
                            sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");
                            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                            sb.Append(this.txt_down_BARCODE.ClientID);//設定焦點的欄位
                        }
                    }
                    //sb.Append("新增或編輯模式下異動欄位[一段碼]onchange<partition>");
                    //sb.Append("TRUE<partition>");
                    //sb.Append(txt_down_ITEM.ClientID + "<partition>"); //異動一段碼時,清空 Item、 Period 、退貨日、儲區、逾期客訂,設定焦點到ITEM
                    //sb.Append(this.txt_down_PERIOD.ClientID + "<partition>"); //期別
                    //sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>"); //二段碼
                    //sb.Append(txt_down_RTN_DDL.ClientID + "<partition>"); //預定退貨日
                    //sb.Append(this.txt_down_RECOMMAND_LOCATION);//建議儲區

                }

                #endregion

                #region 新增或編輯模式下異動欄位[品號/品名]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[品號/品名]")
                {
                    //s_PMA = string.Empty;//大分類
                    //s_ROOT_NO = string.Empty;//群分類
                    s_ITEM = s_Client_String[1].ToString().Trim();//品號

                    #region 從資料庫查詢資料

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//品號
                    ParameterList.Add(s_CHAN_NO);//通路
                    ParameterList.Add(s_STORE);//門市                    
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return_1 = new DataTable();
                    BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);
                    dt_Return_1 = bco.GetMaxDeiveryPeriod2(ParameterList);

                    #endregion

                    if (dt_Return_1 == null || dt_Return_1.Rows.Count == 0 ||
                        dt_Return_1.Rows[0]["PERIOD"].ToString() == string.Empty)
                    {
                        sb.Length = 0;
                        sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("查無資料<partition>");
                        sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位

                    }
                    else
                    {
                        //設定品號、期別
                        s_ITEM = s_Client_String[1];
                        s_PERIOD = dt_Return_1.Rows[0]["PERIOD"].ToString();
                        //設定群分類、大分類
                        s_PMA = dt_Return_1.Rows[0]["PMA"].ToString();//大分類
                        s_ROOT_NO = dt_Return_1.Rows[0]["ROOT_NO"].ToString();//群分類

                        if (dt_Return_1.Rows[0]["CAN_DELIVER"].ToString() == "1")
                        {
                            sb.Length = 0;
                            sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                            sb.Append("TRUE<partition>");
                            sb.Append(dt_Return_1.Rows[0]["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID);
                        }
                        else
                        {
                            sb.Length = 0;
                            sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                            sb.Append("FALSE<partition>");
                            sb.Append("客服區域限制不可出貨<partition>");
                            sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位
                        }

                        #region  OLD 取得商品主檔資訊

                        //DataTable dt_Return_2 = new DataTable();

                        //ParameterList.Clear();
                        //BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", s_Client_String[1], "=", "and");

                        //BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                        //dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList);

                        //if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0)
                        //{
                        //    s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類

                        //    s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類
                        //}
                        //else
                        //{
                        //    sb = sb.Remove(0, sb.Length);
                        //    sb.Append("新增或編輯模式下異動欄位[品號/品名]<partition>");
                        //    sb.Append("FALSE<partition>");
                        //    sb.Append("商品主檔中無對應品號<partition>");
                        //    sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位

                        //}

                        #endregion
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[期別]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]")
                {
                    //期別或品號有異動時,重取庫存
                    if (s_ITEM != s_Client_String[3].ToString().Trim() ||
                          s_PERIOD != s_Client_String[4].ToString().Trim()
                       )

                    { dtStock = null; }

                    s_CHAN_NO = s_Client_String[1].ToString().Trim();//通路
                    s_STORE = s_Client_String[2].ToString().Trim();//門市

                    if (s_ITEM != s_Client_String[3].ToString().Trim())
                    {

                    }
                    s_ITEM = s_Client_String[3].ToString().Trim();//品號
                    s_PERIOD = s_Client_String[4].ToString().Trim();//期別


                    #region 檢查書店是否有未結案同品項訂單


                    if (s_Client_String[8] == string.Empty)
                    {

                        #region 從資料庫查詢資料

                        ParameterList.Clear();
                        ParameterList.Add(s_Client_String[1]);//通路
                        ParameterList.Add(s_Client_String[2]);//門市

                        ParameterList.Add(s_Client_String[3]);//品號
                        ParameterList.Add(s_Client_String[4]);//期別
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(this.txt_up_CODE.Text);//訂單單號

                        DataTable dt_Return_1 = new DataTable();
                        BCO.RecordCRMOrder bco_Record = new BCO.RecordCRMOrder(ConntionDB);
                        dt_Return_1 = bco_Record.CheckOrderItemExist(ParameterList);

                        #endregion

                        if (dt_Return_1.Rows.Count > 0)
                        {
                            sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                            sb.Append("檢查書店是否有未結案同品項訂單<partition>");
                            sb.Append("該門市已存在未結案之同品項訂單於訂單標號:[" + dt_Return_1.Rows[0]["CRM_REQUEST_NO"].ToString() + "],不可新增<partition>");
                            sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位

                            sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                            sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                            sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                            sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                            sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                            sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                            sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                            sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                            sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                            sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                            return sb.ToString();
                        }
                    }

                    #endregion

                    #region 檢查牌價是否已經正確建立

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[2]);//門市
                    ParameterList.Add(s_Client_String[3]);//品號
                    ParameterList.Add(s_Client_String[4]);//期別
                    ParameterList.Add(DateTime.Today.ToString("yyyy/MM/dd")); // 系統日
                    ParameterList.Add(Session["UID"].ToString());
                    PIC.VDS2G.BSM.ALO.ProcessALOCommon co_process = new PIC.VDS2G.BSM.ALO.ProcessALOCommon(ConntionDB);
                    string sRes = co_process.CheckStAcceptDisPrice(ParameterList);
                    //bool bRes = co_process.CheckStAcceptDisPrice(ParameterList, null);
                    if (sRes != string.Empty)
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("檢查牌價是否已經正確建立<partition>");
                        sb.Append("期別" + s_PERIOD + "牌價未生效[" + sRes + "],不可新增<partition>");
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區
                        return sb.ToString();
                    }

                    #endregion

                    #region 設定二段碼、退書截止日與逾期客訂

                    string s_down_BARCODE = string.Empty;//一段碼
                    string s_down_PERIOD_BARCODE = string.Empty;//二段碼

                    string s_down_RTN_DDL = string.Empty;//退書截止日

                    s_down_BARCODE = s_Client_String[5];
                    s_down_PERIOD_BARCODE = s_Client_String[6];
                    s_down_RTN_DDL = s_Client_String[7];
                    BCO.QueryCRMCommon bco_Common = new BCO.QueryCRMCommon(ConntionDB);

                    // 不管原來有沒有值,只要品號改變,都重新查詢
                    //if (s_Client_String[5] == string.Empty ||//一段碼
                    //    s_Client_String[6] == string.Empty ||//二段碼

                    //    s_Client_String[7] == string.Empty)//退書截止日
                    //{
                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//通路
                    ParameterList.Add(s_Client_String[3]);//品號
                    ParameterList.Add(s_Client_String[4]);//期別
                    ParameterList.Add(Session["UID"].ToString());

                    DataTable dt_Return_2 = new DataTable();

                    dt_Return_2 = bco_Common.QueryItemPeriodInfo(ParameterList);

                    if (dt_Return_2.Rows.Count > 0)//有找到資料
                    {
                        s_down_BARCODE = dt_Return_2.Rows[0]["BARCODE"].ToString();
                        s_down_PERIOD_BARCODE = dt_Return_2.Rows[0]["PERIOD_BARCODE"].ToString();
                        s_down_RTN_DDL = DateTime.Parse(dt_Return_2.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd");

                    }
                    else//查無資料
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("設定二段碼、退書截止日與逾期客訂<partition>");
                        sb.Append("查無[一段碼][二段碼][退書截止日],無法新增<partition>");
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//設定焦點的欄位

                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                        return sb.ToString();
                    }
                    //}

                    #endregion

                    #region 逾期客訂確認

                    TimeSpan time = new TimeSpan(11, 00, 00);
                    bool b_down_IS_OVERDUE = false;
                    DateTime d_Now;
                    DateTime d_RTN_DDL;

                    d_Now = DateTime.Now;
                    d_RTN_DDL = DateTime.Parse(s_down_RTN_DDL);

                    if (d_Now.DayOfWeek == DayOfWeek.Saturday ||
                        d_Now.DayOfWeek == DayOfWeek.Sunday ||
                        (d_Now.DayOfWeek == DayOfWeek.Friday && d_Now.TimeOfDay.CompareTo(time) >= 0))
                    {
                        //if (d_RTN_DDL.AddDays(-5).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0)
                        if (d_RTN_DDL.AddDays(-5).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        {
                            b_down_IS_OVERDUE = true;
                            b_IS_OVERDUE = true;
                        }
                    }
                    else
                    {
                        //if (d_RTN_DDL.AddDays(-2).ToShortDateString().CompareTo(d_Now.ToShortDateString()) <= 0)
                        if (d_RTN_DDL.AddDays(-2).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        {
                            b_down_IS_OVERDUE = true;
                            b_IS_OVERDUE = true;
                        }
                    }

                    //[@逾期客訂].檢查結果為True時,顯示Confirm訊息『商品已逾期,不可退貨,確定要新增?』

                    //使用者確認要新增時,可繼續編輯。

                    //使用者選擇不新增時,取消本筆明細新增。

                    if (b_down_IS_OVERDUE == true)
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("[逾期客訂]檢查結果為TRUE<partition>");
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(s_ROOT_NO + "<partition>");//群分類

                        sb.Append(s_Client_String[3] + "<partition>");//品號
                        sb.Append(s_Client_String[4] + "<partition>");//期別
                        sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日

                        return sb.ToString();
                    }
                    else
                    {
                        sb.Append("新增或編輯模式下異動欄位[期別]<partition>");
                        sb.Append("[逾期客訂]檢查結果為FALSE<partition>");
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(s_down_BARCODE + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(s_down_PERIOD_BARCODE + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                        sb.Append(s_down_RTN_DDL + "<partition_Detail>" + txt_down_RTN_DDL.ClientID);//退書截止日
                    }

                    #endregion

                    #region 取得庫存資訊

                    GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]);

                    #endregion
                }

                #endregion

                #region 新增或編輯模式下異動欄位[期別]Confirm後

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[期別]Confirm後")
                {
                    if (dtStock != null)
                    { dtStock = null; }

                    if (s_Client_String[1] == "TRUE")//繼續編輯。
                    {
                        #region 取得商品主檔資訊

                        if (s_PMA == String.Empty || s_ROOT_NO == String.Empty)
                        {
                            DataTable dt_Return_2 = new DataTable();

                            ParameterList.Clear();
                            BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", slp_down_ITEM.Text, "=", "and");

                            BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                            dt_Return_2 = bco_itm.QuerySKUByFind_1(ParameterList);

                            if (dt_Return_2 != null && dt_Return_2.Rows.Count != 0)
                            {
                                s_PMA = dt_Return_2.Rows[0]["PMA"].ToString();//大分類

                                s_ROOT_NO = dt_Return_2.Rows[0]["ROOT_NO"].ToString();//群分類
                            }
                            else
                            {
                                sb = sb.Remove(0, sb.Length);
                                sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>");
                                sb.Append("FALSE<partition>");
                                sb.Append("商品主檔中無對應品號<partition>");
                                sb.Append(txt_down_ITEM.ClientID);//設定焦點的欄位
                            }
                        }

                        #endregion

                        #region 取得庫存資訊

                        GetStock(s_ROOT_NO, s_Client_String[3], s_Client_String[4]);
                        #endregion
                    }
                    else if (s_Client_String[1] == "FALSE")//取消本筆明細新增。
                    {
                        #region 清空靜態變數

                        dtStock = null;//異動欄位[期別]
                        s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                        s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                        s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                        #endregion

                        #region 計算 dt_Detail 的筆數


                        int i_dt_Detail_Count = 0;
                        if (dt_Detail != null)
                        {
                            if (dt_Detail.GetChanges(DataRowState.Deleted) == null)
                            { i_dt_Detail_Count = dt_Detail.Rows.Count; }
                            else
                            { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; }
                        }

                        #endregion

                        sb.Append("新增或編輯模式下異動欄位[期別]Confirm後<partition>");
                        sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數
                        sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus
                        sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                        sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                        sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                        sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                        sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                        sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼
                        sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                        sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                        sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量
                        sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱
                        sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                        sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                        sb.Append(txt_up_STORE.ClientID + "<partition>");//門市
                        sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所
                        sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期
                        sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員
                        sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者
                        sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源
                        sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設
                        sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號
                        sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號
                        sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img
                        sb.Append(img_up_STORE.ClientID + "<partition>");//門市img
                        sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img
                        sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img
                        sb.Append(img_up_BUSUID.ClientID);//訂單維護者img
                    }
                }

                #endregion

                #region 新增或編輯模式下異動欄位[訂貨量]

                else if (s_Client_String[0] == "新增或編輯模式下異動欄位[訂貨量]")
                {

                    #region 判斷庫存是否足夠
                    if ((dtStock == null) || (dtStock.Rows.Count < 1))
                    {

                        GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    }
                    if (((dtStock == null) || (dtStock.Rows.Count < 1)) &&
                        (s_ROOT_NO != "2"))
                    {

                        sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append("庫存量不足,請取消新增<partition>");
                        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        return sb.ToString();
                    }
                    #endregion

                    DataView dvStock = new DataView(dtStock.Copy());

                    s_SRC_LOCATE_TYPE = string.Empty;
                    int i_REQUEST_QTY = 0;//畫面上使用者輸入的"訂貨量"
                    int i_ONHD_QTY = 0;//現有庫存量
                    int i_RESERVE_QTY = 0;//配本保留數
                    int i_Final_QTY = 0;//庫存儲區可配量
                    int i_DIS_ENABLE = 0;//可配量
                    string s_SRC_LOCATE_NO = string.Empty;//VDS_CRM_ORDER_DETL.SRC_LOCATE_NO欄位

                    i_REQUEST_QTY = int.Parse(s_Client_String[1]);

                    // 2009-07-30 cyshu 修改,逾期客訂可取退貨儲區庫存
                    #region [@群分類]=1(雜誌) 時

                    //if (s_ROOT_NO == "1" && s_Client_String[2] == "false")
                    if (s_ROOT_NO == "1")
                    {
                        #region 先檢查庫存儲區可用庫存

                        dvStock.RowFilter = "LOCATETYPE = '2'";
                        dvStock.Sort = "ONHD_QTY DESC";
                        #region Old Source
                        //if (dvStock.Count > 0)
                        //{
                        //    i_ONHD_QTY = 0;
                        //    i_RESERVE_QTY = 0;
                        //    for (int i = 0; i < dvStock.Count; i++)
                        //    {
                        //        i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                        //        i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                        //    }
                        //}
                        #endregion

                        #region new code
                        i_ONHD_QTY = 0;
                        i_RESERVE_QTY = 0;
                        bool b_Locate_Stock = false; //庫存儲區
                        for (int i = 0; i < dvStock.Count; i++)
                        {
                            i_ONHD_QTY = int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                            i_RESERVE_QTY = int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                            i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量
                            if (i_Final_QTY >= i_REQUEST_QTY)
                            {
                                s_SRC_LOCATE_TYPE = "2";
                                s_SRC_LOCATE_NO = dvStock[i]["LOCATE_NO"].ToString();//現有庫存儲區
                                try
                                {
                                    i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                                }
                                catch { i_DIS_ENABLE = 0; }
                                b_Locate_Stock = true;
                                break;
                            }
                        }
                        if (!b_Locate_Stock) //庫存儲區庫存不足
                        {

                            if (s_PMA == "13" ||
                                s_PMA == "14" ||
                                s_PMA == "15" ||
                                s_PMA == "16")
                            {
                                #region 外雜
                                sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                sb.Append("FALSE<partition>");
                                sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>");
                                sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位

                                sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                                return sb.ToString();
                                #endregion
                            }
                            else
                            {
                                #region 檢查退貨儲區可用庫存

                                i_ONHD_QTY = 0;
                                i_RESERVE_QTY = 0;
                                i_Final_QTY = 0;
                                i_DIS_ENABLE = 0;
                                s_SRC_LOCATE_NO = string.Empty;

                                dvStock.RowFilter = "LOCATETYPE = '1'";
                                for (int i = 0; i < dvStock.Count; i++)
                                {
                                    i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                                    i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                                }

                                i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                                if (i_Final_QTY >= i_REQUEST_QTY)
                                {
                                    s_SRC_LOCATE_TYPE = "1";//退貨儲區
                                    s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                                    i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                                }
                                else
                                {
                                    sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                    sb.Append("FALSE<partition>");
                                    sb.Append("庫存量不足,請取消新增<partition>");
                                    sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                                    sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                                    return sb.ToString();
                                }
                                #endregion
                            }

                        }
                        #endregion new code

                        #region old code2
                        //i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;//庫存儲區可配量

                        //// 庫存儲區可配量 >= 訂量時,設定建議儲區 = 庫存儲區
                        //if (i_Final_QTY >= i_REQUEST_QTY)
                        //{
                        //    s_SRC_LOCATE_TYPE = "2";//庫存儲區
                        //    s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                        //    try
                        //    {
                        //        i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                        //    }
                        //    catch { i_DIS_ENABLE = 0; }
                        //}
                        //else
                        //{
                        //    if (s_PMA == "13" ||
                        //        s_PMA == "14" ||
                        //        s_PMA == "15" ||
                        //        s_PMA == "16")
                        //    {
                        //        sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        //        sb.Append("FALSE<partition>");
                        //        sb.Append("外雜D儲區庫存量不足,無法新增訂單<partition>");
                        //        sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位

                        //        sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        //        return sb.ToString();
                        //    }
                        //    else
                        //    {
                        //        #region 檢查退貨儲區可用庫存

                        //        i_ONHD_QTY = 0;
                        //        i_RESERVE_QTY = 0;
                        //        i_Final_QTY = 0;
                        //        i_DIS_ENABLE = 0;
                        //        s_SRC_LOCATE_NO = string.Empty;

                        //        dvStock.RowFilter = "LOCATETYPE = '1'";
                        //        for (int i = 0; i < dvStock.Count; i++)
                        //        {
                        //            i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                        //            i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                        //        }

                        //        i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                        //        if (i_Final_QTY >= i_REQUEST_QTY)
                        //        {
                        //            s_SRC_LOCATE_TYPE = "1";//退貨儲區
                        //            s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                        //            i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                        //        }
                        //        else
                        //        {
                        //            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                        //            sb.Append("FALSE<partition>");
                        //            sb.Append("庫存量不足,請取消新增<partition>");
                        //            sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//設定焦點的欄位 
                        //            sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);

                        //            return sb.ToString();
                        //        }

                        //        #endregion
                        //    }
                        //}

                        #endregion old code2
                        #endregion
                    }

                    #endregion

                    #region [@群分類]=2(圖書)

                    else
                    {
                        dvStock.RowFilter = "LOCATETYPE = '2'";
                        dvStock.Sort = "ONHD_QTY DESC";

                        if (dvStock.Count > 0)
                        {
                            // 先作預設值
                            s_SRC_LOCATE_TYPE = "2"; // 庫存儲區
                            s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區

                            for (int i = 0; i < dvStock.Count; i++)
                            {
                                i_ONHD_QTY += int.Parse(dvStock[i]["ONHD_QTY"].ToString());
                                i_RESERVE_QTY += int.Parse(dvStock[i]["RESERVE_QTY"].ToString());
                            }

                            i_Final_QTY = i_ONHD_QTY - i_RESERVE_QTY;

                            if (i_Final_QTY >= i_REQUEST_QTY)
                            {
                                s_SRC_LOCATE_TYPE = "2";//庫存儲區
                                s_SRC_LOCATE_NO = dvStock[0]["LOCATE_NO"].ToString();//現有庫存量最大的儲區
                                i_DIS_ENABLE = int.Parse(dvStock[0]["ONHD_QTY"].ToString()) - int.Parse(dvStock[0]["RESERVE_QTY"].ToString());
                            }
                            else //圖書庫存不足仍可新增
                            {
                                s_SRC_LOCATE_TYPE = "2";//庫存儲區
                                s_SRC_LOCATE_NO = "D";
                                i_DIS_ENABLE = 0;
                                sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                                sb.Append("TRUE_ALERT<partition>");
                                sb.Append("圖書庫存不足,確認要新增?<partition>");
                                sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                                sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);
                                return sb.ToString();
                            }
                        }
                        else //圖書庫存不足仍可新增
                        {
                            #region 圖書庫存不足仍可新增
                            s_SRC_LOCATE_TYPE = "2";//庫存儲區
                            s_SRC_LOCATE_NO = "D";
                            i_DIS_ENABLE = 0;
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_ALERT<partition>");
                            sb.Append("圖書庫存不足,確認要新增?<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);
                            return sb.ToString();
                            #endregion
                        }
                    }

                    #endregion

                    if (sb.ToString() == string.Empty)
                    {
                        if (i_REQUEST_QTY > 100)
                        {
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_ALERT<partition>");
                            sb.Append("訂貨量大於100<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);

                            return sb.ToString();
                        }
                        else
                        {
                            sb.Append("新增或編輯模式下異動欄位[訂貨量]<partition>");
                            sb.Append("TRUE_NO_ALERT<partition>");
                            sb.Append(s_SRC_LOCATE_NO + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");
                            sb.Append(i_DIS_ENABLE.ToString() + "<partition_Detail>" + this.hid_DIS_ENABLE.ClientID);

                            return sb.ToString();
                        }
                    }
                }

                #endregion

                #region 新增或編輯模式按下明細區[取消]鈕

                else if (s_Client_String[0] == "新增或編輯模式按下明細區[取消]鈕")
                {
                    #region 清空靜態變數

                    dtStock = null;//異動欄位[期別]
                    s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                    s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                    s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])
                    sb.Remove(0, sb.Length);

                    #endregion

                    #region 計算 dt_Detail 的筆數

                    int i_dt_Detail_Count = 0;
                    if (dt_Detail != null)
                    {
                        if (dt_Detail.GetChanges(DataRowState.Deleted) == null)
                        { i_dt_Detail_Count = dt_Detail.Rows.Count; }
                        else
                        { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; }
                    }

                    #endregion

                    sb.Append("新增或編輯模式按下明細區[取消]鈕<partition>");
                    sb.Append(i_dt_Detail_Count.ToString() + "<partition>");//dt_Detail的筆數
                    sb.Append(this.hid_PageStatus.ClientID + "<partition>");//hid_PageStatus
                    sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                    sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                    sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                    sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                    sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼
                    sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                    sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量
                    //sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱
                    sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                    sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                    sb.Append(txt_up_STORE.ClientID + "<partition>");//門市
                    sb.Append(txt_up_Z_O.ClientID + "<partition>");//營業所
                    sb.Append(txt_up_BUSDATE.ClientID + "<partition>");//訂單日期
                    sb.Append(txt_up_SALE_ID.ClientID + "<partition>");//營業人員
                    sb.Append(txt_up_BUSUID.ClientID + "<partition>");//訂單維護者
                    sb.Append(((DropDownList)((ASP.sys_slp_slp_enumbase_ascx)drop_up_ORDER_TYPE).FindControl("D1")).ClientID + "<partition>");//訂單來源
                    sb.Append(this.txt_up_PO_SOURCE_NO.ClientID + "<partition>");//PO單號預設
                    sb.Append(this.txt_up_CODE.ClientID + "<partition>");//訂單編號
                    sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");//流水編號
                    sb.Append(img_up_CHAN_NO.ClientID + "<partition>");//通路img
                    sb.Append(img_up_STORE.ClientID + "<partition>");//門市img
                    sb.Append(img_up_BUSDATE.ClientID + "<partition>");//訂單日期img
                    sb.Append(img_up_SALE_ID.ClientID + "<partition>");//營業人員img
                    sb.Append(img_up_BUSUID.ClientID);//訂單維護者img
                }

                #endregion

                #region 新增或編輯模式按下GridView[編輯]鈕


                else if (s_Client_String[0] == "新增或編輯模式按下GridView[編輯]鈕")
                {
                    DataRow dRow = dt_Detail.Select("ID = " + s_Client_String[1])[0];
                    string s_IS_OVERDUE;
                    //改為已擷轉仍可修改 
                    //if (dRow["TRANS_RESULT"].ToString() == "1")//已擷轉
                    //{ sb.Append("此筆訂單品項已擷轉,不可編輯或刪除\r\n"); }

                    if (dRow["STATUS"].ToString() == "75")//已結案
                    { sb.Append("此筆訂單品項已結案,不可編輯或刪除\r\n"); }

                    #region 編輯前檢查錯誤


                    if (sb.ToString() != string.Empty)
                    {
                        sb.Insert(0, "新增或編輯模式按下GridView[編輯]鈕_編輯前檢查FALSE<partition>");
                        return sb.ToString();
                    }

                    #endregion

                    #region 取得庫存
                    i_Curr_Order_Qty = 0;
                    s_ROOT_NO = dRow["ROOT_NO"].ToString(); //群分類
                    s_ITEM = dRow["ITEM"].ToString();    //品號
                    s_PERIOD = dRow["PERIOD"].ToString();  //期別
                    i_Curr_Order_Qty = (dRow["REQUEST_QTY"].ToString().Trim() == string.Empty) ? 0 : int.Parse(dRow["REQUEST_QTY"].ToString().Trim());
                    s_SRC_LOCATE_NO = dRow["SRC_LOCATE_NO"].ToString();//原儲區
                    //取得目前庫存
                    dtStock = null;
                    GetStock(s_ROOT_NO, s_ITEM, s_PERIOD);
                    //編輯模式下,可用庫存應加上原訂單需求量
                    AddStockForEditMode(s_SRC_LOCATE_NO, i_Curr_Order_Qty);
                    #endregion

                    #region 編輯前檢查正確
                    s_IS_OVERDUE = (dRow["IS_OVERDUE"].ToString() == "0") ? "false" : "true";

                    sb.Append("新增或編輯模式按下GridView[編輯]鈕_編輯前檢查TRUE<partition>");
                    sb.Append(txt_up_CHAN_NO.ClientID + "<partition>");//通路
                    sb.Append(txt_up_STORE.ClientID + "<partition>");//門市

                    sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                    sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                    sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                    sb.Append(s_IS_OVERDUE + "<partition_Detail>" + chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                    sb.Append(dRow["PO_SOURCE_NO"].ToString() + "<partition_Detail>" + this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                    sb.Append(dRow["BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                    sb.Append(dRow["PERIOD_BARCODE"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                    sb.Append(dRow["ITEM"].ToString() + "<partition_Detail>" + txt_down_ITEM.ClientID + "<partition>");//品號
                    sb.Append(dRow["ITEM_NAME"].ToString() + "<partition_Detail>" + txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                    sb.Append(dRow["PERIOD"].ToString() + "<partition_Detail>" + this.txt_down_PERIOD.ClientID + "<partition>");//期別
                    sb.Append(dRow["REQUEST_QTY"].ToString() + "<partition_Detail>" + txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                    //sb.Append(dRow["REQUEST_QTY"].ToString() + ".0000<partition_Detail>" + txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                    sb.Append(DateTime.Parse(dRow["RTN_DDL"].ToString()).ToString("yyyy/MM/dd") + "<partition_Detail>" + txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                    sb.Append(dRow["SRC_LOCATE_NO"].ToString() + "<partition_Detail>" + this.txt_down_RECOMMAND_LOCATION.ClientID + "<partition>");//建議儲區
                    sb.Append(dRow["ID"].ToString() + "<partition_Detail>" + this.hid_ID.ClientID);//hid_ID

                    #endregion
                }

                #endregion

                #region 新增或編輯模式按下明細區[新增明細]鈕

                else if (s_Client_String[0] == "新增或編輯模式按下明細區[新增明細]鈕")
                {
                    #region 清空靜態變數

                    dtStock = null;//異動欄位[期別]
                    s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                    s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                    s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                    #endregion
                }

                #endregion

                #region 新增模式異動欄位[流水編號]

                else if (s_Client_String[0] == "新增模式異動欄位[流水編號]")
                {
                    #region 檢查是否為有效流水編號


                    DataTable dt_Return = new DataTable();

                    ParameterList.Clear();
                    ParameterList.Add(s_Client_String[1]);//流水編號
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(DateTime.Now);

                    BCO.RecordCRMRecord bco = new BCO.RecordCRMRecord(ConntionDB);
                    dt_Return = bco.QueryCRMRecordByCode_CheckExist(ParameterList);

                    if (dt_Return.Rows.Count == 0)
                    {
                        sb.Append("新增模式異動欄位[流水編號]<partition>");
                        sb.Append("FALSE<partition>");
                        sb.Append(this.txt_up_CRM_NO.ClientID + "<partition>");
                        sb.Append("[流水編號]不為存在的有效編號");
                    }

                    #endregion
                }

                #endregion

                CallBackValue = sb.ToString();
            }
            catch (Exception ex)
            { CallBackValue = "發生例外錯誤<partition>" + ex.Message; }
        }

        return CallBackValue;
    }
Example #2
0
    /// <summary>
    /// DOWN BUTTON 更新鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_down_Update_Click(object sender, EventArgs e)
    {

        try
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            TextBox txt_down_ITEM = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxCode");//品號
            TextBox txt_down_ITEM_NAME = (TextBox)((ASP.itm_slp_slp_sku_ascx)slp_down_ITEM).FindControl("TextBoxName");//品名
            TextBox txt_down_REQUEST_QTY = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxCode");//訂貨量
            TextBox txt_down_REQUEST_QTY_NAME = (TextBox)((ASP.wui_slp_slp_slpquantity_ascx)slp_down_REQUEST_QTY).FindControl("TextBoxName");//訂貨量名稱
            TextBox txt_down_RTN_DDL = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)slp_down_RTN_DDL).FindControl("TextBoxCode");//退書截止日
            CheckBox chk_down_IS_OVERDUE = (CheckBox)((ASP.wui_slp_slp_boolean_ascx)slp_down_IS_OVERDUE).FindControl("C1");//逾期客訂
            //string SessionIDName = "CRM041_dt_Detail" + PageTimeStamp.Value;
            //if (Session[SessionIDName] != null) dt_Detail = (DataTable)Session[SessionIDName];
            if (this.hid_PageStatus.Value == "INSERT" ||
                this.hid_PageStatus.Value == "EDIT")
            {
                s_PMA = string.Empty;
                s_ROOT_NO = string.Empty;
                string s_Is_PO = string.Empty;

                sb.Remove(0, sb.Length);
                DataTable dt_Return = new DataTable();
                ArrayList ParameterList = new ArrayList();//20091117

                #region 依照品號取得所屬[群分類]、[大分類]

                ParameterList.Clear();
                BCO_ITM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ITEM", this.slp_down_ITEM.Text, "=", "and");

                BCO_ITM.MaintainSKU bco_itm = new BCO_ITM.MaintainSKU(ConntionDB);
                dt_Return = bco_itm.QuerySKUByFind_1(ParameterList);

                if (dt_Return != null && dt_Return.Rows.Count != 0)
                {
                    s_PMA = dt_Return.Rows[0]["PMA"].ToString();//大分類

                    s_ROOT_NO = dt_Return.Rows[0]["ROOT_NO"].ToString();//群分類

                }

                #endregion

                #region 判斷PO單號
                //確定PO單號存在
                GetChainPOSetting(this.slp_up_CHAN_NO.Text, this.slp_up_STORE.Text);
                DataView dvChainPOSetting = new DataView(dtChainPOSetting.Copy());
                dvChainPOSetting.RowFilter = "PMA = '" + s_PMA + "' and ROOT_NO = '" + s_ROOT_NO + "'";
                if (dvChainPOSetting.Count > 0)
                {
                    if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "1")//代表是依PO分單
                    { s_Is_PO = "TRUE"; }
                    else if (dvChainPOSetting[0]["IS_DIS_BYPO"].ToString() == "0")//代表不是依PO分單
                    { s_Is_PO = "FALSE"; }
                    // 2009-08-12 cyhsu add
                    if (this.slp_up_CHAN_NO.Text == "CB" && s_ROOT_NO == "1")
                    {
                        //當通路=誠品, 群分類=雜誌時,不管通路設定檔設定為何,都先規定要輸入PO單號
                        s_Is_PO = "TRUE";
                    }
                }

                //s_Is_PO = TRUE 代表是依PO分單>>[PO單號]欄位一定要填
                //s_Is_PO = FALSE 代表不是依PO分單>>[PO單號]欄位一定不能填
                //s_Is_PO = NULL 代表是依PO分單>>[PO單號]欄位可填可不填

                if (s_Is_PO == "TRUE")
                {
                    if (this.txt_down_PO_SOURCE_NO.Text.ToString().Length == 0)
                    //if (this.txt_down_PO_SOURCE_NO.Text.Trim() == string.Empty)
                    { sb.Append("PO單號不可空白"); }
                }
                else if (s_Is_PO == "FALSE")
                {
                    if (this.txt_down_PO_SOURCE_NO.Text.Trim() != string.Empty)
                    { sb.Append("PO單號不可有值"); }
                }

                if (GetStringLen(txt_down_PO_SOURCE_NO.Text.Trim()) > 20)
                { sb.Append("PO單號欄位輸入資料過長"); }

                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true);
                    return;
                }

                #endregion

                #region 判斷一段碼、二段碼是否屬於該品號、期別
                ParameterList.Clear();

                ParameterList.Add(this.slp_down_ITEM.Text); // ITEM
                ParameterList.Add(this.txt_down_PERIOD.Text);      // PERIOD
                ParameterList.Add(this.txt_down_BARCODE.Text); // 一段碼
                ParameterList.Add(this.txt_down_PERIOD_BARCODE.Text);      // 二段碼
                ParameterList.Add(Session["UID"].ToString());

                BCO.QueryCRMCommon co_common = new BCO.QueryCRMCommon(ConntionDB);
                bool b_CheckRes;
                b_CheckRes = co_common.CheckItemPeriodBarcode(ParameterList);
                if (!b_CheckRes)
                {
                    sb.Remove(0, sb.Length);
                    sb.AppendFormat("一段碼[{2}]、二段碼[{3}]不屬於品號[{0}]、期別[{1}]!",
                                    this.slp_down_ITEM.Text,
                                    this.txt_down_PERIOD.Text,
                                    this.txt_down_BARCODE.Text,
                                    this.txt_down_PERIOD_BARCODE.Text);
                }

                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + this.txt_down_PO_SOURCE_NO.ClientID + "'].focus();", true);
                    return;
                }

                #endregion

                #region 檢查是否可新增
                bool bCheck = CheckOrderDetail(this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text);
                if (!bCheck && hid_ID.Value == string.Empty)
                {
                    sb.Remove(0, sb.Length);
                    sb.AppendFormat("品號[{0}]、期別[{1}]已存在,不可重複新增!", this.slp_down_ITEM.Text, this.txt_down_PERIOD.Text);
                }
                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sb.ToString() + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true);
                    return;
                }
                string sCheck = CheckCanUpdate(s_CHAN_NO, s_STORE,
                                               this.slp_down_ITEM.Text,
                                               this.txt_down_PERIOD.Text,
                                               txt_down_RTN_DDL.Text,
                                               this.txt_up_CODE.Text);

                if (sCheck != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "alert('" + sCheck + "');document.all['" + txt_down_ITEM.ClientID + "'].focus();", true);
                    return;
                }

                #endregion


                // 為了解決頁面儲區空白的問題先暫時設定睡眠對應。
                for (int i = 0; i < 10; i++)
                {
                    if (this.txt_down_RECOMMAND_LOCATION.Text != String.Empty)
                    { break; }
                    System.Threading.Thread.Sleep(500);
                }

                #region 更新明細暫存資訊

                #region 新增狀態,若是第一筆資料,建立 TEMP TABLE

                if (this.hid_PageStatus.Value == "INSERT" && hid_ID.Value == string.Empty)
                {
                    if (dt_Detail == null)
                    {
                        DataTable dtTmp = new DataTable();
                        ParameterList.Clear();
                        ParameterList.Add(Session["UID"].ToString());

                        BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                        dtTmp = bco.QUERY_CRM041_DETL_SCHEMA(ParameterList);

                        DataColumn dcol1 = new DataColumn("BARCODE", System.Type.GetType("System.String"));//一段碼
                        DataColumn dcol2 = new DataColumn("PERIOD_BARCODE", System.Type.GetType("System.String"));//二段碼
                        DataColumn dcol3 = new DataColumn("ITEM_NAME", System.Type.GetType("System.String"));//品名
                        DataColumn dcol4 = new DataColumn("COLUMN_STATUS", System.Type.GetType("System.String"));//欄位狀態

                        dtTmp.Columns.Add(dcol1);
                        dtTmp.Columns.Add(dcol2);
                        dtTmp.Columns.Add(dcol3);
                        dtTmp.Columns.Add(dcol4);

                        dt_Detail = dtTmp.Copy();
                        dtTmp.Dispose();
                    }
                }

                #endregion

                if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") &&
                    this.hid_ID.Value == string.Empty)
                {
                    DataRow dRow = dt_Detail.NewRow();

                    if (dt_Detail.Rows.Count == 0)
                    { dRow["ID"] = 0; }
                    else
                    {
                        DataView dv_Detail = new DataView(dt_Detail.Copy());
                        dv_Detail.Sort = "ID ASC";
                        dRow["ID"] = int.Parse(dv_Detail[0]["ID"].ToString()) + 1;
                    }

                    dRow["ROOT_NO"] = s_ROOT_NO;//群分類
                    dRow["PMA"] = s_PMA;//大分類
                    dRow["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//PO單號
                    dRow["BARCODE"] = this.txt_down_BARCODE.Text.Trim();//一段碼
                    dRow["PERIOD_BARCODE"] = this.txt_down_PERIOD_BARCODE.Text.Trim();//二段碼
                    dRow["ITEM"] = this.slp_down_ITEM.Text.Trim();//品號
                    dRow["ITEM_NAME"] = this.slp_down_ITEM.Name.Trim();//品名
                    //dRow["ITEM_NAME"] = ((TextBox)this.slp_down_ITEM.Controls[1].FindControl("TextBoxName")).Text.Trim();//品名
                    dRow["PERIOD"] = this.txt_down_PERIOD.Text.Trim();//期別
                    dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                    dRow["RTN_DDL"] = DateTime.ParseExact(this.slp_down_RTN_DDL.Text.Trim(), "yyyy/MM/dd", null);//退書截止日
                    b_IS_OVERDUE = CheckIsOverDue(this.slp_down_RTN_DDL.Text.Trim());
                    if (b_IS_OVERDUE == true)
                    { dRow["IS_OVERDUE"] = 1; }//逾期客訂有被勾選
                    else
                    { dRow["IS_OVERDUE"] = 0; }//逾期客訂沒有被勾選
                    // todo cyhsu: 找外雜 Locate_type 與 locate_no 沒有設定的原因
                    if ((s_SRC_LOCATE_TYPE == String.Empty) && (s_ROOT_NO == "1") &&
                       ((s_PMA == "13") || (s_PMA == "14") || (s_PMA == "15") || (s_PMA == "16")))
                    {
                        s_SRC_LOCATE_TYPE = "2";
                        this.txt_down_RECOMMAND_LOCATION.Text = "D";
                    }

                    dRow["SRC_LOCATE_TYPE"] = s_SRC_LOCATE_TYPE;//建議儲區
                    dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                    dRow["PROC_DESC"] = 0;//處理狀態(0代表未擷轉)
                    dRow["STATUS"] = 25;//結案狀態(25代表未結案,75代表已結案)
                    dRow["DIS_ENABLE"] = int.Parse(this.hid_DIS_ENABLE.Value);//可配量

                    dt_Detail.Rows.Add(dRow);
                }
                else if ((this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT") &&
                    this.hid_ID.Value != string.Empty)
                {
                    //2009-02-04 cyhsu change
                    DataTable dtTmp = dt_Detail.Copy();

                    //string s_FilterExpression = string.Empty;
                    //s_FilterExpression = "ID = " + this.hid_ID.Value;

                    //DataRow dRow = dt_Detail.Select(s_FilterExpression)[0];
                    //dRow["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                    //dRow["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                    int i_index = -1;

                    for (int i = 0; i < dtTmp.Rows.Count; i++)
                    {
                        if (dtTmp.Rows[i]["ID"].ToString() == this.hid_ID.Value)
                        {
                            i_index = i;
                            break;
                        }
                    }
                    if (i_index > -1)
                    {
                        dt_Detail.Rows[i_index]["REQUEST_QTY"] = int.Parse(this.slp_down_REQUEST_QTY.Text.Trim());//訂貨量
                        dt_Detail.Rows[i_index]["SRC_LOCATE_NO"] = this.txt_down_RECOMMAND_LOCATION.Text.Trim();//建議儲區
                        dt_Detail.Rows[i_index]["PO_SOURCE_NO"] = this.txt_down_PO_SOURCE_NO.Text.Trim();//建議儲區;
                    }
                }

                this.gv_Detail.DataSource = dt_Detail;
                this.gv_Detail.PageSize = 10;
                this.gv_Detail.PageIndex = 0;
                this.gv_Detail.DataBind();
                Panel1.Height = gv_Detail.Rows.Count * 45 + 60;

                //Session[SessionIDName] = dt_Detail;

                #region 清空 hid_ID,hid_DIS_ENABLE

                //this.hid_ID.Value = string.Empty;是否不應清空?2009-06-04 cyhsu
                this.hid_DIS_ENABLE.Value = string.Empty;

                #endregion

                #region 清空靜態變數

                dtStock = null;//異動欄位[期別]
                s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                #endregion

                #region 設定畫面狀態


                sb.Remove(0, sb.Length);
                sb.Append("新增或編輯模式按下明細區[更新]鈕<partition>");
                sb.Append(dt_Detail.Rows.Count.ToString() + "<partition>");//dt_Detail筆數
                sb.Append(this.panel_Middle.ClientID + "<partition>");//panel_Middle
                sb.Append(this.panel_Down_AddDetail.ClientID + "<partition>");//panel_Down_AddDetail
                sb.Append(this.panel_Down_Button.ClientID + "<partition>");//panel_Down_Button
                sb.Append(chk_down_IS_OVERDUE.ClientID + "<partition>");//逾期客訂
                sb.Append(this.txt_down_PO_SOURCE_NO.ClientID + "<partition>");//PO單號
                sb.Append(this.txt_down_BARCODE.ClientID + "<partition>");//一段碼
                sb.Append(this.txt_down_PERIOD_BARCODE.ClientID + "<partition>");//二段碼

                sb.Append(txt_down_ITEM.ClientID + "<partition>");//品號
                sb.Append(txt_down_ITEM_NAME.ClientID + "<partition>");//品名
                sb.Append(this.txt_down_PERIOD.ClientID + "<partition>");//期別
                sb.Append(txt_down_REQUEST_QTY.ClientID + "<partition>");//訂貨量

                sb.Append(txt_down_REQUEST_QTY_NAME.ClientID + "<partition>");//訂貨量名稱

                sb.Append(txt_down_RTN_DDL.ClientID + "<partition>");//退書截止日
                sb.Append(this.txt_down_RECOMMAND_LOCATION.ClientID);//建議儲區

                ScriptManager.RegisterStartupScript(this.up_Down_Button, this.GetType(), "CRM041", "but_down_Update_Click('" + sb.ToString() + "');", true);

                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Example #3
0
    /// <summary>
    /// 檢查明細是否可更新
    /// </summary>
    /// <param name="v_ChanNo">通路</param>
    /// <param name="v_Store">門市</param>
    /// <param name="v_Item">品號</param>
    /// <param name="v_Period">期別</param>
    /// <param name="v_RTN_DLL">退貨截止日</param>
    /// <returns></returns>
    private string CheckCanUpdate(string v_ChanNo, string v_Store, string v_Item,
                                  string v_Period, string v_RTN_DLL, string v_Crm_Request_No)
    {
        StringBuilder sb_chk = new StringBuilder();
        #region 檢查書店是否有未結案同品項訂單
        ArrayList ParameterList = new ArrayList();//20091117

        ParameterList.Clear();
        ParameterList.Add(v_ChanNo);//通路
        ParameterList.Add(v_Store);//門市

        ParameterList.Add(v_Item);//品號
        ParameterList.Add(v_Period);//期別
        ParameterList.Add(Session["UID"].ToString());//使用者
        ParameterList.Add(v_Crm_Request_No);//訂單編號

        DataTable dt_Return_1 = new DataTable();
        BCO.RecordCRMOrder bco_Record = new BCO.RecordCRMOrder(ConntionDB);
        dt_Return_1 = bco_Record.CheckOrderItemExist(ParameterList);
        if (dt_Return_1.Rows.Count > 0)
        {
            sb_chk.Append("此門市有未結案同品項訂單,不可新增");
        }
        #endregion

        return sb_chk.ToString();
    }
Example #4
0
    /// <summary>
    /// UP BUTTON 取消鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_up_Cancle_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.hid_PageStatus.Value == "INSERT" ||
                this.hid_PageStatus.Value == "VIEW")
            {
                #region 清空靜態變數

                //dtChainPOSetting = null;//異動欄位[門市]

                dtStock = null;//異動欄位[期別]
                s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                dt_Detail = null;
                //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
                dt_Master = null;
                dt_Detail_Original = null;

                #endregion

                #region 設定頁面狀態


                this.hid_PageStatus.Value = "QUERY";
                this.txt_PageStatus.Text = "QUERY";
                SetPageStartValue();
                SetPageStatus();

                #endregion

                #region 設定各欄位模式ReadOnly

                this.slp_up_CHAN_NO.ReadOnly = false;
                this.slp_up_STORE.ReadOnly = false;
                this.slp_up_Z_O.ReadOnly = false;
                this.slp_up_BUSDATE.ReadOnly = false;
                this.slp_up_SALE_ID.ReadOnly = false;
                this.slp_up_BUSUID.ReadOnly = false;
                this.drop_up_ORDER_TYPE.ReadOnly = false;
                this.txt_up_PO_SOURCE_NO.ReadOnly = false;
                this.txt_up_PO_SOURCE_NO.CssClass = "";
                this.txt_up_CODE.ReadOnly = false;
                this.txt_up_CODE.CssClass = "";
                this.txt_up_CRM_NO.ReadOnly = false;
                this.txt_up_CRM_NO.CssClass = "";

                #endregion
            }
            else if (this.hid_PageStatus.Value == "EDIT")
            {
                int i_Id = int.Parse(dt_Master.Rows[0]["ID"].ToString());

                #region 清空靜態變數

                //dtChainPOSetting = null;//異動欄位[門市]

                dtStock = null;//異動欄位[期別]
                s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                dt_Detail = null;
                //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
                dt_Master = null;
                dt_Detail_Original = null;

                #endregion

                #region 重新從資料庫抓取資料

                DataSet ds_Return = new DataSet();

                ParameterList.Clear();
                ParameterList.Add(i_Id);
                ParameterList.Add(Session["UID"].ToString());

                BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                ds_Return = bco.QUERY_CRM041_MAIN_AND_DETL(ParameterList);

                dt_Master = ds_Return.Tables["VDS_CRM_ORDER_MAIN"].Copy();
                dt_Detail = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
                //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = dt_Detail;
                dt_Detail_Original = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();

                ds_Return.Clear();
                ds_Return.Dispose();

                #endregion

                #region 新增後處理


                this.hid_PageStatus.Value = "VIEW";
                this.txt_PageStatus.Text = "VIEW";
                SetPageStatus();

                #endregion

                #region 將資料寫入頁面


                #region MAIN

                this.slp_up_CHAN_NO.Text = dt_Master.Rows[0]["CHAN_NO"].ToString();//通路
                this.slp_up_STORE.Text = dt_Master.Rows[0]["STORE"].ToString();//門市

                this.slp_up_Z_O.Text = dt_Master.Rows[0]["Z_O"].ToString();//營業所
                this.slp_up_BUSDATE.Text = dt_Master.Rows[0]["BUSDATE"].ToString();//訂單日期
                this.slp_up_SALE_ID.Text = dt_Master.Rows[0]["SAL_ID"].ToString();//營業人員
                this.slp_up_BUSUID.Text = dt_Master.Rows[0]["BUSUID"].ToString();//訂單維護者

                this.drop_up_ORDER_TYPE.Text = dt_Master.Rows[0]["ORDER_TYPE"].ToString();//訂單來源
                this.txt_up_PO_SOURCE_NO.Text = dt_Master.Rows[0]["PO_SOURCE_NO"].ToString();//PO單號預設
                this.txt_up_CODE.Text = dt_Master.Rows[0]["CODE"].ToString();//訂單編號
                this.txt_up_CRM_NO.Text = dt_Master.Rows[0]["CRM_NO"].ToString();//流水編號

                #endregion

                #region DETL

                this.gv_Detail.DataSource = dt_Detail;
                this.gv_Detail.PageSize = 10;
                this.gv_Detail.PageIndex = 0;
                this.gv_Detail.DataBind();
                Panel1.Height = gv_Detail.Rows.Count * 45 + 60;

                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { AuthorityControls(this); }
    }
Example #5
0
    /// <summary>
    /// UP BUTTON 刪除鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_up_Delete_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.hid_PageStatus.Value == "VIEW")
            {
                #region 檢視主檔與明細檔所有資料的結案狀態


                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Remove(0, sb.Length);

                string s_Filter_D = string.Empty;
                string s_Filter_M = string.Empty;
                s_Filter_M = "STATUS = 75";//75代表已結案
                s_Filter_D = "(STATUS = 75) or (TRANS_RESULT <> 0)";//75代表已結案



                if (dt_Master.Select(s_Filter_M).Length > 0 ||
                    dt_Detail.Select(s_Filter_D).Length > 0)
                { sb.Append("本訂單有品項已結案或已擷轉,不可刪除"); }

                if (sb.ToString() != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('" + sb.ToString() + "');", true);
                    return;
                }

                #endregion

                #region 確認刪除時,呼叫 RecordCRMOrder.DeleteCRMOrder] 刪除資料

                DateTime d_Now = DateTime.Now;
                ArrayList ParameterList = new ArrayList();//20091117

                ParameterList.Clear();

                //新的資料
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(d_Now);

                ////舊資料內容值

                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["ID"].ToString(), "int"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CODE"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["BUSDATE"].ToString(), "date"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["BUSUID"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CREATEDATE"].ToString(), "datetime"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CREATEUID"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["UPDATEDATE"].ToString(), "datetime"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["UPDATEUID"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["STATUS"].ToString(), "int"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["ENABLE"].ToString(), "int"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CRM_NO"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CRM_REQUEST_NO"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CHAN_NO"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["STORE"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CLOSE_DATE"].ToString(), "date"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["PO_SOURCE_NO"].ToString(), "string"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["ORDER_TYPE"].ToString(), "int"));
                ParameterList.Add(GetValueSetParameter(dt_Master.Rows[0]["CREATE_ROLE"].ToString(), "string"));

                BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                bco.DeleteCRMOrder(ParameterList, null, dt_Detail);

                #endregion

                #region 清空靜態變數

                dtChainPOSetting = null;//異動欄位[門市] -- 檢視模式清空

                dtStock = null;//異動欄位[期別]
                s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                dt_Detail = null;
                //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
                dt_Master = null;
                dt_Detail_Original = null;

                #endregion

                #region 設定頁面狀態


                this.hid_PageStatus.Value = "QUERY";
                this.txt_PageStatus.Text = "QUERY";
                SetPageStartValue();
                SetPageStatus();

                this.RightMsgLabel.Text = "刪除成功";

                #endregion

                #region 設定各欄位模式ReadOnly

                this.slp_up_CHAN_NO.ReadOnly = false;
                this.slp_up_STORE.ReadOnly = false;
                this.slp_up_Z_O.ReadOnly = false;
                this.slp_up_BUSDATE.ReadOnly = false;
                this.slp_up_SALE_ID.ReadOnly = false;
                this.slp_up_BUSUID.ReadOnly = false;
                this.drop_up_ORDER_TYPE.ReadOnly = false;
                this.txt_up_PO_SOURCE_NO.ReadOnly = false;
                this.txt_up_PO_SOURCE_NO.CssClass = "";
                this.txt_up_CODE.ReadOnly = false;
                this.txt_up_CODE.CssClass = "";
                this.txt_up_CRM_NO.ReadOnly = false;
                this.txt_up_CRM_NO.CssClass = "";

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Example #6
0
    /// <summary>
    /// UP BUTTON 查詢鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_up_Query_Click(object sender, EventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        try
        {
            if (this.hid_PageStatus.Value == "QUERY" ||
                sender.ToString() == "ToolBar_RecFirst" ||
                sender.ToString() == "ToolBar_RecLast" ||
                sender.ToString() == "ToolBar_RecNext" ||
                sender.ToString() == "ToolBar_RecPre" ||
                sender.ToString() == "CRM051_TO_CRM041")
            {
                #region 前置檢查與參數過濾


                if (this.hid_PageStatus.Value == "QUERY")
                {
                    sb.Remove(0, sb.Length);
                    if (this.slp_up_CHAN_NO.Text.Trim() == string.Empty &&
                        this.slp_up_STORE.Text.Trim() == string.Empty &&
                        this.slp_up_BUSDATE.Text.Trim() == string.Empty &&
                        this.slp_up_BUSUID.Text.Trim() == string.Empty &&
                        this.txt_up_CODE.Text.Trim() == string.Empty &&
                        this.txt_up_CRM_NO.Text.Trim() == string.Empty)
                    {
                        sb.Append("[通路]、[門市]、[訂單日期]、[訂單維護者]、[訂單編號]、[流水編號],六個欄位不可皆為空白,至少需輸入一項作為查詢條件。");
                        ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('" + sb.ToString() + "');", true);
                        return;
                    }
                }

                #endregion

                #region 處理查詢

                ArrayList ParameterList = new ArrayList();//20091117


                if (this.hid_PageStatus.Value == "QUERY" || sender.ToString() == "CRM051_TO_CRM041")
                {
                    #region 清空靜態變數

                    dtChainPOSetting = null;//異動欄位[門市] --由CRM05 連結 CRM04 =>查詢Query時先清空

                    dtStock = null;//異動欄位[期別]
                    s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                    s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                    s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                    dt_Detail = null;
                    //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
                    dt_Master = null;
                    dt_Detail_Original = null;

                    #endregion

                    DataSet ds_Return = new DataSet();

                    #region 取得查詢資料
                    if (this.hid_PageStatus.Value == "QUERY")
                    {
                        ParameterList.Clear();
                        ParameterList.Add(GetValueSetParameter(this.slp_up_CHAN_NO.Text.Trim(), "string"));//通路
                        ParameterList.Add(GetValueSetParameter(this.slp_up_STORE.Text.Trim(), "string"));//門市

                        ParameterList.Add(GetValueSetParameter(this.slp_up_Z_O.Text.Trim(), "string"));//營業所
                        ParameterList.Add(GetValueSetParameter(this.slp_up_BUSDATE.Text.Trim(), "date"));//訂單日期
                        ParameterList.Add(GetValueSetParameter(this.slp_up_SALE_ID.Text.Trim(), "string"));//營業人員
                        ParameterList.Add(GetValueSetParameter(this.slp_up_BUSUID.Text.Trim(), "string"));//訂單維護者

                        ParameterList.Add(GetValueSetParameter(this.drop_up_ORDER_TYPE.Text, "int"));//訂單來源
                        ParameterList.Add(GetValueSetParameter(this.txt_up_PO_SOURCE_NO.Text.Trim(), "string"));//PO單號預設
                        ParameterList.Add(GetValueSetParameter(this.txt_up_CODE.Text.Trim(), "string"));//訂單編號
                        ParameterList.Add(GetValueSetParameter(this.txt_up_CRM_NO.Text.Trim(), "string"));//流水編號
                        ParameterList.Add(Session["UID"].ToString());

                        BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                        ds_Return = bco.QueryCRMOrderByFind(ParameterList);
                    }
                    else if (sender.ToString() == "CRM051_TO_CRM041")
                    {
                        string s_CRM_REQUEST_NO = Request["CRM041_CRM_REQUEST_NO"].ToString();
                        ParameterList.Clear();
                        ParameterList.Add(s_CRM_REQUEST_NO);
                        ParameterList.Add(Session["UID"].ToString());

                        BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                        ds_Return = bco.QueryCRMOrderBy_CRM_REQUEST_NO(ParameterList);
                    }
                    #endregion

                    #region 記錄查詢結果到頁面變數與Session
                    if (ds_Return.Tables["VDS_CRM_ORDER_MAIN"].Rows.Count == 0 ||
                        ds_Return.Tables["VDS_CRM_ORDER_DETL"].Rows.Count == 0)
                    {
                        ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('查無訂單資料');", true);
                        return;
                    }
                    else
                    {
                        dt_Master = ds_Return.Tables["VDS_CRM_ORDER_MAIN"].Copy();
                        dt_Detail = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
                        //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = dt_Detail;
                        dt_Detail_Original = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
                    }
                    #endregion
                    ds_Return.Dispose();
                }
                else
                {
                    DataSet ds_Return = new DataSet();
                    #region 取得查詢資料
                    ParameterList.Clear();
                    ParameterList.Add(this.txt_up_CODE.Text);
                    ParameterList.Add(Session["UID"].ToString());

                    BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
                    if (sender.ToString() == "ToolBar_RecFirst")
                    { ds_Return = bco.QueryFirstCRMOrder(ParameterList); }
                    else if (sender.ToString() == "ToolBar_RecLast")
                    { ds_Return = bco.QueryLastCRMOrder(ParameterList); }
                    else if (sender.ToString() == "ToolBar_RecNext")
                    { ds_Return = bco.QueryNextCRMOrder(ParameterList); }
                    else if (sender.ToString() == "ToolBar_RecPre")
                    { ds_Return = bco.QueryPriorCRMOrder(ParameterList); }

                    if (ds_Return == null)
                    {
                        SetPageStatus();
                        if (sender.ToString() == "ToolBar_RecNext")
                        { ScriptManager.RegisterStartupScript(this.up_ToolBar, typeof(UpdatePanel), "CRM041", "alert('無下一筆資料');", true); }
                        else if (sender.ToString() == "ToolBar_RecPre")
                        { ScriptManager.RegisterStartupScript(this.up_ToolBar, typeof(UpdatePanel), "CRM041", "alert('無前一筆資料');", true); }
                        return;
                    }
                    else
                    {
                        #region 清空靜態變數

                        dtChainPOSetting = null;//異動欄位[門市] --查詢清空2

                        dtStock = null;//異動欄位[期別]
                        s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
                        s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
                        s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

                        dt_Detail = null;
                        //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
                        dt_Master = null;
                        dt_Detail_Original = null;

                        #endregion

                        dt_Master = ds_Return.Tables["VDS_CRM_ORDER_MAIN"].Copy();
                        dt_Detail = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
                        //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = dt_Detail;
                        dt_Detail_Original = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
                    }
                    #endregion
                    ds_Return.Dispose();
                }

                #endregion

                #region 切換到檢視模式


                this.hid_PageStatus.Value = "VIEW";
                this.txt_PageStatus.Text = "VIEW";
                SetPageStatus();

                #endregion

                #region 設定頁面控制項

                #region MAIN

                this.slp_up_CHAN_NO.Text = dt_Master.Rows[0]["CHAN_NO"].ToString();//通路
                this.slp_up_STORE.Text = dt_Master.Rows[0]["STORE"].ToString();//門市

                this.slp_up_Z_O.Text = dt_Master.Rows[0]["Z_O"].ToString();//營業所
                this.slp_up_BUSDATE.Text = dt_Master.Rows[0]["BUSDATE"].ToString();//訂單日期
                this.slp_up_SALE_ID.Text = dt_Master.Rows[0]["SAL_ID"].ToString();//營業人員
                this.slp_up_BUSUID.Text = dt_Master.Rows[0]["BUSUID"].ToString();//訂單維護者

                this.drop_up_ORDER_TYPE.Text = dt_Master.Rows[0]["ORDER_TYPE"].ToString();//訂單來源
                this.txt_up_PO_SOURCE_NO.Text = dt_Master.Rows[0]["PO_SOURCE_NO"].ToString();//PO單號預設
                this.txt_up_CODE.Text = dt_Master.Rows[0]["CODE"].ToString();//訂單編號
                this.txt_up_CRM_NO.Text = dt_Master.Rows[0]["CRM_NO"].ToString();//流水編號

                #endregion

                #region DETL

                this.gv_Detail.DataSource = dt_Detail;
                this.gv_Detail.PageSize = 10;
                this.gv_Detail.PageIndex = 0;
                this.gv_Detail.DataBind();
                Panel1.Height = gv_Detail.Rows.Count * 45 + 60;

                #endregion

                #endregion

                #region 設定各欄位模式ReadOnly

                this.slp_up_CHAN_NO.ReadOnly = true;
                this.slp_up_STORE.ReadOnly = true;
                this.slp_up_Z_O.ReadOnly = true;
                this.slp_up_BUSDATE.ReadOnly = true;
                this.slp_up_SALE_ID.ReadOnly = true;
                this.slp_up_BUSUID.ReadOnly = true;
                this.drop_up_ORDER_TYPE.ReadOnly = true;
                this.txt_up_PO_SOURCE_NO.ReadOnly = true;
                this.txt_up_PO_SOURCE_NO.CssClass = "readtxtbox";
                this.txt_up_CODE.ReadOnly = true;
                this.txt_up_CODE.CssClass = "readtxtbox";
                this.txt_up_CRM_NO.ReadOnly = true;
                this.txt_up_CRM_NO.CssClass = "readtxtbox";

                #endregion

            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { AuthorityControls(this); }
    }
Example #7
0
    /// <summary>
    /// UP BUTTON 存檔鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_up_Save_Click(object sender, EventArgs e)
    {
        try
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Remove(0, sb.Length);

            #region 檢查所有必填欄位是否為空值


            if (this.slp_up_CHAN_NO.Text.Trim() == string.Empty)
            { sb.Append("[通路]欄位為必填欄位\\r\\n"); }
            if (this.slp_up_STORE.Text.Trim() == string.Empty)
            { sb.Append("[門市]欄位為必填欄位\\r\\n"); }
            if (this.slp_up_Z_O.Text.Trim() == string.Empty)
            { sb.Append("[營業所]欄位為必填欄位\\r\\n"); }
            if (this.slp_up_BUSDATE.Text.Trim() == string.Empty)
            { sb.Append("[訂單日期]欄位為必填欄位\\r\\n"); }
            if (this.slp_up_SALE_ID.Text.Trim() == string.Empty)
            { sb.Append("[營業人員]欄位為必填欄位\\r\\n"); }
            if (this.slp_up_BUSUID.Text.Trim() == string.Empty)
            { sb.Append("[訂單維護者]欄位為必填欄位\\r\\n"); }
            if (this.drop_up_ORDER_TYPE.Text == string.Empty)
            { sb.Append("[訂單來源]欄位為必填欄位\\r\\n"); }
            if (this.txt_up_CODE.Text.Trim() == string.Empty)
            { sb.Append("[訂單編號]欄位為必填欄位\\r\\n"); }
            //if (this.txt_up_CRM_NO.Text.Trim() == string.Empty)
            //{ sb.Append("[流水編號]欄位為必填欄位\\r\\n"); }
            if (GetStringLen(txt_up_PO_SOURCE_NO.Text.Trim()) > 20)
            { sb.Append("[PO單號預設]欄位輸入資料長度過長\\r\\n"); }

            if (sb.ToString() != string.Empty)
            {
                ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('" + sb.ToString() + "');", true);
                return;
            }

            #endregion

            #region 檢查是否有明細資料


            int i_dt_Detail_Count = 0;
            if (dt_Detail != null)
            {
                if (dt_Detail.GetChanges(DataRowState.Deleted) == null)
                { i_dt_Detail_Count = dt_Detail.Rows.Count; }
                else
                { i_dt_Detail_Count = dt_Detail.Rows.Count - dt_Detail.GetChanges(DataRowState.Deleted).Rows.Count; }
            }

            if (dt_Detail == null || i_dt_Detail_Count == 0)
            { sb.Append("無明細資料"); }

            if (sb.ToString() != string.Empty)
            {
                ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('" + sb.ToString() + "');", true);
                return;
            }

            #endregion

            int i_Id = 0;
            BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
            ArrayList ParameterList = new ArrayList();//20091117

            if (this.hid_PageStatus.Value == "INSERT")
            {
                #region 儲存新增資料

                DateTime d_Now = DateTime.Now;

                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(this.slp_up_BUSDATE.Text, "date"));//訂單日期
                ParameterList.Add(GetValueSetParameter(this.slp_up_BUSUID.Text, "string"));//訂單維護者

                ParameterList.Add(d_Now);//CREATEDATE
                ParameterList.Add(Session["UID"].ToString());//CREATEUID
                ParameterList.Add(d_Now);//UPDATEDATE
                ParameterList.Add(Session["UID"].ToString());//UPDATEUID
                ParameterList.Add(25);//結案狀態(Status)=25(未結案)
                ParameterList.Add(1);//ENABLE
                ParameterList.Add(GetValueSetParameter(this.txt_up_CRM_NO.Text, "string"));//流水編號
                ParameterList.Add(GetValueSetParameter(this.slp_up_CHAN_NO.Text, "string"));//通路
                ParameterList.Add(GetValueSetParameter(this.slp_up_STORE.Text, "string"));//門市

                ParameterList.Add(System.DBNull.Value);//CLOSE_DATE
                ParameterList.Add(GetValueSetParameter(this.txt_up_PO_SOURCE_NO.Text, "string"));//PO單號預設
                ParameterList.Add(GetValueSetParameter(this.drop_up_ORDER_TYPE.Text, "int"));//訂單來源
                ParameterList.Add(Session["UID"].ToString());//建立單位(Create_Role)= [@登入者]所屬角色

                ParameterList.Add(Session["UID"].ToString());

                i_Id = bco.CreateCRMOrder(ParameterList, null, dt_Detail);

                #endregion
            }
            else if (this.hid_PageStatus.Value == "EDIT")
            {
                i_Id = int.Parse(dt_Master.Rows[0]["ID"].ToString());

                #region 取得異動資料

                DataTable dt_Detail_Changes_Delete = new DataTable();
                DataTable dt_Detail_Changes_Add = new DataTable();
                DataTable dt_Detail_Changes_Modify = new DataTable();

                dt_Detail_Changes_Delete = dt_Detail.GetChanges(DataRowState.Deleted);
                dt_Detail_Changes_Add = dt_Detail.GetChanges(DataRowState.Added);
                dt_Detail_Changes_Modify = dt_Detail.GetChanges(DataRowState.Modified);

                #endregion

                #region 將異動資料寫入資料庫

                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(DateTime.Now);
                ParameterList.Add(i_Id);

                bco.UpdateCRMOrder(ParameterList, null, dt_Detail_Changes_Delete, dt_Detail_Changes_Add, dt_Detail_Changes_Modify, dt_Detail_Original);

                #endregion
            }

            #region 清空靜態變數

            // dtChainPOSetting = null;//異動欄位[門市]

            dtStock = null;//異動欄位[期別]
            s_PMA = string.Empty;//大分類(異動欄位[品號/品名])
            s_ROOT_NO = string.Empty;//群分類(異動欄位[品號/品名])
            s_SRC_LOCATE_TYPE = string.Empty;//建議儲區類別(異動欄位[訂貨量])

            dt_Detail = null;
            //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = null;
            dt_Master = null;
            dt_Detail_Original = null;

            #endregion

            #region 重新從資料庫抓取資料

            DataSet ds_Return = new DataSet();

            ParameterList.Clear();
            ParameterList.Add(i_Id);
            ParameterList.Add(Session["UID"].ToString());

            ds_Return = bco.QUERY_CRM041_MAIN_AND_DETL(ParameterList);

            dt_Master = ds_Return.Tables["VDS_CRM_ORDER_MAIN"].Copy();
            dt_Detail = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();
            //Session["CRM041_dt_Detail" + PageTimeStamp.Value] = dt_Detail;
            dt_Detail_Original = ds_Return.Tables["VDS_CRM_ORDER_DETL"].Copy();

            ds_Return.Clear();
            ds_Return.Dispose();

            #endregion

            #region 檢查今日該門市是否已有訂單擷轉記錄


            if (this.hid_PageStatus.Value == "INSERT")
            {
                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(this.slp_up_BUSDATE.Text, "date"));//訂單擷轉日(放系統日)
                ParameterList.Add(GetValueSetParameter(this.slp_up_CHAN_NO.Text, "string"));//通路
                ParameterList.Add(GetValueSetParameter(this.slp_up_STORE.Text, "string"));//門市

                ParameterList.Add(Session["UID"].ToString());

                BCO.MaintainCRMOrderTransfer bco_Transfer = new BCO.MaintainCRMOrderTransfer(ConntionDB);
                if (bco_Transfer.QueryCountsByStore(ParameterList) > 0)
                {
                    sb.Append("當天訂單已結轉,到店時間將會延後");
                    ScriptManager.RegisterStartupScript(this.up_Up_Button, typeof(UpdatePanel), "CRM041", "alert('" + sb.ToString() + "');", true);
                }
            }

            #endregion

            #region 寫入訊息

            if (this.hid_PageStatus.Value == "INSERT")
            { this.RightMsgLabel.Text = "新增成功"; }
            else if (this.hid_PageStatus.Value == "EDIT")
            { this.RightMsgLabel.Text = "修改儲存成功"; }


            #endregion

            #region 新增後處理


            this.hid_PageStatus.Value = "VIEW";
            this.txt_PageStatus.Text = "VIEW";
            SetPageStatus();

            #endregion

            #region 將資料寫入頁面


            #region MAIN

            this.slp_up_CHAN_NO.Text = dt_Master.Rows[0]["CHAN_NO"].ToString();//通路
            this.slp_up_STORE.Text = dt_Master.Rows[0]["STORE"].ToString();//門市

            this.slp_up_Z_O.Text = dt_Master.Rows[0]["Z_O"].ToString();//營業所
            this.slp_up_BUSDATE.Text = dt_Master.Rows[0]["BUSDATE"].ToString();//訂單日期
            this.slp_up_SALE_ID.Text = dt_Master.Rows[0]["SAL_ID"].ToString();//營業人員
            this.slp_up_BUSUID.Text = dt_Master.Rows[0]["BUSUID"].ToString();//訂單維護者

            this.drop_up_ORDER_TYPE.Text = dt_Master.Rows[0]["ORDER_TYPE"].ToString();//訂單來源
            this.txt_up_PO_SOURCE_NO.Text = dt_Master.Rows[0]["PO_SOURCE_NO"].ToString();//PO單號預設
            this.txt_up_CODE.Text = dt_Master.Rows[0]["CODE"].ToString();//訂單編號
            this.txt_up_CRM_NO.Text = dt_Master.Rows[0]["CRM_NO"].ToString();//流水編號

            //記錄靜態變數 門市、通路
            s_CHAN_NO = this.slp_up_CHAN_NO.Text;
            s_STORE = this.slp_up_STORE.Text;

            #endregion

            #region DETL

            this.gv_Detail.DataSource = dt_Detail;
            this.gv_Detail.PageSize = 10;
            this.gv_Detail.PageIndex = 0;
            this.gv_Detail.DataBind();
            Panel1.Height = gv_Detail.Rows.Count * 45 + 60;

            #endregion

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Example #8
0
    /// <summary>
    /// 期別
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strStore"></param>
    /// <param name="strItem"></param>
    /// <param name="strPeriod"></param>
    /// <param name="strBarcode"></param>
    /// <param name="strPeriodBarcode"></param>
    /// <param name="strRtnDdl"></param>
    /// <param name="strID"></param>
    /// <param name="strCode"></param>
    /// <param name="strUserID"></param>
    /// <param name="strPageTimeStamp"></param>
    /// <returns></returns>
    private string GetValueByPageMethod_PERIOD(string strChan, string strStore, string strItem, string strPeriod, string strBarcode, string strPeriodBarcode, string strRtnDdl, string strID, string strCode, string strUserID, string strPageTimeStamp)
    {
        #region

        string strRtn = "", strTemp1 = "", strTemp2 = "", strTemp3 = "", strTemp4 = "";

        try
        {
            //期別或品號有異動時,重取庫存
            if (Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)].ToString() != strItem || Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)].ToString() != strPeriod)
            {
                Session[string.Format("CRM041_dtStock_{0}", strPageTimeStamp)] = null;
            }

            //s_CHAN_NO
            //s_STORE
            //s_ITEM
            //s_PERIOD
            Session[string.Format("CRM041_s_CHAN_NO_{0}", strPageTimeStamp)] = strChan;//通路
            Session[string.Format("CRM041_s_STORE_{0}", strPageTimeStamp)] = strStore;//門市
            Session[string.Format("CRM041_s_ITEM_{0}", strPageTimeStamp)] = strItem;//品號
            Session[string.Format("CRM041_s_PERIOD_{0}", strPageTimeStamp)] = strPeriod;//期別

            #region CHECK-1:檢查書店是否有未結案同品項訂單


            if (strID == string.Empty)
            {
                #region 從資料庫查詢資料
                ArrayList ParameterList = new ArrayList();

                ParameterList.Clear();
                ParameterList.Add(strChan);//通路
                ParameterList.Add(strStore);//門市
                ParameterList.Add(strItem);//品號
                ParameterList.Add(strPeriod);//期別
                ParameterList.Add(strUserID);
                ParameterList.Add(strCode);//訂單單號

                DataTable dt_Return_1 = new DataTable();
                BCO_CRM.RecordCRMOrder BCO1 = new BCO_CRM.RecordCRMOrder(ConntionDB);
                dt_Return_1 = BCO1.CheckOrderItemExist(ParameterList);
                BCO1.CloseConnection();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();

                #endregion

                if (dt_Return_1.Rows.Count > 0)
                {
                    strTemp1 = string.Format("該門市已存在未結案之同品項訂單於訂單標號:[{0}],不可新增", dt_Return_1.Rows[0]["CRM_REQUEST_NO"].ToString());
                }
            }

            #endregion

            if (strTemp1 == "")
            {
                #region CHECK-2:檢查牌價是否已經正確建立

                ParameterList.Clear();
                ParameterList.Add(strStore);//門市
                ParameterList.Add(strItem);//品號
                ParameterList.Add(strPeriod);//期別
                ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd")); // 系統日
                ParameterList.Add(strUserID);
                BCO_ALO.ProcessALOCommon BCO2 = new BCO_ALO.ProcessALOCommon(ConntionDB);
                string sRes = BCO2.CheckStAcceptDisPrice(ParameterList);
                BCO2.CloseConnection();

                if (sRes != string.Empty)
                {
                    strTemp2 = string.Format("期別:[{0}],牌價未生效[{1}],不可新增", strPeriod, sRes);
                }

                #endregion

                if (strTemp2 == "")
                {
                    #region CHECK-3:設定二段碼、退書截止日與逾期客訂

                    string s_down_BARCODE = string.Empty;//一段碼
                    string s_down_PERIOD_BARCODE = string.Empty;//二段碼
                    string s_down_RTN_DDL = string.Empty;//退書截止日

                    s_down_BARCODE = strBarcode;
                    s_down_PERIOD_BARCODE = strPeriodBarcode;
                    s_down_RTN_DDL = strRtnDdl;

                    // 不管原來有沒有值,只要品號改變,都重新查詢
                    ParameterList.Clear();
                    ParameterList.Add(strChan);//通路
                    ParameterList.Add(strItem);//品號
                    ParameterList.Add(strPeriod);//期別
                    ParameterList.Add(strUserID);

                    DataTable dt_Return_2 = new DataTable();
                    BCO_CRM.QueryCRMCommon BCO3 = new BCO_CRM.QueryCRMCommon(ConntionDB);
                    dt_Return_2 = BCO3.QueryItemPeriodInfo(ParameterList);
                    BCO3.CloseConnection();

                    if (dt_Return_2.Rows.Count > 0)//有找到資料
                    {
                        s_down_BARCODE = dt_Return_2.Rows[0]["BARCODE"].ToString();
                        s_down_PERIOD_BARCODE = dt_Return_2.Rows[0]["PERIOD_BARCODE"].ToString();
                        s_down_RTN_DDL = DateTime.Parse(dt_Return_2.Rows[0]["RTN_DDL"].ToString()).ToString("yyyy/MM/dd");
                    }
                    else//查無資料
                    {
                        strTemp3 = string.Format("查無[一段碼][二段碼][退書截止日],無法新增");
                    }

                    #endregion

                    if (strTemp3 == "")
                    {
                        #region CHECK-4:逾期客訂確認

                        TimeSpan time = new TimeSpan(11, 00, 00);
                        bool b_down_IS_OVERDUE = false;
                        //20140515 家容提出移除逾期判斷
                        //DateTime d_Now;
                        //DateTime d_RTN_DDL;

                        //d_Now = DateTime.Now;
                        //d_RTN_DDL = DateTime.Parse(s_down_RTN_DDL);

                        //if (d_Now.DayOfWeek == DayOfWeek.Saturday || d_Now.DayOfWeek == DayOfWeek.Sunday ||
                        //    (d_Now.DayOfWeek == DayOfWeek.Friday && d_Now.TimeOfDay.CompareTo(time) >= 0))
                        //{
                        //    if (d_RTN_DDL.AddDays(-5).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        //    {
                        //        b_down_IS_OVERDUE = true;
                        //        b_IS_OVERDUE = true;
                        //    }
                        //}
                        //else
                        //{
                        //    if (d_RTN_DDL.AddDays(-2).ToString("yyyy/MM/dd").CompareTo(d_Now.ToString("yyyy/MM/dd")) <= 0)
                        //    {
                        //        b_down_IS_OVERDUE = true;
                        //        b_IS_OVERDUE = true;
                        //    }
                        //}

                        //[@逾期客訂].檢查結果為True時,顯示Confirm訊息『商品已逾期,不可退貨,確定要新增?』
                        //使用者確認要新增時,可繼續編輯。
                        //使用者選擇不新增時,取消本筆明細新增。

                        if (b_down_IS_OVERDUE == true)
                        {

                            strTemp4 = string.Format("TRUE-{0}-{1}-{2}-{3}-{4}-{5}",
                                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, s_down_BARCODE, s_down_PERIOD_BARCODE, s_down_RTN_DDL);
                        }
                        else
                        {
                            strTemp4 = string.Format("FALSE-{0}-{1}-{2}-{3}-{4}-{5}",
                                Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, s_down_BARCODE, s_down_PERIOD_BARCODE, s_down_RTN_DDL);
                        }

                        #endregion

                        if (strTemp4.IndexOf("FALSE") != -1)
                        {
                            #region 取得庫存資訊

                            GetStockByPageMethod(Session[string.Format("CRM041_s_ROOT_NO_{0}", strPageTimeStamp)].ToString(), strItem, strPeriod, strUserID, strPageTimeStamp);

                            #endregion
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return strRtn = string.Format("{0};{1};{2};{3}", strTemp1, strTemp2, strTemp3, strTemp4);
        #endregion
    }
Example #9
0
    private DataTable Get_Query_Data()
    {
        #region 處理查詢

        string s_Count = (this.TextBoxRowCountLimit.Text == string.Empty) ? "9999" : this.TextBoxRowCountLimit.Text;
        DropDownList drop_ST_ACCEPT_QTY = (DropDownList)((ASP.wui_slp_slp_slpnumber_ascx)slp_ST_ACCEPT_QTY).FindControl("D1");

        TextBox txt_ST_ACCEPT_QTY = (TextBox)((ASP.wui_slp_slp_slpnumber_ascx)slp_ST_ACCEPT_QTY).FindControl("TextBoxCode");
        //(TextBox)this.slp_ST_ACCEPT_QTY.FindControl("TextBoxCode");
        ArrayList ParameterList = new ArrayList();//20091117

        ParameterList.Clear();
        ParameterList.Add(Session["UID"].ToString());
        ParameterList.Add(GetValueSetParameter(this.slp_BUSDATE.Text, "date", false));//訂單日期
        ParameterList.Add(GetValueSetParameter(this.slp_CHAN_NO.Text, "string", CheckBoxLikeSearch.Checked));//通路
        ParameterList.Add(GetValueSetParameter(this.slp_STORE.Text, "string", CheckBoxLikeSearch.Checked));//門市
        ParameterList.Add(GetValueSetParameter(this.txt_PO_SOURCE_NO.Text, "string", CheckBoxLikeSearch.Checked));//PO單號
        ParameterList.Add(GetValueSetParameter(this.slp_Z_O.Text, "string", CheckBoxLikeSearch.Checked));//營業所
        ParameterList.Add(GetValueSetParameter(this.slp_SAL_ID.Text, "string", CheckBoxLikeSearch.Checked));//營業專員
        ParameterList.Add(GetValueSetParameter(this.txt_BARCODE.Text, "string", CheckBoxLikeSearch.Checked));//一段碼
        ParameterList.Add(GetValueSetParameter(this.txt_PERIOD_BARCODE.Text, "string", CheckBoxLikeSearch.Checked));//二段碼

        try
        {
            int.Parse(txt_ST_ACCEPT_QTY.Text.Trim());
            ParameterList.Add(GetValueSetParameter(drop_ST_ACCEPT_QTY.SelectedItem.Text, "string", false));//運算子
            ParameterList.Add(GetValueSetParameter(txt_ST_ACCEPT_QTY.Text, "int", false));//出貨量

        }
        catch
        {
            ParameterList.Add(GetValueSetParameter(string.Empty, "string", false));//運算子
            ParameterList.Add(GetValueSetParameter(txt_ST_ACCEPT_QTY.Text, "int", false));//出貨量
        }

        ParameterList.Add(GetValueSetParameter(this.slp_ITEM.Text, "string", CheckBoxLikeSearch.Checked));//品號/品名
        ParameterList.Add(GetValueSetParameter(this.slp_PERIOD.Text, "string", CheckBoxLikeSearch.Checked));//期別
        ParameterList.Add(GetValueSetParameter(this.drop_ORDER_TYPE.SelectedValue, "int", false));//訂單來源
        ParameterList.Add(GetValueSetParameter(this.drop_PROC_DESC.SelectedValue, "int", false));//處理記錄
        ParameterList.Add(GetValueSetParameter(this.drop_STATUS.SelectedValue, "int", false));//結案狀態
        ParameterList.Add(GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "date", false));//進貨單日
        ParameterList.Add(GetValueSetParameter(s_Count, "int", false));//筆數

        DataTable dt_Return = new DataTable();

        BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
        dt_Return = bco.QueryCRMOrderMasterAndDetail(ParameterList);

        #endregion

        return dt_Return;
    }
Example #10
0
    /// <summary>
    /// BUTTON [查詢]鈕(上方)
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_up_Query_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 清空商品儲區移轉明細資料

            //抓取本頁初次登記的時間
            this.gv_Item_Detl.DataSource = null;
            this.gv_Item_Detl.DataBind();
            Session["CRM071_gv_Item_Detl" + PageTimeStamp.Value] = null;

            #endregion

            #region 檢查條件

            string s_CheckPage = CheckPage(sender);

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            #endregion

            #region 傳入參數

            BCO.CRMCommon CRMComm = new BCO.CRMCommon();
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_up_TRANS_DATE.Text, "date", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "date", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));
            ParameterList.Add(Session["UID"].ToString());

            #endregion

            #region 取得資料

            DataTable dt_Return = new DataTable();

            BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
            dt_Return = bco.QueryForTransfer(ParameterList);

            bAfterQueryDataBinding = true;

            if (dt_Return != null && !dt_Return.Columns.Contains("CHECKED"))//增加欄位以方便判別是否已勾選
                dt_Return.Columns.Add("CHECKED");


            #endregion

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            string SessionIDName = "CRM071_gv_WaitForWork" + PageTimeStamp.Value;

            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dt_Return;
            this.gv_WaitForWork.DataSource = dt_Return;
            this.gv_WaitForWork.PageSize = (TextBoxPagesize_Query.Text == "") ? 20 : (int.Parse(TextBoxPagesize_Query.Text) <= 0) ? 20 : int.Parse(TextBoxPagesize_Query.Text);
            this.gv_WaitForWork.DataBind();


            bAfterQueryDataBinding = false;

            #endregion

            #region 檢查是否有資料

            string s_ScriptManager_Script = string.Empty;

            if (dt_Return.Rows.Count == 0)
            {
                s_ScriptManager_Script = @"
document.getElementById('" + this.panel_Tab2.ClientID + @"').style.display = 'none';
document.getElementById('" + this.but_Execute.ClientID + @"').disabled = true;";
                this.ErrorMsgLabel.Text = "查無資料";
            }
            else
            {
                s_ScriptManager_Script = @"
document.getElementById('" + this.panel_Tab2.ClientID + @"').style.display = 'block';
document.getElementById('" + this.but_Execute.ClientID + @"').disabled = false;";
            }

            ScriptManager.RegisterStartupScript(this.up_gv_WaitForWork, typeof(UpdatePanel), "CRM071", s_ScriptManager_Script, true);

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
        #endregion
    }
Example #11
0
    protected void gv_Item_Detl_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            #region 傳入參數

            TextBox txt_MEMO = (TextBox)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("txt_MEMO");
            HiddenField hid_TRANS_DATE = (HiddenField)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("hid_TRANS_DATE");
            Label lab_ITEM = (Label)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("lab_ITEM");
            Label lab_PERIOD = (Label)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("lab_PERIOD");
            Label lab_SRC_LOCATE_NO = (Label)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("lab_SRC_LOCATE_NO");
            Label lab_DST_LOCATE_NO = (Label)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("lab_DST_LOCATE_NO");

            if (GetStringLen(txt_MEMO.Text.Trim()) > txt_MEMO.MaxLength)
            {
                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CRM071", "alert('[注意事項]欄位輸入資料長度過長');", true);
                throw new Exception("[注意事項]欄位輸入資料長度過長");
                return;
                
            }

            BCO.CRMCommon CRMComm = new BCO.CRMCommon();
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(CRMComm.GetValueSetParameter(txt_MEMO.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(hid_TRANS_DATE.Value, "date", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(lab_ITEM.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(lab_PERIOD.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(lab_SRC_LOCATE_NO.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(lab_DST_LOCATE_NO.Text, "string", false));

            #endregion

            #region 儲存明細編輯資訊

            BCO.RecordCRMOrder bco = new BCO.RecordCRMOrder(ConntionDB);
            bco.UpdateTransferMemo(ParameterList, null);

            #endregion

            this.RightMsgLabel.Text = "更新成功";
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
            return;
        }
        //finally
        //{
            HiddenField hid_TRANS_DATE2 = (HiddenField)this.gv_Item_Detl.Rows[e.RowIndex].FindControl("hid_TRANS_DATE");

            this.gv_Item_Detl.EditIndex = -1;
            int i_PageSize = this.gv_Item_Detl.PageSize;
            int i_PageIndex = this.gv_Item_Detl.PageIndex;

            Get_Trans_Detl_Data(hid_TRANS_DATE2.Value, i_PageSize, i_PageIndex);
        //}
    }
Example #12
0
    protected void btn_Close_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            SaveCurrentGridviewValue();

            if (CheckDetailIsExisted())
            {

                string SessionIDName = "CRM221_" + PageTimeStamp.Value;
                DataTable dtTemp = (DataTable)Session[SessionIDName];

                if (dtTemp != null)
                {
                    #region Variables

                    CRMModel.RecordCRMOrder CRMBCO = new CRMModel.RecordCRMOrder(ConnectionDB);
                    string strErrMsg = "";
                    bool bResult = false;
                    ArrayList ParameterList = new ArrayList();
                    CRMModel.CRMCommon BCOCommon = new CRMModel.CRMCommon();
                    System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();

                    #endregion


                    #region
                    try
                    {
                        #region 新增
                        for (Int32 i = 0; i <= dtTemp.Rows.Count - 1; i++)
                        {
                            if (dtTemp.Rows[i].RowState != DataRowState.Deleted)
                            {
                                if (strErrMsg == "")
                                {
                                    //ORDER
                                    if (dtTemp.Rows[i]["CHECKED"].ToString()=="1" && 
                                        dtTemp.Rows[i]["PROC_DESC"].ToString() != "")
                                    {
                                        ParameterList.Clear();
                                        ParameterList.Add(dtTemp.Rows[i]["PID"].ToString());
                                        ParameterList.Add(dtTemp.Rows[i]["ITEM"].ToString());
                                        ParameterList.Add(dtTemp.Rows[i]["PERIOD"].ToString());
                                        ParameterList.Add(dtTemp.Rows[i]["PROC_DESC"].ToString());
                                        ParameterList.Add(Session["UID"].ToString());
                                        bResult = CRMBCO.UpdateCrm22(ParameterList, DBT, out strErrMsg);
                                    }
                                }
                                else
                                {
                                    break;
                                    DBT.Rollback();//交易失敗
                                }
                            }
                        }
                        #endregion

                        DBT.Commit();//交易成功
                    }
                    catch (Exception ex)
                    {
                        DBT.Rollback();//交易失敗
                        throw ex;
                    }


                    if (bResult && strErrMsg == "")
                    {
                        QueryData();
                        ErrorMsgLabel.Text = "結案成功";
                    }
                    else
                    {
                        ErrorMsgLabel.Text = strErrMsg;
                    }
                    #endregion

                }
            }

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