//protected void GvPermissions_RowDataBound(object sender, GridViewRowEventArgs e) //{ // if (e.Row.RowType == DataControlRowType.DataRow) // { // Label lblScreenID1 = (Label)e.Row.FindControl("lblScreenID"); // Label lblScreenName1 = (Label)e.Row.FindControl("lblScreenName"); // CheckBox ChkAdd1 = (CheckBox)e.Row.FindControl("ChkAdd"); // } //} protected void ddlservice_SelectedIndexChanged(object sender, EventArgs e) { objBAL = new ClsBAL(); if (ddlservice.SelectedValue == "ALL") { ObjDataset = objBAL.GetScreens(); if (ObjDataset != null) { if (ObjDataset.Tables.Count > 0) { if (ObjDataset.Tables[0].Rows.Count > 0) { GvPermissions.DataSource = ObjDataset.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } } else { ObjDataset = objBAL.getscreenbyservice(ddlservice.SelectedValue); if (ObjDataset != null) { if (ObjDataset.Tables.Count > 0) { if (ObjDataset.Tables[0].Rows.Count > 0) { GvPermissions.DataSource = ObjDataset.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } } }
protected void GvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Change") { tdmsg.Visible = false; lblMainMsg.Text = ""; // int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button clicked // by the user from the Rows collection. // GridViewRow row = GvUsers.Rows[index]; try { //if (ViewState["UserPermissions"] != null) //{ //if (ViewState["EditUser"].ToString() == "1") //{ GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); // GridViewRow gRow = (GridViewRow)(Label)e.CommandSource; Label lblUserName1 = (Label)gRow.FindControl("lblUserName"); Label lblName1 = (Label)gRow.FindControl("lblName"); LinkButton lblRoleID1 = (LinkButton)gRow.FindControl("lblRoleID"); Label lblID1 = (Label)gRow.FindControl("lblID"); Label lblPassword1 = (Label)gRow.FindControl("lblPassword"); Label lblEmailId = (Label)gRow.FindControl("lblEmailId"); Label lblAddress = (Label)gRow.FindControl("lblAddress"); Label lblCity = (Label)gRow.FindControl("lblCity"); Label lblState = (Label)gRow.FindControl("lblState"); Label lblCountry = (Label)gRow.FindControl("lblCountry"); Label lblPinCode = (Label)gRow.FindControl("lblPinCode"); Label lblMobileNo = (Label)gRow.FindControl("lblMobileNo"); txtUsername.Text = lblUserName1.Text; txtName.Text = lblName1.Text; ddlRole.SelectedValue = lblRoleID1.Text; lblID.Text = lblID1.Text; txtPassword.Text = lblPassword1.Text; txtCnfrmPswd.Text = lblPassword1.Text; txtCnfrmPswd.TextMode = TextBoxMode.SingleLine; txtPassword.TextMode = TextBoxMode.SingleLine; txtUsername.Enabled = false; txtEmailId.Text = lblEmailId.Text; txtAddress.Text = lblAddress.Text; txtCity.Text = lblCity.Text; ddlState.Text = lblState.Text; ddlcountry.Text = lblCountry.Text; txtPinCode.Text = lblPinCode.Text; txtMobileNo.Text = lblMobileNo.Text; btnSaveUD.Visible = false; btnCancel.Visible = true; btnUpdateUD.Visible = true; BindRoles(); MVUsers.ActiveViewIndex = 1; MVUsers.Visible = true; //} //else //{ // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = " No Permission to Edit Users.Please Contact Administrator for further details..."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // MVUsers.ActiveViewIndex = 0; // MVUsers.Visible = true; //} // } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Change", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } #region TEst //System.Text.StringBuilder sb = new System.Text.StringBuilder(); //sb.Append(@"<script language='javascript'>"); //sb.Append(@"$(document).ready(function () {"); //sb.Append(@"$('[id$='txtUsername']').val ="); //sb.Append(lblUserName1.Text); //sb.Append(@";$('[id$='txtName']').val = "); //sb.Append(lblName1.Text); //sb.Append(@";$('[id$='txtPassword']').val ="); //sb.Append(lblPassword1.Text); //sb.Append(@";$('[id$='txtCnfrmPswd']').val ="); //sb.Append(lblPassword1.Text); //sb.Append(@";$('[id$='ddlRole']').val ="); //sb.Append(lblRoleID1.Text); //sb.Append(@"$('.adduser').show('slow');"); //sb.Append(@"$('.abc').hide('slow');"); //sb.Append(@"$('[id$='btnSaveUD']').hide('slow');"); //sb.Append(@"$('[id$='btnUpdateUD']').show('slow');"); //sb.Append(@"});});"); //sb.Append(@"</script>"); //ScriptManager.RegisterStartupScript(GvUsers, GvUsers.GetType(), "JSCR", sb.ToString(), false); #endregion } if (e.CommandName == "Remove") { tdmsg.Visible = false; lblMainMsg.Text = ""; try { //if (ViewState["UserPermissions"] != null) //{ //if (ViewState["DeleteUser"].ToString() == "1") //{ GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); // GridViewRow gRow = (GridViewRow)(Label)e.CommandSource; Label lblID1 = (Label)gRow.FindControl("lblID"); objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(lblID1.Text); objBAL.modifiedBy = Convert.ToInt32(1); if (objBAL.DeleteUser()) { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "User details Deleted Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; BindUsers(); MVUsers.Visible = true; } else { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); lblMainMsg.Text = "OOPS...Failed to Delete user setails...."; lblMainMsg.ForeColor = System.Drawing.Color.Maroon; } //} //else //{ // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = " No Permission to delete Users.Please Contact Administrator for further details..."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // MVUsers.ActiveViewIndex = 0; // MVUsers.Visible = true; //} // } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Remove", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } } if (e.CommandName == "Permissions") { tdmsg.Visible = false; lblMainMsg.Text = ""; try { GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); Label lblUserName1 = (Label)gRow.FindControl("lblUserName"); Label lblName1 = (Label)gRow.FindControl("lblName"); Label lblRole1 = (Label)gRow.FindControl("lblRole"); Label lblID1 = (Label)gRow.FindControl("lblID"); Label lblPassword1 = (Label)gRow.FindControl("lblPassword"); lblRolePer.Text = lblRole1.Text; lblUserNamePer.Text = lblUserName1.Text; lblUserID.Text = lblID1.Text; objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(lblID1.Text); ObjDataset = (DataSet)objBAL.GetScreens(); if (ObjDataset != null) { if (ObjDataset.Tables[0].Rows.Count > 0) { ViewState["Screens"] = ObjDataset.Tables[0]; ObjDataset1 = (DataSet)objBAL.GetUserPermissions(); if (ObjDataset1 != null) { ViewState["Permissions"] = ObjDataset1.Tables[0]; } GvPermissions.DataSource = ObjDataset.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } else { ViewState["Permissions"] = null; objBAL = new ClsBAL(); ObjDataset1 = (DataSet)objBAL.GetScreens(); if (ObjDataset1 != null) { GvPermissions.DataSource = ObjDataset1.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } else { ViewState["Permissions"] = null; objBAL = new ClsBAL(); ObjDataset1 = (DataSet)objBAL.GetScreens(); if (ObjDataset1 != null) { GvPermissions.DataSource = ObjDataset1.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Permissions", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } finally { if (ObjDataset != null) { ObjDataset = null; } if (ObjDataset1 != null) { ObjDataset1 = null; } if (ObjDatatable != null) { ObjDatatable = null; } if (ObjDataview != null) { ObjDataview = null; } } } }