Exemple #1
0
        /// <summary>
        /// To Bind Grid
        /// </summary>
        private void BindGrid()
        {
            // AutomobileOnline.Model.clsDesigRightsDAL objclsDesigRightsDAL = new AutomobileOnline.Model.clsDesigRightsDAL();
            WebTransport.DAL.DesigRightsDAL objclsDesigRightsDAL = new WebTransport.DAL.DesigRightsDAL();

            if (ddlType.SelectedItem.Text == "Form")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeForm(Convert.ToInt32(ddlDesign.SelectedValue));
                objclsDesigRightsDAL = null;
                grdMain.DataSource   = lstGridData;
                grdMain.DataBind();

                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;
            }
            else if (ddlType.SelectedItem.Text == "Menu")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeMenu(Convert.ToInt32(ddlDesign.SelectedValue));
                objclsDesigRightsDAL = null;
                grdMain.DataSource   = lstGridData;
                grdMain.DataBind();

                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;
            }
            else if (ddlType.SelectedItem.Text == "Report")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeRep(Convert.ToInt32(ddlDesign.SelectedValue));
                objclsDesigRightsDAL = null;
                grdMain.DataSource   = lstGridData;
                grdMain.DataBind();

                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;
            }
            else
            {
                lblcontant.Visible = false;
                divpaging.Visible  = false;
            }


            int count    = grdMain.Rows.Count;
            int RowCount = 0;

            foreach (GridViewRow row in grdMain.Rows)
            {
                CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
                if (chkSelect.Checked)
                {
                    RowCount++;
                }
            }
            if (RowCount == count)
            {
                chkSelectAllRows.Checked     = true;
                imgBtnSelectAllRows.ImageUrl = "~/Images/SelectAll_Active.png";
            }
            else
            {
                chkSelectAllRows.Checked     = false;
                imgBtnSelectAllRows.ImageUrl = "~/Images/SelectAll_Inactive.png";
            }
            if (count > 0)
            {
                selectall.Visible = true;
            }
            else
            {
                selectall.Visible = false;
            }
        }
Exemple #2
0
        protected void imgBtnSelectAllRows_Click(object sender, ImageClickEventArgs e)
        {
            Int32  empIdno           = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            int    value             = 0;
            string strMsg            = string.Empty;
            int    intDesigRghtsIdno = 0;

            // AutomobileOnline.Model.clsDesigRightsDAL objclsDesigRightsDAL = new AutomobileOnline.Model.clsDesigRightsDAL();
            WebTransport.DAL.DesigRightsDAL objclsDesigRightsDAL = new WebTransport.DAL.DesigRightsDAL();
            if (ddlType.SelectedItem.Text == "Form")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeForm(Convert.ToInt32(ddlDesign.SelectedValue));
                int i           = 0;
                foreach (GridViewRow row in grdMain.Rows)
                {
                    bool bAdd    = false;
                    bool bEdit   = false;
                    bool bView   = false;
                    bool bDelete = false;
                    bool bPrint  = false;
                    if (lstGridData.Count > 0)
                    {
                        intDesigRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "DesigRghts_Idno"));
                        CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
                        if (chkSelect.Checked == true)
                        {
                            bAdd = true; bEdit = true; bView = true; bDelete = true; bPrint = true;
                        }
                        else if (chkSelect.Checked == false)
                        {
                            bAdd = false; bEdit = false; bView = false; bDelete = false; bPrint = false;
                        }
                        value = objclsDesigRightsDAL.UpdateAll(intDesigRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                        bool bDesigRights = true;
                        if (bAdd == true && bEdit == true && bView == true && bDelete == true && bPrint == true)
                        {
                            bDesigRights = true;
                        }
                        if (bAdd == false && bEdit == false && bView == false && bDelete == false && bPrint == false)
                        {
                            bDesigRights = false;
                        }
                        int intDesigRights = 0;
                        intDesigRights = objclsDesigRightsDAL.UpdateDesigRights(Convert.ToInt32(ddlDesign.SelectedValue) /*intDesigRghtsIdno*/, bDesigRights);
                    }
                    i++;
                }
            }
            else if (ddlType.SelectedItem.Text == "Menu")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeMenu(Convert.ToInt32(ddlDesign.SelectedValue));
                int i           = 0;
                foreach (GridViewRow row in grdMain.Rows)
                {
                    bool bAdd    = false;
                    bool bEdit   = false;
                    bool bView   = false;
                    bool bDelete = false;
                    bool bPrint  = false;
                    if (lstGridData.Count > 0)
                    {
                        intDesigRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "DesigRghts_Idno"));
                        CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
                        if (chkSelect.Checked == true)
                        {
                            bAdd = true; bEdit = true; bView = true; bDelete = true; bPrint = true;
                        }
                        else if (chkSelect.Checked == false)
                        {
                            bAdd = false; bEdit = false; bView = false; bDelete = false; bPrint = false;
                        }
                        value = objclsDesigRightsDAL.UpdateAll(intDesigRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                        bool bDesigRights = true;
                        if (bAdd == true && bEdit == true && bView == true && bDelete == true && bPrint == true)
                        {
                            bDesigRights = true;
                        }
                        if (bAdd == false && bEdit == false && bView == false && bDelete == false && bPrint == false)
                        {
                            bDesigRights = false;
                        }
                        int intDesigRights = 0;
                        intDesigRights = objclsDesigRightsDAL.UpdateDesigRights(Convert.ToInt32(ddlDesign.SelectedValue) /*intDesigRghtsIdno*/, bDesigRights);
                    }
                    i++;
                }
            }
            else if (ddlType.SelectedItem.Text == "Report")
            {
                var lstGridData = objclsDesigRightsDAL.SelectForGridTypeRep(Convert.ToInt32(ddlDesign.SelectedValue));
                int i           = 0;
                foreach (GridViewRow row in grdMain.Rows)
                {
                    bool bAdd    = false;
                    bool bEdit   = false;
                    bool bView   = false;
                    bool bDelete = false;
                    bool bPrint  = false;
                    if (lstGridData.Count > 0)
                    {
                        intDesigRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "DesigRghts_Idno"));
                        CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
                        if (chkSelect.Checked == true)
                        {
                            bAdd = true; bEdit = true; bView = true; bDelete = true; bPrint = true;
                        }
                        else if (chkSelect.Checked == false)
                        {
                            bAdd = false; bEdit = false; bView = false; bDelete = false; bPrint = false;
                        }
                        value = objclsDesigRightsDAL.UpdateAll(intDesigRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                        bool bDesigRights = true;
                        if (bAdd == true && bEdit == true && bView == true && bDelete == true && bPrint == true)
                        {
                            bDesigRights = true;
                        }
                        if (bAdd == false && bEdit == false && bView == false && bDelete == false && bPrint == false)
                        {
                            bDesigRights = false;
                        }
                        int intDesigRights = 0;
                        intDesigRights = objclsDesigRightsDAL.UpdateDesigRights(Convert.ToInt32(ddlDesign.SelectedValue) /*intDesigRghtsIdno*/, bDesigRights);
                    }
                    i++;
                }
            }
            objclsDesigRightsDAL = null;
            if (value > 0)
            {
                this.BindGrid();
                strMsg = "Record updated successfully.";
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
        }