예제 #1
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           intUserRghtsIdno = 0;
            UserRightsDAL objUserRightsDAL = new UserRightsDAL();

            if (ddlType.SelectedItem.Text == "Form")
            {
                var lstGridData = objUserRightsDAL.SelectForGridTypeForm(Convert.ToInt32(ddlUser.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)
                    {
                        intUserRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "UserRgt_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 = objUserRightsDAL.UpdateAll(intUserRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                    }
                    i++;
                }
            }
            else if (ddlType.SelectedItem.Text == "Menu")
            {
                var lstGridData = objUserRightsDAL.SelectForGridTypeMenu(Convert.ToInt32(ddlUser.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)
                    {
                        intUserRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "UserRgt_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 = objUserRightsDAL.UpdateAll(intUserRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                    }
                    i++;
                }
            }
            else if (ddlType.SelectedItem.Text == "Report")
            {
                var lstGridData = objUserRightsDAL.SelectForGridTypeRep(Convert.ToInt32(ddlUser.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)
                    {
                        intUserRghtsIdno = Convert.ToInt32(DataBinder.Eval(lstGridData[i], "UserRgt_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 = objUserRightsDAL.UpdateAll(intUserRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                    }
                    i++;
                }
            }
            objUserRightsDAL = null;
            if (value > 0)
            {
                this.BindGrid();
                strMsg = "Record updated successfully.";
            }
            if (value <= 0)
            {
                strMsg = "Record not updated.";
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
        }
예제 #2
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Int32         empIdno          = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string        strMsg           = string.Empty;
            int           intUserRghtsIdno = 0;
            UserRightsDAL objUserRightsDAL = new UserRightsDAL();
            HiddenField   hiduserId        = (HiddenField)grdMain.Rows[0].FindControl("hiduserId");
            int           intUserIdno      = Convert.ToInt32(hiduserId.Value);

            if (e.CommandName == "cmdAdd")
            {
                bool     bAdd   = false;
                string[] strAdd = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strAdd.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strAdd[0]);
                    if (Convert.ToBoolean(strAdd[1]) == true)
                    {
                        bAdd = false;
                    }
                    else
                    {
                        bAdd = true;
                    }

                    int value = objUserRightsDAL.UpdateAdd(intUserRghtsIdno, bAdd, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            if (e.CommandName == "cmdEdit")
            {
                bool     bEdit   = false;
                string[] strEdit = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strEdit.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strEdit[0]);
                    if (Convert.ToBoolean(strEdit[1]) == true)
                    {
                        bEdit = false;
                    }
                    else
                    {
                        bEdit = true;
                    }
                    int value = objUserRightsDAL.UpdateEdit(intUserRghtsIdno, bEdit, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            if (e.CommandName == "cmdView")
            {
                bool     bView   = false;
                string[] strView = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strView.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strView[0]);
                    if (Convert.ToBoolean(strView[1]) == true)
                    {
                        bView = false;
                    }
                    else
                    {
                        bView = true;
                    }
                    int value = objUserRightsDAL.UpdateView(intUserRghtsIdno, bView, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            if (e.CommandName == "cmdDelete")
            {
                bool     bDelete   = false;
                string[] strDelete = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strDelete.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strDelete[0]);
                    if (Convert.ToBoolean(strDelete[1]) == true)
                    {
                        bDelete = false;
                    }
                    else
                    {
                        bDelete = true;
                    }
                    int value = objUserRightsDAL.UpdateDelete(intUserRghtsIdno, bDelete, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            if (e.CommandName == "cmdPrint")
            {
                bool     bPrint   = false;
                string[] strPrint = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strPrint.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strPrint[0]);
                    if (Convert.ToBoolean(strPrint[1]) == true)
                    {
                        bPrint = false;
                    }
                    else
                    {
                        bPrint = true;
                    }
                    int value = objUserRightsDAL.UpdatePrint(intUserRghtsIdno, bPrint, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            if (e.CommandName == "cmdSelectAll")
            {
                bool     bAdd    = false;
                bool     bEdit   = false;
                bool     bView   = false;
                bool     bDelete = false;
                bool     bPrint  = false;
                string[] strAll  = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strAll.Length > 1)
                {
                    intUserRghtsIdno = Convert.ToInt32(strAll[0]);
                    int         value     = 0;
                    GridViewRow row       = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
                    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            = objUserRightsDAL.UpdateAll(intUserRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno);
                    objUserRightsDAL = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record updated successfully.";
                    }
                }
            }
            this.BindGrid();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
        }