Example #1
0
        protected void grdMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgBtnStatus = (ImageButton)e.Row.FindControl("imgBtnStatus");
                bool        status       = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "Status"));
                //ImageButton imgBtnEdit = (ImageButton)e.Row.FindControl("imgBtnEdit");
                ////ImageButton imgBtnDelete = (ImageButton)e.Row.FindControl("imgBtnDelete");
                //base.CheckUserRights(intFormId);
                //if (base.Edit == false)
                //{
                imgBtnStatus.Visible = true;
                //    imgBtnEdit.Visible = false;
                //    grdMain.Columns[4].Visible = false;
                //}
                ////if (base.Delete == false)
                ////{
                ////    imgBtnDelete.Visible = false;
                ////}
                //if ((base.Edit == false) && (base.Delete == false))
                //{
                //    grdMain.Columns[5].Visible = false;
                //}
                if (status == false)
                {
                    imgBtnStatus.ImageUrl = "~/Images/inactive.png";
                }
                else
                {
                    imgBtnStatus.ImageUrl = "~/Images/active.png";
                }
                //if (Convert.ToInt32(drpState.SelectedValue) > 0)
                //{
                //    grdMain.Columns[1].Visible = false;
                //}
                //else
                //{
                //    grdMain.Columns[1].Visible = true;
                //}
                LinkButton lnkbtnDelete = (LinkButton)e.Row.FindControl("lnkbtnDelete");
                string     ItemIdno     = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "PCompIdno"));
                if (ItemIdno != "")
                {
                    PetrolCompanyMasterDAL obj = new PetrolCompanyMasterDAL();

                    var ItemExist = obj.CheckItemExistInOtherMaster(Convert.ToInt32(ItemIdno));
                    if (ItemExist != null && ItemExist.Count > 0)
                    {
                        lnkbtnDelete.Visible = false;
                    }
                    else
                    {
                        lnkbtnDelete.Visible = true;
                    }
                }
            }
        }
Example #2
0
        private void BindGrid()
        {
            PetrolCompanyMasterDAL objclsPetrolCompanyMaster = new PetrolCompanyMasterDAL();
            var lstGridData = objclsPetrolCompanyMaster.SelectForSearch(Convert.ToString(txtPetrolCompanyName.Text.Trim()));

            objclsPetrolCompanyMaster = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("S.No", typeof(string));
                dt.Columns.Add("Company Name", typeof(string));
                dt.Columns.Add("Status", typeof(string));
                int c = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["S.No"]         = ++c;
                    dr["Company Name"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "PCompName"));
                    if (Convert.ToBoolean(DataBinder.Eval(lstGridData[i], "Status")) == true)
                    {
                        dr["Status"] = "Active";
                    }
                    else
                    {
                        dr["Status"] = "Inactive";
                    }
                    dt.Rows.Add(dr);
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }

                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;

                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;
                imgBtnExcel.Visible = true;
                divpaging.Visible   = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): 0 ";
                imgBtnExcel.Visible = false;
                lblcontant.Visible  = false;
                divpaging.Visible   = false;
            }
        }
Example #3
0
        private void Populate(int PCompIdno)
        {
            PetrolCompanyMasterDAL objclsPetrolCompanyMaster = new PetrolCompanyMasterDAL();
            var objPetrolCompanyMaster = objclsPetrolCompanyMaster.SelectById(PCompIdno);

            objclsPetrolCompanyMaster = null;
            if (objPetrolCompanyMaster != null)
            {
                txtPCompanyName.Text = Convert.ToString(objPetrolCompanyMaster.PComp_Name);
                chkStatus.Checked    = Convert.ToBoolean(objPetrolCompanyMaster.Status);
                hidPCompIdno.Value   = Convert.ToString(objPetrolCompanyMaster.PComp_Idno);
                txtPCompanyName.Focus();
            }
        }
Example #4
0
        protected void lnkbtnSave_OnClick(object sender, EventArgs e)
        {
            Int32  empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string strMsg  = string.Empty;
            PetrolCompanyMasterDAL objclsPetrolCompanyMasterDAL = new PetrolCompanyMasterDAL();
            Int64 intCityIdno = 0;

            if (string.IsNullOrEmpty(hidPCompIdno.Value) == true)
            {
                intCityIdno = objclsPetrolCompanyMasterDAL.InsertPCompanyMaster(txtPCompanyName.Text.Trim(), Convert.ToBoolean(chkStatus.Checked), empIdno);
            }
            else
            {
                intCityIdno = objclsPetrolCompanyMasterDAL.UpdatePCompanyMaster(txtPCompanyName.Text.Trim(), Convert.ToInt32(hidPCompIdno.Value), Convert.ToBoolean(chkStatus.Checked), empIdno);
            }
            objclsPetrolCompanyMasterDAL = null;

            if (intCityIdno > 0)
            {
                if (string.IsNullOrEmpty(hidPCompIdno.Value) == false)
                {
                    strMsg = "Record updated successfully.";
                }
                else
                {
                    strMsg = "Record saved successfully.";
                }
                this.ClearControls();
            }
            else if (intCityIdno < 0)
            {
                strMsg = "Record already exists.";
            }
            else
            {
                if (string.IsNullOrEmpty(hidPCompIdno.Value) == false)
                {
                    strMsg = "Record not updated.";
                }
                else
                {
                    strMsg = "Record not saved.";
                }
            }

            Session["Message"] = strMsg.ToString();

            Response.Redirect("PetrolCompanyMaster.aspx");
        }
Example #5
0
        public void countall()
        {
            PetrolCompanyMasterDAL objclsPetrolCompanyMaster = new PetrolCompanyMasterDAL();
            Int64 total = 0;

            total = objclsPetrolCompanyMaster.selectcount();
            if (total > 0)
            {
                lblTotalRecord.Text = "T. Record (s):" + total;
            }
            else
            {
                lblTotalRecord.Text = "T. Record (s): 0 ";
            }
        }
Example #6
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Int32  empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string strMsg  = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("PetrolCompanyMaster.aspx?PCompIdno=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                PetrolCompanyMasterDAL objclsPetrolCompanyMaster = new PetrolCompanyMasterDAL();
                Int32 intValue = objclsPetrolCompanyMaster.Delete(Convert.ToInt32(e.CommandArgument));
                objclsPetrolCompanyMaster = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                }
                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);
            }
            else if (e.CommandName == "cmdstatus")
            {
                int      intCityIdno = 0;
                bool     bStatus     = false;
                string[] strStatus   = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strStatus.Length > 1)
                {
                    intCityIdno = Convert.ToInt32(strStatus[0]);
                    if (Convert.ToBoolean(strStatus[1]) == true)
                    {
                        bStatus = false;
                    }
                    else
                    {
                        bStatus = true;
                    }
                    PetrolCompanyMasterDAL objclsPetrolCompanyMaster = new PetrolCompanyMasterDAL();
                    int value = objclsPetrolCompanyMaster.UpdateStatus(intCityIdno, bStatus, empIdno);
                    objclsPetrolCompanyMaster = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Status updated successfully.";
                    }
                    else
                    {
                        strMsg = "Status not updated.";
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                }
            }
        }