Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AuthorityControls(this);
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            this.btnLink.Attributes.Add("onclick", "AddIFrameTab('進項憑證明細表','../VAM/VAM121.aspx?Code=VAM12')");
            if (!IsPostBack)
            {
                ViewState["ToZero"] = "0";
                //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );
                //設定GridView預設的狀態

                Initialization_Component();
                //設定ToolBar預設狀態
                ToolBarInit();

                //預設檔案儲存路徑              
                ((TextBox)this.SLP_VendorInvoice2.Controls[1].FindControl("TextBoxCode")).Attributes["onblur"] += "chkInv_no();";

                string V_VANDOR = Request["V_VANDOR"].ToString();
                string V_VANDOR_NAME = Request["V_VANDOR_NAME"].ToString();
                string V_TAX_TYPE = Request["V_TAX_TYPE"].ToString();

                this.TextBox2.Text = V_VANDOR + "/" + V_VANDOR_NAME;
                SLP_VendorBase1.Text = V_VANDOR;
                this.hidVANDOR.Value = V_VANDOR;
                this.TextBox2.ReadOnly = true;
                if (V_TAX_TYPE == "0")
                {
                    this.TextBox1.Text = "應稅";
                }
                else if (V_TAX_TYPE == "1")
                {
                    this.TextBox1.Text = "免稅";
                }
                else if (V_TAX_TYPE == "2")
                {
                    this.TextBox1.Text = "零稅";
                }
                hidTaxType.Value = V_TAX_TYPE;

                //稅率
                if (V_TAX_TYPE == "0")
                {
                    BCO.VAM17_BCO bco = new BCO.VAM17_BCO(ConnectionDB);
                    decimal iTaxRate;
                    bco.QueryTaxRate(out iTaxRate);
                    this.hidTaxRate.Value = iTaxRate.ToString();
                }
                else
                {
                    this.hidTaxRate.Value = "0";
                }

                Session["V_TAX_TYPE"] = V_TAX_TYPE;
                this.TextBox1.ReadOnly = true;
                this.TextBox2.CssClass = "readtxtbox";
                this.TextBox1.CssClass = "readtxtbox";
                this.TextBox5.CssClass = "readtxtbox";
                ((TextBox)this.SLP_SLPDate2.FindControl("TextBoxCode")).Text = System.DateTime.Now.ToShortDateString();
                this.SetClinetFocus(((TextBox)this.SLP_SLPDate1.FindControl("TextBoxCode")).ClientID);

                DataTable dt = DataLoad(V_VANDOR, V_TAX_TYPE);

                if (dt.Rows.Count == 0)
                {
                    Response.Redirect("VAM171.aspx?Code=VAM17&Msg=查無檔期資料");
                }
                else
                {
                    #region 資料與GridView繫結
                    string SessionIDName = "VAM172_gv_ItemInfo" + PageTimeStamp.Value;
                    this.GridView1.Visible = true;
                    Session["SessionID"] = SessionIDName;
                    Session[SessionIDName] = dt;
                    this.GridView1.DataSource = dt;
                    this.GridView1.DataBind();
                    #endregion
                }

                this.Form.DefaultButton = this.btnSave.UniqueID;
            }
            else
            {
                if (Request.Form["__EVENTTARGET"] == "SaveData")
                {
                    SaveData();
                }
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        this.panel_parent.Attributes.Add("style", "display:none");
        #endregion
    }//page_load
Ejemplo n.º 2
0
    private void databind(string V_DISC_NO, string V_SESSIONNAME)
    {
        BCO.VAM17_BCO bco = new BCO.VAM17_BCO(ConnectionDB);
        #region 取得發票主檔資料
        DataTable dtMain = (DataTable)Session[V_SESSIONNAME];
        DataRow drA = dtMain.Select("DISC_NO='" + V_DISC_NO + "'")[0];
        //取得原始折讓資料(for delete)
        ArrayList ParameterDel = new ArrayList();

        if (drA != null)
        {
            this.hidID.Value = drA["ID"].ToString();
            this.TextBox2.Text = drA["VENDOR"].ToString() + "/" + drA["VENDOR_NAME"].ToString();
            this.TextBox2.CssClass = "readtxtbox";
            this.SLP_VendorBase1.Text = drA["VENDOR"].ToString();
            this.TextBox2.ReadOnly = true;

            if (drA["TAX_TYPE"].ToString() == "0")
            {
                this.TextBox1.Text = "應稅";
            }
            else if (drA["TAX_TYPE"].ToString() == "1")
            {
                this.TextBox1.Text = "免稅";
            }
            else if (drA["TAX_TYPE"].ToString() == "2")
            {
                this.TextBox1.Text = "零稅";
            }
            hidTaxType.Value = drA["TAX_TYPE"].ToString();
            this.TextBox1.ReadOnly = true;

            if (drA["TRANS_TAX"].ToString() == "0")
            {
                chkTRANS_TAX.Checked = false;
            }
            else if (drA["TRANS_TAX"].ToString() == "1")
            {
                chkTRANS_TAX.Checked = true;
            }


            //稅率
            if (drA["TAX_TYPE"].ToString() == "0")
            {
                decimal iTaxRate;
                bco.QueryTaxRate(out iTaxRate);
                this.hidTaxRate.Value = iTaxRate.ToString();
            }
            else
            {
                this.hidTaxRate.Value = "0";
            }
            Session["V_TAX_TYPE"] = drA["TAX_TYPE"].ToString();
            this.TextBox5.Text = V_DISC_NO;

            this.TextBox1.CssClass = "readtxtbox";
            this.TextBox5.CssClass = "readtxtbox";

            ((TextBox)this.SLP_SLPDate1.FindControl("TextBoxCode")).Text = drA["DISC_DATE"].ToString();
            ((TextBox)this.SLP_SLPDate2.FindControl("TextBoxCode")).Text = drA["KEYIN_DATE"].ToString();

            ((TextBox)this.SLP_SLPNumber1.FindControl("TextBoxCode")).Text = drA["DISC_UAMT"].ToString();
            ((TextBox)this.SLP_SLPNumber4.FindControl("TextBoxCode")).Text = drA["DISC_UAMT"].ToString();
            ((TextBox)this.SLP_SLPNumber2.FindControl("TextBoxCode")).Text = drA["DISC_TAX"].ToString();
            ((TextBox)this.SLP_SLPNumber3.FindControl("TextBoxCode")).Text = drA["DISC_AMT"].ToString();

            ParameterDel.Add(GetValueSetParameter(V_DISC_NO, "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false));
            string seName = "VAM173_Par" + PageTimeStamp.Value;
            Session[seName] = ParameterDel;
        }

        #endregion


        #region 取得資料

        DataTable dtA = new DataTable();
        DataTable dtB = new DataTable();


        dtA = bco.ViewDiscountDetl(V_DISC_NO);
        dtB = bco.QueryDiscountInv(V_DISC_NO);

        string SessionIDNameA = "VAM173_gvA_ItemInfo" + PageTimeStamp.Value;
        string SessionIDNameB = "VAM173_gvB_ItemInfo" + PageTimeStamp.Value;

        this.GridView1.Visible = true;
        Session[SessionIDNameA] = dtA;
        this.GridView1.DataSource = dtA;
        this.GridView1.DataBind();

        this.GridView2.Visible = true;
        Session[SessionIDNameB] = dtB;
        this.GridView2.DataSource = dtB;
        this.GridView2.DataBind();
        if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢";
            this.btnSave.Enabled = false;
        }
        else
        {
            this.btnSave.Enabled = true;
        }
        #endregion
    }