protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        try
        {
            //清除目前選擇DATA            
            this.SelectLabelCode.Text = "";
            this.SelectLabelName.Text = "";

            GridView1.PageSize = Convert.ToInt32(TextBoxPagesize.Text.Trim());
            VAMModel.MaintainPurchaseInvoice bco = new VAMModel.MaintainPurchaseInvoice(ConntionDB);
            firstpage = 0;
            firstindex = -1;

            ParameterList.Clear();
            ParameterList.Add(TextBoxRowCountLimit.Text.Trim());
            string strValue1 = string.Empty;
            string strValue2 = string.Empty;
            RangeStringValue(TextBoxCode.Text.Trim(), TextBoxCode2.Text.Trim(), out strValue1, out strValue2);
            ParameterList.Add(strValue1);
            ParameterList.Add(strValue2);
            RangeStringValue(SLP_VendorBase1.Text.Trim(), SLP_VendorBase2.Text.Trim(), out strValue1, out strValue2);
            ParameterList.Add(strValue1);
            ParameterList.Add(strValue2);
            ParameterList.Add(txt_INV_AMT.Text.Trim());
            ParameterList.Add(txt_NON_DISC_AMT.Text.Trim());
            databind(bco.QueryLikeForSLP(ParameterList));
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }//ButtonQuery_Click
    public string VendorInvoiceName(string Code,
                                    string Manufacture
                                    )
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainPurchaseInvoice MPI = new MaintainPurchaseInvoice(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Add(Code);
            ParameterList.Add(Manufacture);
            ParameterList.Add("");
            DataTable dt = MPI.QueryForSLP(ParameterList);
            Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["INV_UAMT"].ToString() : "查無資料");
        }

        return Name;
    }
 public VAM_SLP_SLP_VendorInvoice()
 {
     MaintainPurchaseInvoice = new VAMModel.MaintainPurchaseInvoice(ConntionDB);
 }
示例#4
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 BD = Request["BD"].ToString();
                string ED = Request["ED"].ToString();
                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();
                ((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode")).Text = BD;
                //((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode")).ReadOnly = true;
                ((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode")).Text = ED;
                //((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode")).ReadOnly = true;
                this.SLP_SLPDateRange1.ReadOnly = true;
                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.MaintainPurchaseInvoice bco = new BCO.MaintainPurchaseInvoice(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(BD, ED, V_VANDOR, V_TAX_TYPE);

                if (dt.Rows.Count == 0)
                {
                    //this.btnSave.Enabled = false;
                    //ErrorMsgLabel.Text = "查無進退貨資料";
                    //ScriptManager.RegisterStartupScript(Page, this.GetType(), "VAM072", "alert('查無進退貨資料');", true);
                    Response.Redirect("VAM071.aspx?Code=VAM07&Msg=查無進退貨資料");
                }
                else
                {
                    Decimal iAmt = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["SOURCE_TYPE"].ToString() == "1")
                            iAmt -= Convert.ToDecimal(dt.Rows[i]["AMT"].ToString());
                        else
                            iAmt += Convert.ToDecimal(dt.Rows[i]["AMT"].ToString());
                    }

                    if (iAmt < 0)
                    {
                        ErrorMsgLabel.Text = "進貨金額 > 退貨金額,故不可開立折讓單據";
                        //20100107當進貨大於退貨時仍可以維護,維護後當按儲存時再做檢核
                        //this.btnSave.Enabled = false;
                    }
                    #region 資料與GridView繫結
                    string SessionIDName = "VAM072_gv_ItemInfo" + PageTimeStamp.Value;
                    this.GridView1.Visible = true;
                    Session["SessionID"] = SessionIDName;
                    Session[SessionIDName] = dt;
                    this.GridView1.DataSource = dt;
                    this.GridView1.DataBind();
                    #endregion
                }

                if (Request.QueryString["Requery"] != null)
                {
                    if (Request.QueryString["Requery"].ToString() == "true")
                    {
                        //SLP_Store1.Text = Session["txtSLP_Store1"] == null ? "" : Session["txtSLP_Store1"].ToString();
                        //SLP_Store2.Text = Session["txtSLP_Store2"] == null ? "" : Session["txtSLP_Store2"].ToString();

                        //databind();
                    }
                }

                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
示例#5
0
    protected void ButtonNew_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 檢查條件
            this.ErrorMsgLabel.Text = "";
            this.GridView1.Visible = false;
            if (this.SLP_EnumBase1.Text == "")
            {
                this.ErrorMsgLabel.Text = "請選擇單一稅別";
                SetDDLFocus(((DropDownList)this.SLP_EnumBase1.FindControl("D1")).ClientID);
                return;
            }

            string s_CheckPage = CheckPageNew(sender);

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

            #region 查詢未日結日期

            string V_MSG, V_RESULT;

            BCO.MaintainPurchaseInvoice bco = new BCO.MaintainPurchaseInvoice(ConnectionDB);
            bco.CheckDailyClose(this.SLP_SLPDateRange1.StartDate.ToString(), this.SLP_SLPDateRange1.EndDate.ToString(), out V_MSG, out V_RESULT);

            if (V_MSG != string.Empty)
            {
                this.ErrorMsgLabel.Text = V_MSG;
                SetClinetFocus(((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode")).ClientID);
                return;
            }
            #endregion

            Response.Redirect("VAM072.aspx?Code=VAM07&BD=" + this.SLP_SLPDateRange1.StartDate.ToString() + "&ED=" + this.SLP_SLPDateRange1.EndDate.ToString() + "&V_VANDOR="
                + this.SLP_VendorBase1.Text.Trim() + "&V_VANDOR_NAME=" + this.SLP_VendorBase1.Name + "&V_TAX_TYPE=" + this.SLP_EnumBase1.Text.ToString());
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
        #endregion
    }//ButtonNew_Click
示例#6
0
    private void SaveData()
    {
        try
        {
            ArrayList ParameterDel = new ArrayList();

            string seName = "VAM063_Par" + PageTimeStamp.Value;
            ParameterDel = (ArrayList)Session[seName];
            ParameterDel.Add(Session["UID"].ToString());
            ParameterDel.Add(System.DateTime.Now);

            #region 傳入參數

            ParameterList.Clear();
            //V_INV_NO
            ParameterList.Add(GetValueSetParameter(this.txtINV.Text.Trim(), "string", false));
            //D_INV_DATE
            ParameterList.Add(GetValueSetParameter(this.SLP_SLPDate2.Text.Trim(), "date", false));
            //V_FORM_NO
            ParameterList.Add(GetValueSetParameter(this.SLP_CodeFile2.Text.Trim(), "string", false));
            //N_TAX_TYPE
            ParameterList.Add(GetValueSetParameter(this.TextBox1.Text.Trim().Substring(0, 1), "int", false));
            //V_VENDOR
            ParameterList.Add(GetValueSetParameter(this.hidVANDOR.Value, "string", false));
            //N_INV_UAMT
            ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber1.Text.Trim(), "Decimal", false));
            //N_INV_TAX
            ParameterList.Add(GetValueSetParameter(this.SLP_SLPNumber2.Text.Trim(), "Decimal", false));
            //D_KEYIN_DATE
            ParameterList.Add(GetValueSetParameter(this.SLP_SLPDate1.Text.Trim(), "date", false));
            //D_UPDATEDATE
            ParameterList.Add(System.DateTime.Now);
            //V_UPDATEUID
            ParameterList.Add(Session["UID"].ToString());
            //V_CREATEUID
            ParameterList.Add(Session["UID"].ToString());
            //D_CREATEDATE
            ParameterList.Add(System.DateTime.Now);


            string SessionIDName = "VAM063_gv_ItemInfo" + PageTimeStamp.Value;
            DataTable dt = (DataTable)Session[SessionIDName];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["AMT"] = Convert.ToDecimal(((TextBox)this.GridView1.Rows[i].FindControl("txtAMT")).Text.Trim());
            }


            #endregion

            #region 新增資料

            BCO.MaintainPurchaseInvoice bco = new BCO.MaintainPurchaseInvoice(ConnectionDB);
            string sMsg = bco.UpdatePurchaseInvoice(ParameterDel, ParameterList, dt, null);
            if (sMsg != "")
                ErrorMsgLabel.Text = sMsg;
            else
                ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "ClientScript", string.Format("alert('儲存完成');location.replace('VAM061.aspx?Code=VAM06&INV=" + this.txtINV.Text.Trim() + "');", Session["UID"].ToString().Trim()), true);
            //this.UpdatePanel1.Update();
            #endregion

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
示例#7
0
    }//UC_RecPre
    #endregion

    private void databind(string V_INVOICE_NO, string V_SESSIONNAME)
    {
        BCO.MaintainPurchaseInvoice bco = new BCO.MaintainPurchaseInvoice(ConnectionDB);
        #region 取得發票主檔資料
        DataTable dtMain = (DataTable)Session[V_SESSIONNAME];
        DataRow drA = dtMain.Select("INV_NO='" + V_INVOICE_NO + "'")[0];
        //取得原始發票資料(for delete)
        ArrayList ParameterDel = new ArrayList();

        if (drA != null)
        {
            this.TextBox2.Text = drA["VENDOR"].ToString() + drA["VENDOR_NAME"].ToString();
            this.TextBox2.ReadOnly = true;
            this.hidVANDOR.Value = drA["VENDOR"].ToString();
            this.TextBox1.Text = drA["TAX_TYPE_EXPLAIN"].ToString();
            this.TextBox1.ReadOnly = true;

            //稅率
            if (drA["TAX_TYPE_EXPLAIN"].ToString().Substring(0, 1) == "0")
            {
                decimal iTaxRate;
                bco.QueryTaxRate(out iTaxRate);
                this.hidTaxRate.Value = iTaxRate.ToString();
            }
            else
                this.hidTaxRate.Value = "0";

            ((TextBox)this.SLP_SLPDate1.FindControl("TextBoxCode")).Text = drA["KEYIN_DATE"].ToString();
            ((TextBox)this.SLP_SLPDate2.FindControl("TextBoxCode")).Text = drA["INV_DATE"].ToString();
            //((TextBox)this.SLP_VendorInvoice1.FindControl("TextBoxCode")).Text = V_INVOICE_NO;
            this.txtINV.Text = V_INVOICE_NO;
            //((TextBox)this.SLP_VendorInvoice1.FindControl("TextBoxCode")).ReadOnly=true;
            this.txtINV.ReadOnly = true;

            this.SLP_SLPNumber1.Text = Convert.ToDecimal(drA["INV_UAMT"].ToString()).ToString("0");

            this.SLP_SLPNumber2.Text = Convert.ToDecimal(drA["INV_TAX"].ToString()).ToString("0");
            decimal stotal = (Convert.ToDecimal(drA["INV_UAMT"].ToString()) + Convert.ToDecimal(drA["INV_TAX"].ToString()));

            this.SLP_SLPNumber3.Text = stotal.ToString("0");
            this.SLP_CodeFile2.Text = drA["FORM_NO"].ToString();
            ParameterDel.Add(GetValueSetParameter(V_INVOICE_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 = "VAM063_Par" + PageTimeStamp.Value;
            Session[seName] = ParameterDel;

            this.TextBox2.CssClass = "readtxtbox";
            this.TextBox1.CssClass = "readtxtbox";
            this.txtINV.CssClass = "readtxtbox";
        }

        #endregion


        #region 取得資料

        DataTable dtA = new DataTable();


        dtA = bco.QueryInvoiceDetl(V_INVOICE_NO);

        string SessionIDName = "VAM063_gv_ItemInfo" + PageTimeStamp.Value;

        this.GridView1.Visible = true;
        //Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dtA;
        this.GridView1.DataSource = dtA;
        this.GridView1.DataBind();
        ((TextBox)this.GridView1.Rows[GridView1.Rows.Count - 1].FindControl("txtAMT")).Attributes["onblur"] = "document.getElementById('ctl00_CPH_TabContainer1_TabPanel2_btnSave').focus()";
        if (dtA.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢";
            this.btnSave.Enabled = false;
        }
        else
        {
            this.btnSave.Enabled = true;
        }
        #endregion
    }
示例#8
0
    //protected void btnReCount_Click(object sender, EventArgs e)
    //{
    //    ReCnt();
    //}

     protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {

            DataTable dtA = (DataTable)Session[this.hidSessionName.Value];
            DataRow drA = dtA.Select("INV_NO='" + this.txtINV.Text + "'")[0];
            
            
            //1. 已經被折讓過的發票資料A. NON_DISC_AMT <> A.INV_UAMT 則不能刪除,顯示提醒《此張發票已有折讓資料,無法刪除》。
            //2. 已經被折讓的物料差資料C. NON_DISC_AMT <> C. DIFF_INV_UAMT 則不能刪除,顯示提醒無法刪除。
            ArrayList ParameterDel = new ArrayList();
            ParameterDel.Add(GetValueSetParameter(drA["INV_NO"].ToString(), "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));
            ParameterDel.Add(Session["UID"].ToString());
            ParameterDel.Add(System.DateTime.Now);
            BCO.MaintainPurchaseInvoice bco = new BCO.MaintainPurchaseInvoice(ConnectionDB);
            string sMsg = bco.DeletePurchaseInvoice(ParameterDel, null);
            //if (sMsg == "刪除成功")
            //{
            //    drA.Delete();
            //    dtA.AcceptChanges();
            //    Session[SessionIDName] = dtA;
            //    this.GridView1.DataSource = dtA;
            //    this.GridView1.DataBind();

            //    ArrayList NOList = new ArrayList();
            //    for (int j = 0; j < dtA.Rows.Count; j++)
            //    {
            //        string[] strNO = new string[2];
            //        strNO[0] = dtA.Rows[j]["INV_NO"].ToString();
            //        strNO[1] = SessionIDName;
            //        NOList.Add(strNO);
            //    }

            //    Session["VAM061Query" + SessionIDName] = NOList;
            //}
            ErrorMsgLabel.Text = sMsg;
            this.btnDel.Enabled = false;
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("位置0") == -1)
                ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者異動,請重新查詢再進行編輯。";
            else
                ErrorMsgLabel.Text = ex.Message;
        }
    }