Exemple #1
0
    //停止往來計算(檢核)
    protected void STOP_COUNT_Check()
    {
        try
        {
            TextBox tb = (TextBox)slpSTOP_DATE.FindControl("TextBoxCode");
            if (slpSTOP_DATE.Text.Trim().Length == 0)
            {
                string sc = "alert('請輸入停止往來日');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) < DateTime.Parse(slpRESUME_DATE_B.Text) || DateTime.Parse(slpSTOP_DATE.Text) > DateTime.Parse(slpRESUME_DATE_E.Text))
            {
                string sc = "alert('停止往來日必須介於履歷起始日與履歷結束日中間');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }

            //找出最大的結帳年月
            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            string maxYM = bco.QueryMaxYM();
            if (maxYM == "")
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('無結帳年月,請重新輸入');", true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) <= DateTime.Parse(maxYM.Substring(0, 4) + "/" + maxYM.Substring(4, 2) + "/26"))
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('輸入的日期已結過帳,請重新輸入');", true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) < DateTime.Today)
            {
                string sc = "if(confirm('您所輸入的停止往來日小於系統日期,是否仍確定更新?')){this.disabled=true;__doPostBack('STOP_COUNT','');} else {";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);}";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            STOP_COUNT();
            UpdatePanel2.Update();
        }
        catch (Exception ex)
        {
            lblErrMsg1.Text = "帳款往來計算不成功 !! " + ex.Message;
            UpdatePanel2.Update();
        }
    }
Exemple #2
0
    //追溯計算(檢核)
    protected void RE_COUNT_Check()
    {
        try
        {
            if (slpTRACE_DATE_B.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (slpTRACE_DATE_B.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯年月(起)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (slpTRACE_DATE_E.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (slpTRACE_DATE_E.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯年月(迄)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            string trace1 = slpTRACE_DATE_B.Text.Substring(0, 4) + "/" + slpTRACE_DATE_B.Text.Substring(4, 2) + "/01";
            string trace2 = slpTRACE_DATE_E.Text.Substring(0, 4) + "/" + slpTRACE_DATE_E.Text.Substring(4, 2) + "/01";
            DateTime dt;
            if (!DateTime.TryParse(trace1, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (!DateTime.TryParse(trace2, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace1) > DateTime.Parse(trace2))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(起)不可大於追溯年月(迄)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace2).Year > DateTime.Today.Year)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(迄)不可大於系統年月,請重新設定');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace2).Year == DateTime.Today.Year && DateTime.Parse(trace2).Month > DateTime.Today.Month)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(迄)不可大於系統年月,請重新設定');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (txtYEAR_MONTH.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (txtYEAR_MONTH.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯掛帳年月');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            string trace3 = txtYEAR_MONTH.Text.Substring(0, 4) + "/" + txtYEAR_MONTH.Text.Substring(4, 2) + "/01";
            if (!DateTime.TryParse(trace3, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }

            //找出最大的結帳年月
            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            string maxYM = bco.QueryMaxYM();
            if (!(string.Compare(txtYEAR_MONTH.Text, maxYM) > 0))
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('該合約已結帳至" + maxYM + "月,請重新輸入掛帳年月');", true);
                return;
            }

            TextBox Tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
            string Sc = @"if(confirm('避免供應商追溯金額為負值,請再度確認掛帳年月,以免產生負值的各項扣款報表,是否確定進行追溯?')){this.disabled=true;__doPostBack('RE_COUNT','');} else {";
            Sc += @"window.setTimeout(function set_focus(){document.all['" + Tb.ClientID + "'].focus();document.all['" + Tb.ClientID + "'].select();}, 1800);}";
            //string Sc = @"if(confirm('避免供應商追溯金額為負值,請再度確認掛帳年月,以免產生負值的各項扣款報表,是否確定進行追溯?')){this.disabled=true;__doPostBack('RE_COUNT','');}";
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", Sc, true);
            UpdatePanel2.Update();
        }
        catch (Exception ex)
        {
            lblErrMsg1.Text = "帳款追溯不成功 !! " + ex.Message;
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "btnSTOP_COUNT_fail", "alert('帳款追溯不成功 !! " + ex.Message + "');", true);
            UpdatePanel2.Update();
        }
    }