Пример #1
0
    protected void btnGo_Click(object sender, EventArgs e)
    {
        if (txt_BookingDate.Text != "" && txt_bookingDateTo.Text == "")
        {
            lblValidation.Visible = true;
            lblValidation.Text    = "Please Select the Booking Date To !!";
            txt_bookingDateTo.Focus();
        }
        else if (txt_BookingDate.Text == "" && txt_bookingDateTo.Text != "")
        {
            lblValidation.Visible = true;
            lblValidation.Text    = "Please Select the Booking Date From !!";
            txt_BookingDate.Focus();
        }
        else
        {
            lblValidation.Visible = false;
            try
            {
                if (Page.IsPostBack)
                {
                    lblMess.Text = "No Records Found!";
                    gv_Report.Dispose();
                    gv_Report.DataBind();
                }
                decimal totamt = 0; int quantity = 0;
                string  BookingID         = txt_BookingID.Text.Length > 0 ? txt_BookingID.Text : "0";
                string  pgReceipt         = txt_ReceiptNo.Text.Length > 0 ? txt_ReceiptNo.Text : "0";
                string  DateOfBookingFrom = txt_BookingDate.Text.Length > 0 ? txt_BookingDate.Text : "0";
                string  DateOfBookingTo   = txt_bookingDateTo.Text.Length > 0 ? txt_bookingDateTo.Text : "0";
                string  Name          = txt_Name.Text.Length > 0 ? txt_Name.Text : "0";
                string  Package       = ddlPackage.SelectedItem.Text;
                int     paymentStatus = Convert.ToInt32(ddlPaymentStatus.SelectedValue);
                DataSet ds            = TransactionBOL.Select_Report_tbl_ValentinePackages(BookingID, DateOfBookingFrom, DateOfBookingTo, Name, pgReceipt, Package, paymentStatus);
                string  data          = ds.Tables[0].Columns[9].ToString();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    Btn_Excel.Enabled    = true;
                    btnPrint.Disabled    = false;
                    gv_Report.DataSource = ds;
                    lblMess.Text         = "";
                }
                else
                {
                    btnPrint.Disabled = true;
                    Btn_Excel.Enabled = false;
                    lblMess.Text      = "No Records Found!";
                }
                gv_Report.DataBind();

                if (gv_Report.Rows.Count > 0)
                {
                    foreach (GridViewRow Gr in gv_Report.Rows)
                    {
                        totamt   = totamt + decimal.Parse(Gr.Cells[2].Text);
                        quantity = quantity + int.Parse(Gr.Cells[3].Text);
                    }
                    gv_Report.FooterRow.Cells[1].Text = "Total";
                    gv_Report.FooterRow.Cells[3].Text = quantity.ToString();

                    gv_Report.FooterRow.Cells[2].Text = totamt.ToString();
                }
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
            }
        }
    }