Exemple #1
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("HireInvoice.aspx?HI=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                HireInvDAL obj      = new HireInvDAL();
                Int32      intValue = obj.DeleteHireInvoice(Convert.ToInt32(e.CommandArgument));
                obj = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    txtInvoiceno.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.UrlReferrer == null)
            {
                base.AutoRedirect();
            }
            if (!IsPostBack)
            {
                ddlDateRange.Focus();
                Datefrom.Attributes.Add("onkeypress", "return notAllowAnything(event);");
                txtDateTo.Attributes.Add("onkeypress", "return notAllowAnything(event);");
                txtInvoiceno.Attributes.Add("onkeypress", "return allowOnlyNumber(event);");
                this.BindDateRange();
                this.BindLocationFrom();
                this.ddlDateRange_SelectedIndexChanged(sender, e);

                HireInvDAL Obj           = new HireInvDAL();
                DateTime?  datefromValue = null;
                DateTime?  dateToValue   = null;
                datefromValue       = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text));
                dateToValue         = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
                lblTotalRecord.Text = "T. Record (s): " + Obj.SelectHireInvoiceCount(Convert.ToInt32(ddlDateRange.SelectedValue), datefromValue, dateToValue);
                prints.Visible      = false;
            }
        }
Exemple #3
0
        private void BindGrid()
        {
            HireInvDAL obj           = new HireInvDAL();
            DateTime?  datefromValue = null;
            DateTime?  dateToValue   = null;
            Int64      yearIDNO      = Convert.ToInt32(ddlDateRange.SelectedValue);
            int        BillNo        = string.IsNullOrEmpty(Convert.ToString(txtInvoiceno.Text)) ? 0 : Convert.ToInt32(txtInvoiceno.Text);


            if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false)
            {
                datefromValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtDateTo.Text)) == false)
            {
                dateToValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
            }


            int   Locidno  = Convert.ToInt32(drpCityFrom.SelectedValue == "" ? 0 : Convert.ToInt32(drpCityFrom.SelectedValue));
            Int32 yearidno = Convert.ToInt32(ddlDateRange.SelectedValue == "" ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue));
            Int64 UserIdno = 0;

            if (Convert.ToString(Session["Userclass"]) != "Admin")
            {
                UserIdno = Convert.ToInt64(Session["UserIdno"]);
            }
            var lstGridData = obj.SelectSerach(BillNo, datefromValue, dateToValue, Locidno, yearidno, UserIdno);

            obj = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;
                imgBtnExcel.Visible = false;

                Double TotalNetAmount = 0;

                for (int i = 0; i < lstGridData.Count; i++)
                {
                    TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt"));
                }
                lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");

                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text    = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString();
                lblcontant.Visible = true;
                divpaging.Visible  = true;
                prints.Visible     = false;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): 0 ";
                lblcontant.Visible  = false;
                divpaging.Visible   = false;
                imgBtnExcel.Visible = false;
                prints.Visible      = false;
            }
        }