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); }
protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { Int32 empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString()); string strMsg = string.Empty; int intDesigRghtsIdno = 0; bool bAdd = false; bool bEdit = false; bool bView = false; bool bDelete = false; bool bPrint = false; WebTransport.DAL.DesigRightsDAL objclsDesigRightsDAL = new WebTransport.DAL.DesigRightsDAL(); HiddenField hiddesigId = (HiddenField)grdMain.Rows[0].FindControl("hiddesigId"); int intDesignIdno = Convert.ToInt32(hiddesigId.Value); if (e.CommandName == "cmdAdd") { string[] strAdd = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strAdd.Length > 1) { intDesigRghtsIdno = Convert.ToInt32(strAdd[0]); if (Convert.ToBoolean(strAdd[1]) == true) { bAdd = false; } else { bAdd = true; } int value = objclsDesigRightsDAL.UpdateAdd(intDesigRghtsIdno, bAdd, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } if (e.CommandName == "cmdEdit") { string[] strEdit = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strEdit.Length > 1) { intDesigRghtsIdno = Convert.ToInt32(strEdit[0]); if (Convert.ToBoolean(strEdit[1]) == true) { bEdit = false; } else { bEdit = true; } int value = objclsDesigRightsDAL.UpdateEdit(intDesigRghtsIdno, bEdit, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } if (e.CommandName == "cmdView") { string[] strView = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strView.Length > 1) { intDesigRghtsIdno = Convert.ToInt32(strView[0]); if (Convert.ToBoolean(strView[1]) == true) { bView = false; } else { bView = true; } int value = objclsDesigRightsDAL.UpdateView(intDesigRghtsIdno, bView, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } if (e.CommandName == "cmdDelete") { string[] strDelete = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strDelete.Length > 1) { intDesigRghtsIdno = Convert.ToInt32(strDelete[0]); if (Convert.ToBoolean(strDelete[1]) == true) { bDelete = false; } else { bDelete = true; } int value = objclsDesigRightsDAL.UpdateDelete(intDesigRghtsIdno, bDelete, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } if (e.CommandName == "cmdPrint") { string[] strPrint = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strPrint.Length > 1) { intDesigRghtsIdno = Convert.ToInt32(strPrint[0]); if (Convert.ToBoolean(strPrint[1]) == true) { bPrint = false; } else { bPrint = true; } int value = objclsDesigRightsDAL.UpdatePrint(intDesigRghtsIdno, bPrint, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } if (e.CommandName == "cmdSelectAll") { string[] strAll = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strAll.Length > 1) { intDesigRghtsIdno = 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 = objclsDesigRightsDAL.UpdateAll(intDesigRghtsIdno, bAdd, bEdit, bView, bDelete, bPrint, empIdno); objclsDesigRightsDAL = null; if (value > 0) { this.BindGrid(); strMsg = "Record updated successfully."; } } } 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; // AutomobileOnline.Model.clsDesigRightsDAL objclsDesigRightsDAL1 = new AutomobileOnline.Model.clsDesigRightsDAL(); WebTransport.DAL.DesigRightsDAL objclsDesigRightsDAL1 = new WebTransport.DAL.DesigRightsDAL(); intDesigRights = objclsDesigRightsDAL1.UpdateDesigRights(intDesignIdno, bDesigRights); objclsDesigRightsDAL1 = null; this.BindGrid(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); }