예제 #1
0
    protected void btnDiscExcel_Click(object sender, EventArgs e)
    {
        try
        {
            this.btnDiscExcel.Attributes.Add("onclick", "OffPanel('" + this.ErrorMsgLabel.ClientID + "');");
            string type = "";
            if (rdoType4.Checked)
            {
                #region 折讓單套印
                type = "4";
                string errMsg = "";
                bool errored = false;
                string objID = null;
                if (SLP_SLPDateRange.StartDate.Length > 0 && SLP_SLPDateRange.EndDate.Length > 0)
                    if (DateTime.Parse(SLP_SLPDateRange.StartDate) > DateTime.Parse(SLP_SLPDateRange.EndDate))
                    {
                        errMsg += "發票/折讓日期起日不可大於迄日";
                        errored = true;
                        objID = ((ASP.wui_slp_slp_slpdate_ascx)((ASP.wui_slp_slp_slpdaterange_ascx)SLP_SLPDateRange).FindControl("SLP_SLPDate1")).FindControl("TextBoxCode").ClientID;
                    }

                if (SLP_VendorBase1.Text.Trim().Length > 0 && SLP_VendorBase2.Text.Trim().Length > 0)
                    if (string.Compare(SLP_VendorBase1.Text.Trim(), SLP_VendorBase2.Text.Trim()) > 0)
                    {
                        if (!errored)
                        {
                            errMsg += "廠商統編起號不可大於迄號";
                            errored = true;
                            objID = ((TextBox)((ASP.vdm_slp_slp_vendorbase_ascx)SLP_VendorBase1).FindControl("TextBoxCode")).ClientID;
                        }
                    }

                if (SLP_SLPDateRange1.StartDate.Length > 0 && SLP_SLPDateRange1.EndDate.Length > 0)
                    if (DateTime.Parse(SLP_SLPDateRange1.StartDate) > DateTime.Parse(SLP_SLPDateRange1.EndDate))
                    {
                        if (!errored)
                        {
                            errMsg += "入帳日期起日不可大於迄日";
                            errored = true;
                            objID = ((ASP.wui_slp_slp_slpdate_ascx)((ASP.wui_slp_slp_slpdaterange_ascx)SLP_SLPDateRange1).FindControl("SLP_SLPDate1")).FindControl("TextBoxCode").ClientID;
                            //objID = ((TextBox)((WUI.SLP.SLPDate)this.SLP_SLPDateRange1.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode")).ClientID;
                        }
                    }

                if (SLP_VendorDisc1.Text.Trim().Length > 0 && SLP_VendorDisc2.Text.Trim().Length > 0)
                    if (string.Compare(SLP_VendorDisc1.Text.Trim(), SLP_VendorDisc2.Text.Trim()) > 0)
                    {
                        if (!errored)
                        {
                            errMsg += "折讓單號起號不可大於迄號";
                            errored = true;
                            objID = ((TextBox)((ASP.vam_slp_slp_vendordisc_ascx)SLP_VendorDisc1).FindControl("TextBoxCode")).ClientID;
                        }
                    }
                if (errMsg.Length > 0)
                {
                    ErrorMsgLabel.Text = errMsg;
                    string s_Return_String = string.Empty;
                    s_Return_String = @"
                                    function CAACommon_set_Focus( )
                                    {
                                        try
                                        {
                                            document.getElementById('" + objID + @"').select();
                                            document.getElementById('" + objID + @"').focus();
                                        }
                                        catch(err){setTimeout('CAACommon_set_Focus( )', 100);}
                                    }

                                    CAACommon_set_Focus( );
                                    ";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "VAM121.aspx", s_Return_String, true);
                    return;
                }

                ParameterList.Clear();
                ParameterList.Add(SLP_SLPDateRange.StartDate);
                ParameterList.Add(SLP_SLPDateRange.EndDate);
                ParameterList.Add(SLP_VendorBase1.Text.Trim());
                ParameterList.Add(SLP_VendorBase2.Text.Trim());
                ParameterList.Add(SLP_EnumBase.Text); //課稅別
                ParameterList.Add(SLP_SLPDateRange1.StartDate); //入帳日期(起)
                ParameterList.Add(SLP_SLPDateRange1.EndDate); //入帳日期(迄)
                ParameterList.Add(SLP_VendorDisc1.Text);
                ParameterList.Add(SLP_VendorDisc2.Text);
                ParameterList.Add(ddlTRANS_TAX.Text);
                BCO.RecordingDiscountInvoiceFormat bco = new BCO.RecordingDiscountInvoiceFormat(ConntionDB);
                DataTable dt = bco.ExportDiscountInvoiceFormat(ParameterList);
                if (dt.Rows.Count == 0)
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM121.aspx", "alert('查無資料');", true);
                    return;
                }
                GenDiscExcel(dt);
                #endregion
            }
            else
            {
                ErrorMsgLabel.Text = "非折讓單套印選項";
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
예제 #2
0
    protected void btnTran_Click(object sender, EventArgs e)
    {
        try
        {
            this.btnTran.Attributes.Add("onclick", "OffPanel('" + this.ErrorMsgLabel.ClientID + "');");
            string type = "";
            if (rdoType4.Checked)
            {
                #region 折讓單套印
                type = "4";
                string errMsg = "";
                bool errored = false;
                string objID = null;
                if (SLP_SLPDateRange.StartDate.Length > 0 && SLP_SLPDateRange.EndDate.Length > 0)
                    if (DateTime.Parse(SLP_SLPDateRange.StartDate) > DateTime.Parse(SLP_SLPDateRange.EndDate))
                    {
                        errMsg += "發票/折讓日期起日不可大於迄日";
                        errored = true;
                        objID = ((ASP.wui_slp_slp_slpdate_ascx)((ASP.wui_slp_slp_slpdaterange_ascx)SLP_SLPDateRange).FindControl("SLP_SLPDate1")).FindControl("TextBoxCode").ClientID;
                    }

                if (SLP_VendorBase1.Text.Trim().Length > 0 && SLP_VendorBase2.Text.Trim().Length > 0)
                    if (string.Compare(SLP_VendorBase1.Text.Trim(), SLP_VendorBase2.Text.Trim()) > 0)
                    {
                        if (!errored)
                        {
                            errMsg += "廠商統編起號不可大於迄號";
                            errored = true;
                            objID = ((TextBox)((ASP.vdm_slp_slp_vendorbase_ascx)SLP_VendorBase1).FindControl("TextBoxCode")).ClientID;
                        }
                    }

                if (SLP_SLPDateRange1.StartDate.Length > 0 && SLP_SLPDateRange1.EndDate.Length > 0)
                    if (DateTime.Parse(SLP_SLPDateRange1.StartDate) > DateTime.Parse(SLP_SLPDateRange1.EndDate))
                    {
                        if (!errored)
                        {
                            errMsg += "入帳日期起日不可大於迄日";
                            errored = true;
                            objID = ((ASP.wui_slp_slp_slpdate_ascx)((ASP.wui_slp_slp_slpdaterange_ascx)SLP_SLPDateRange1).FindControl("SLP_SLPDate1")).FindControl("TextBoxCode").ClientID;
                        }
                    }

                if (SLP_VendorDisc1.Text.Trim().Length > 0 && SLP_VendorDisc2.Text.Trim().Length > 0)
                    if (string.Compare(SLP_VendorDisc1.Text.Trim(), SLP_VendorDisc2.Text.Trim()) > 0)
                    {
                        if (!errored)
                        {
                            errMsg += "折讓單號起號不可大於迄號";
                            errored = true;
                            objID = ((TextBox)((ASP.vam_slp_slp_vendordisc_ascx)SLP_VendorDisc1).FindControl("TextBoxCode")).ClientID;
                        }
                    }
                if (errMsg.Length > 0)
                {
                    ErrorMsgLabel.Text = errMsg;
                    string s_Return_String = string.Empty;
                    s_Return_String = @"
                                    function CAACommon_set_Focus( )
                                    {
                                        try
                                        {
                                            document.getElementById('" + objID + @"').select();
                                            document.getElementById('" + objID + @"').focus();
                                        }
                                        catch(err){setTimeout('CAACommon_set_Focus( )', 100);}
                                    }

                                    CAACommon_set_Focus( );
                                    ";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "VAM121.aspx", s_Return_String, true);
                    return;
                }
                ParameterList.Clear();
                ParameterList.Add(SLP_SLPDateRange.StartDate);
                ParameterList.Add(SLP_SLPDateRange.EndDate);
                ParameterList.Add(SLP_VendorBase1.Text.Trim());
                ParameterList.Add(SLP_VendorBase2.Text.Trim());
                ParameterList.Add(SLP_EnumBase.Text); //課稅別
                ParameterList.Add(SLP_SLPDateRange1.StartDate); //入帳日期(起)
                ParameterList.Add(SLP_SLPDateRange1.EndDate); //入帳日期(迄)
                ParameterList.Add(SLP_VendorDisc1.Text);
                ParameterList.Add(SLP_VendorDisc2.Text);
                ParameterList.Add(ddlTRANS_TAX.Text);
                BCO.RecordingDiscountInvoiceFormat bco = new BCO.RecordingDiscountInvoiceFormat(ConntionDB);
                DataTable dt = bco.QueryDiscountInvoiceFormat(ParameterList);
                if (dt.Rows.Count == 0)
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM121.aspx", "alert('查無資料');", true);
                    return;
                }
                ShowReport(dt, type);
                #endregion
            }
            else
            {

                #region 檢查條件
                this.ErrorMsgLabel.Text = "";
                string s_CheckPage = CheckPage();
                if (s_CheckPage != string.Empty)
                {
                    this.ErrorMsgLabel.Text = s_CheckPage;
                    return;
                }
                #endregion

                #region 傳入參數
                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange.StartDate.ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange.EndDate.ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_VendorBase1.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_VendorBase2.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_EnumBase.Text.Trim(), "int", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange1.StartDate.ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_SLPDateRange1.EndDate.ToString(), "string", false));
                #endregion

                DataTable dtA = new DataTable();
                DataTable dtB = new DataTable();
                if (this.rdoType1.Checked == true)
                {
                    BCO.RecordingPurchaseInvoice bco = new BCO.RecordingPurchaseInvoice(ConntionDB);
                    dtA = bco.QueryPurchaseInvoice(ParameterList);
                    if (dtA.Rows.Count == 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM121.aspx", "alert('查無資料');", true);
                        return;
                    }
                    string sINV_NO = "";
                    for (int i = 0; i < dtA.Rows.Count; i++)
                    {
                        if (dtA.Rows[i]["INV_NO"].ToString() == sINV_NO)
                        {
                            DataRow drA = dtA.Rows[i];
                            drA.BeginEdit();
                            drA["INV_UAMT"] = System.DBNull.Value;
                            drA["INV_TAX"] = System.DBNull.Value;
                            drA.EndEdit();
                        }
                        sINV_NO = dtA.Rows[i]["INV_NO"].ToString();
                    }
                    ShowReportA(dtA, dtB, "XLS", "VAM121R");
                }
                else if (this.rdoType2.Checked == true)
                {
                    BCO.RecordingDiscountInvoice bco = new BCO.RecordingDiscountInvoice(ConntionDB);
                    dtB = bco.QueryDiscountInvoice(ParameterList);
                    if (dtB.Rows.Count == 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM121.aspx", "alert('查無資料');", true);
                        return;
                    }

                    string sDISC_NO = "";
                    for (int i = 0; i < dtB.Rows.Count; i++)
                    {
                        if (dtB.Rows[i]["DISC_NO"].ToString() == sDISC_NO)
                        {
                            DataRow drB = dtB.Rows[i];
                            drB.BeginEdit();
                            drB["DISC_UAMT"] = System.DBNull.Value;
                            drB["DISC_TAX"] = System.DBNull.Value;
                            drB.EndEdit();
                        }
                        sDISC_NO = dtB.Rows[i]["DISC_NO"].ToString();
                    }
                    ShowReportA(dtA, dtB, "XLS", "VAM122R");
                }
                else if (this.rdoType3.Checked == true)
                {
                    BCO.RecordingPurchaseInvoice bco = new BCO.RecordingPurchaseInvoice(ConntionDB);
                    dtA = bco.QueryPurchaseInvoice(ParameterList);

                    string sINV_NO = "";
                    for (int i = 0; i < dtA.Rows.Count; i++)
                    {
                        if (dtA.Rows[i]["INV_NO"].ToString() == sINV_NO)
                        {
                            DataRow drA = dtA.Rows[i];
                            drA.BeginEdit();
                            drA["INV_UAMT"] = System.DBNull.Value;
                            drA["INV_TAX"] = System.DBNull.Value;
                            drA.EndEdit();
                        }
                        sINV_NO = dtA.Rows[i]["INV_NO"].ToString();
                    }

                    BCO.RecordingDiscountInvoice bco1 = new BCO.RecordingDiscountInvoice(ConntionDB);
                    dtB = bco1.QueryDiscountInvoice(ParameterList);

                    string sDISC_NO = "";
                    for (int i = 0; i < dtB.Rows.Count; i++)
                    {
                        if (dtB.Rows[i]["DISC_NO"].ToString() == sDISC_NO)
                        {
                            DataRow drB = dtB.Rows[i];
                            drB.BeginEdit();
                            drB["DISC_UAMT"] = System.DBNull.Value;
                            drB["DISC_TAX"] = System.DBNull.Value;
                            drB.EndEdit();
                        }
                        sDISC_NO = dtB.Rows[i]["DISC_NO"].ToString();
                    }
                    if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM121.aspx", "alert('查無資料');", true);
                        return;
                    }
                    ShowReportA(dtA, dtB, "XLS", "VAM123R");
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }