Exemplo n.º 1
0
    /// <summary>
    /// BUTTON [預算處理項目]鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Expect_Item_Click(object sender, EventArgs e)
    {
        string s_ErrorMsg = string.Empty;

        try
        {
            #region 建立 Temp Table,將待處理的資料寫入 Temp Table

            DataTable dt_Temp = new DataTable();

            DataColumn dc_ITEM = new DataColumn("ITEM", System.Type.GetType("System.String"));//品號
            DataColumn dc_PERIOD = new DataColumn("PERIOD", System.Type.GetType("System.String"));//期別
            DataColumn dc_USER_ID = new DataColumn("USER_ID", System.Type.GetType("System.String"));//登入人員
            DataColumn dc_CHECKED = new DataColumn("CHECKED", System.Type.GetType("System.String"));//勾選狀態


            dt_Temp.Columns.Add(dc_ITEM);
            dt_Temp.Columns.Add(dc_PERIOD);
            dt_Temp.Columns.Add(dc_USER_ID);
            dt_Temp.Columns.Add(dc_CHECKED);

            foreach (GridViewRow gvRow in this.gv_Query_Result.Rows)
            {
                CheckBox chk_Sgl = (CheckBox)gvRow.FindControl("chk_Sgl");

                DataRow dRow = dt_Temp.NewRow();
                dRow["ITEM"] = gvRow.Cells[0].Text;
                dRow["PERIOD"] = gvRow.Cells[2].Text;
                dRow["USER_ID"] = Session["UID"].ToString();
                if (chk_Sgl.Checked == true)
                { dRow["CHECKED"] = "TRUE"; }
                else
                { dRow["CHECKED"] = "FALSE"; }
                dt_Temp.Rows.Add(dRow);
            }

            #endregion

            #region 處理資料
            ArrayList ParameterList = new ArrayList();//20091117

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

            ArrayList arl_Return = new ArrayList();

            BCO.ProcessCRMHQStock bco = new BCO.ProcessCRMHQStock(ConntionDB);
            arl_Return = bco.PreCalculateQty(dt_Temp, ParameterList, null);

            #endregion

            #region 將資料顯示在畫面上


            this.RightMsgLabel.Text = "預算處理項目執行成功";
            string s_ScriptManager_Script = string.Empty;

            s_ScriptManager_Script = @"
if (document.getElementById('" + this.lab_Expect_Store.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Store.ClientID + @"').innerHTML = '" + arl_Return[0].ToString() + @"';}
if (document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"').innerHTML = '" + arl_Return[1].ToString() + @"';}
if (document.getElementById('" + this.lab_Expect_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Count.ClientID + @"').innerHTML = '" + arl_Return[2].ToString() + @"';}
if (document.getElementById('" + this.but_Execute.ClientID + @"')) {
document.getElementById('" + this.but_Execute.ClientID + @"').disabled = false;}
if (document.getElementById('" + this.but_Query.ClientID + @"')) {
document.getElementById('" + this.but_Query.ClientID + @"').disabled = false; }
if (document.getElementById('" + this.but_Trans_Error.ClientID + @"')) {
document.getElementById('" + this.but_Trans_Error.ClientID + @"').disabled = true;}
if (document.getElementById('" + this.but_Expect_Item.ClientID + @"')) {
document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = false;}
";
            ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CRM081", s_ScriptManager_Script, true);

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
            s_ErrorMsg = ex.ToString();
        }
        finally
        {
            #region 如果[預算處理項目]執行有錯誤


            if (s_ErrorMsg != string.Empty)
            {
                string s_ScriptManager_Script = string.Empty;

                s_ScriptManager_Script = @"
document.getElementById('" + this.but_Execute.ClientID + @"').disabled = false;
document.getElementById('" + this.but_Query.ClientID + @"').disabled = false;
document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = false;
";
                ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CRM081", s_ScriptManager_Script, true);
            }

            #endregion
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// BUTTON [執行]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Execute_Click(object sender, EventArgs e)
    {
        BCO.CRMCommon CRMComm = new BCO.CRMCommon(); 
        try
        {
            #region 建立 Temp Table,將待處理的資料寫入 Temp Table

            DataTable dt_Temp = new DataTable();

            DataColumn dc_ITEM = new DataColumn("ITEM", System.Type.GetType("System.String"));//品號
            DataColumn dc_PERIOD = new DataColumn("PERIOD", System.Type.GetType("System.String"));//期別
            DataColumn dc_USER_ID = new DataColumn("USER_ID", System.Type.GetType("System.String"));//登入人員
            DataColumn dc_CHECKED = new DataColumn("CHECKED", System.Type.GetType("System.String"));//勾選狀態
            DataColumn dc_ID = new DataColumn("ID", System.Type.GetType("System.String"));//勾選狀態
            DataColumn dc_PID = new DataColumn("PID", System.Type.GetType("System.String"));//勾選狀態


            dt_Temp.Columns.Add(dc_ITEM);
            dt_Temp.Columns.Add(dc_PERIOD);
            dt_Temp.Columns.Add(dc_USER_ID);
            dt_Temp.Columns.Add(dc_CHECKED);
            dt_Temp.Columns.Add(dc_ID);
            dt_Temp.Columns.Add(dc_PID);

            //---------------------------------------------------------------------
            #region old
            //foreach (GridViewRow gvRow in this.gv_Query_Result.Rows)
            //{
            //    CheckBox chk_Sgl = (CheckBox)gvRow.FindControl("chk_Sgl");
            //    if (chk_Sgl.Checked == true)
            //    {
            //        DataRow dRow = dt_Temp.NewRow();
            //        dRow["ITEM"] = gvRow.Cells[0].Text;
            //        dRow["PERIOD"] = gvRow.Cells[2].Text;
            //        dRow["USER_ID"] = Session["UID"].ToString();
            //        dRow["CHECKED"] = "TRUE";
            //        //if (chk_Sgl.Checked == true)
            //        //{ dRow["CHECKED"] = "TRUE"; }
            //        //else
            //        //{ dRow["CHECKED"] = "FALSE"; }
            //        dRow["ID"] = ((Label)gvRow.FindControl("lblID")).Text;
            //        dRow["PID"] = ((Label)gvRow.FindControl("lblPID")).Text;
            //        dt_Temp.Rows.Add(dRow);
            //    }
            //}
            #endregion

            #region new

            string SessionIDName = "CRM081_" + PageTimeStamp.Value;
            DataTable dtTemp2 = (DataTable)Session[SessionIDName];
            string s_Checked, s_ID, s_PID;

            foreach (DataRow drTemp2 in dtTemp2.Rows)
            {
                s_Checked = drTemp2["CHECKED"].ToString().Trim();
                s_ID = drTemp2["ID"].ToString().Trim();
                s_PID = drTemp2["PID"].ToString().Trim();

                if (s_Checked != "0")//表示未被設成【未勾選】
                {
                    DataRow dr_Parameter = dt_Temp.NewRow();
                    dr_Parameter["ITEM"] = drTemp2["ITEM"].ToString().Trim();
                    dr_Parameter["PERIOD"] = drTemp2["PERIOD"].ToString().Trim();
                    dr_Parameter["USER_ID"] = Session["UID"].ToString();
                    dr_Parameter["CHECKED"] = "TRUE";
                    dr_Parameter["ID"] = int.Parse(s_ID);
                    dr_Parameter["PID"] = int.Parse(s_PID);
                    dt_Temp.Rows.Add(dr_Parameter);
                }
            }

            #endregion

            //---------------------------------------------------------------------


            //異動 VDS_CRM_08_TMP 的 UPDATEUID
            BCO.ProcessCRMHQStock bco = new BCO.ProcessCRMHQStock(ConntionDB);
            bco.CheckTrankData2(dt_Temp, Session["UID"].ToString(), null);

            #endregion

            #region 參數[PreCalculateQty]預算處理項目

            ArrayList arl_PreCalculateQty = new ArrayList();
            arl_PreCalculateQty.Clear();
            arl_PreCalculateQty.Add(Session["UID"].ToString());

            #endregion

            #region 參數[ProcessCRMTransTmpForHQStock]執行

            ArrayList arl_ProcessCRMTransTmpForHQStock = new ArrayList();
            arl_ProcessCRMTransTmpForHQStock.Clear();
            arl_ProcessCRMTransTmpForHQStock.Add(GetValueSetParameter(this.slp_TRANS_DATE.Text, "string", false));
            arl_ProcessCRMTransTmpForHQStock.Add(GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "string", false));
            arl_ProcessCRMTransTmpForHQStock.Add(Session["UID"].ToString());

            #endregion
                
            #region 處理資料
            ArrayList ParameterList = new ArrayList();//20091117

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

            ArrayList arl_Return = new ArrayList();

            arl_Return = bco.PreCalculateQty(dt_Temp, arl_PreCalculateQty, null);
            bco.ProcessCRMTransTmpForHQStock(arl_ProcessCRMTransTmpForHQStock, null);

            #endregion

            #region 將資料顯示在畫面上


            this.RightMsgLabel.Text = "手開單產生成功";
            string s_ScriptManager_Script = string.Empty;

            s_ScriptManager_Script = @"
if (document.getElementById('" + this.lab_Expect_Store.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Store.ClientID + @"').innerHTML = '" + arl_Return[0].ToString() + @"';}
if (document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"').innerHTML = '" + arl_Return[1].ToString() + @"';}
if (document.getElementById('" + this.lab_Expect_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Expect_Count.ClientID + @"').innerHTML = '" + arl_Return[2].ToString() + @"'; }
if (document.getElementById('" + this.lab_Execute_Store.ClientID + @"')) {
document.getElementById('" + this.lab_Execute_Store.ClientID + @"').innerHTML = '" + arl_Return[0].ToString() + @"'; }
if (document.getElementById('" + this.lab_Execute_Item_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Execute_Item_Count.ClientID + @"').innerHTML = '" + arl_Return[1].ToString() + @"';}
if (document.getElementById('" + this.lab_Execute_Count.ClientID + @"')) {
document.getElementById('" + this.lab_Execute_Count.ClientID + @"').innerHTML = '" + arl_Return[2].ToString() + @"'; }
if (document.getElementById('" + this.but_Execute.ClientID + @"')) {
document.getElementById('" + this.but_Execute.ClientID + @"').disabled = true; }
if (document.getElementById('" + this.but_Trans_Error.ClientID + @"')) {
document.getElementById('" + this.but_Trans_Error.ClientID + @"').disabled = true; }
if (document.getElementById('" + this.but_Query.ClientID + @"')) {
document.getElementById('" + this.but_Query.ClientID + @"').disabled = false;  }
if (document.getElementById('" + this.but_Expect_Item.ClientID + @"')) {
document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = true; }
";
            #region 預設POP查詢使用參數
            string SessionIdName = "POP_QueryDisNo_" + PageTimeStamp.Value;
            Session[SessionIdName] = null;
            ParameterList.Clear();
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_TRANS_DATE.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "string", false));
            ParameterList.Add(CRMComm.GetValueSetParameter("", "string", false)); //0代表未逾期客訂,1代表是逾期客訂
            ParameterList.Add(CRMComm.GetValueSetParameter(this.txt_TRANS_NO_B.Text.Trim(), "string", false));//擷轉序號起
            ParameterList.Add(CRMComm.GetValueSetParameter(this.txt_TRANS_NO_E.Text.Trim(), "string", false));//擷轉序號迄
            ParameterList.Add(Session["UID"].ToString());
            Session[SessionIdName] = ParameterList;
            #endregion

            s_ScriptManager_Script += "alert('手開單產生成功');";
            s_ScriptManager_Script += string.Format(@"POP_QueryDisNo('{0}','{1}','{2}','{3}','{4}','{5}');",
                                                    slp_ROOT_NO.Text,
                                                    slp_TRANS_DATE.Text,
                                                    slp_ST_ACCEPT_DATE.Text,
                                                    "0", //非逾期
                                                    txt_TRANS_NO_B.Text.ToString(),
                                                    txt_TRANS_NO_E.Text.ToString());

            ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CRM081", s_ScriptManager_Script, true);

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
            #region 控制Button
            string s_ScriptManager_Script = string.Empty;

            s_ScriptManager_Script = @"
if (document.getElementById('" + this.but_Trans_Error.ClientID + @"')) {
document.getElementById('" + this.but_Trans_Error.ClientID + @"').disabled = false; }
";
            ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CRM081", s_ScriptManager_Script, true);
            #endregion
       
        }
        finally { CRMComm = null; }
    }
Exemplo n.º 3
0
    /// <summary>
    /// BUTTON [查詢]鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Query_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件
            this.Page.Validate();
            if (!this.Page.IsValid)
            { return; }

            string s_CheckPage = CheckPage();

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

            #endregion

            #region 傳入參數
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.slp_TRANS_DATE.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.slp_ST_ACCEPT_DATE.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_B.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txt_TRANS_NO_E.Text, "string", false));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

            #endregion

            #region 取得資料

            ArrayList arl_Return = new ArrayList();

            BCO.ProcessCRMHQStock bco = new BCO.ProcessCRMHQStock(ConntionDB);
            arl_Return = bco.QueryCRMTransTmpForHQStock(ParameterList);



            #endregion

            #region 資料與GridView繫結

            DataTable dt_Return = new DataTable();

            if (arl_Return[0].ToString() == string.Empty)
            { dt_Return = (DataTable)arl_Return[2]; }


            bAfterQueryDataBinding = true;

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


            //抓取本頁初次登記的時間

            string SessionIDName = "CRM081_" + PageTimeStamp.Value;
            Session["SessionID"] = SessionIDName;

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


            bAfterQueryDataBinding = false;


            #endregion

            #region 檢查是否有資料


            string s_ScriptManager_Script = string.Empty;

            if (arl_Return[0].ToString() != string.Empty)
            {
                this.ErrorMsgLabel.Text = arl_Return[0].ToString();
                s_ScriptManager_Script = @"
document.getElementById('" + this.lab_Expect_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Count.ClientID + @"').innerHTML = '';
if (document.getElementById('" + this.but_Execute.ClientID + @"') != null) { document.getElementById('" + this.but_Execute.ClientID + @"').disabled = true;}
if (document.getElementById('" + this.but_Expect_Item.ClientID + @"') != null) {document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = true;}";
            }
            else
            {
                if (dt_Return.Rows.Count == 0)
                {
                    this.ErrorMsgLabel.Text = "查無資料";
                    s_ScriptManager_Script = @"
document.getElementById('" + this.lab_Expect_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Count.ClientID + @"').innerHTML = '';
if (document.getElementById('" + this.but_Execute.ClientID + @"') != null) { document.getElementById('" + this.but_Execute.ClientID + @"').disabled = true;}
if (document.getElementById('" + this.but_Expect_Item.ClientID + @"') != null) {document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = true;}";
                }
                else
                {
                    this.RightMsgLabel.Text = "查詢成功";
                    s_ScriptManager_Script = @"
document.getElementById('" + this.lab_Expect_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Expect_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Store.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Item_Count.ClientID + @"').innerHTML = '';
document.getElementById('" + this.lab_Execute_Count.ClientID + @"').innerHTML = '';
if (document.getElementById('" + this.but_Execute.ClientID + @"') != null) {document.getElementById('" + this.but_Execute.ClientID + @"').disabled = false;}
if (document.getElementById('" + this.but_Expect_Item.ClientID + @"') != null) {document.getElementById('" + this.but_Expect_Item.ClientID + @"').disabled = false;}";
                }
            }

            ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CRM081", s_ScriptManager_Script, true);

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