protected void Page_Load(object sender, EventArgs e) { aProviders = new PageControlsProvider(); if (IsPostBack) { var eventTarget = Request["__EVENTTARGET"].IsNullOrEmpty() ? String.Empty : Request["__EVENTTARGET"]; string roleCode = Request["__EVENTARGUMENT"]; //hfRoleCode.Value = roleCode; if (eventTarget == "Search" && roleCode != null) { aProviders = new PageControlsProvider(); GridView1.DataSource = null; aTable = aProviders.GetAllbyRoleCode(roleCode); if (aTable.Rows.Count > 0) { GridView1.DataSource = aTable; GridView1.DataBind(); Session["pageControlsTable"] = aTable; btnSubmit.Text = "Update"; } else { //this.AlertWarning(lblMsg, MessageConstants.DataNotFind); MessageHelper.ShowAlertMessage(MessageConstants.DataNotFind); GridView1.DataSource = null; GridView1.DataBind(); btnSubmit.Text = "Submit"; } ddlMenuType.SelectedValue = "0"; } } else { PopulateddlMenuType(); GridView1.DataSource = null; Session["pageControlsTable"] = string.Empty; aTable = aProviders.GetAllPageControls(); GridView1.DataSource = aTable; GridView1.DataBind(); Session["pageControlsTable"] = aTable; } }
private void GetwithCaption() { try { aTable = new DataTable(); DataTable aTableObj = (DataTable)(HttpContext.Current.Session["pageControlsTable"]); foreach (GridViewRow aRow in GridView1.Rows) { aProviders = new PageControlsProvider { CanSelect = ((CheckBox)aRow.FindControl("chkSelect")).Checked, CanInsert = ((CheckBox)aRow.FindControl("chkAdd")).Checked, CanUpdate = ((CheckBox)aRow.FindControl("chkEdit")).Checked, CanDelete = ((CheckBox)aRow.FindControl("chkDelate")).Checked, CanSend = ((CheckBox)aRow.FindControl("chkSend")).Checked, CanCheck = ((CheckBox)aRow.FindControl("chkCheck")).Checked, CanApprove = ((CheckBox)aRow.FindControl("chkApprove")).Checked, CanPreview = ((CheckBox)aRow.FindControl("chkPreview")).Checked, CanReceive = ((CheckBox)aRow.FindControl("chkReceive")).Checked, MenuId = aRow.Cells[0].Text }; foreach (DataRow aRowobj in aTableObj.Rows.Cast <DataRow>().Where(aRowobj => aRowobj[0].ToString() == aProviders.MenuId)) { aRowobj[3] = aProviders.CanSelect; aRowobj[4] = aProviders.CanInsert; aRowobj[5] = aProviders.CanUpdate; aRowobj[6] = aProviders.CanDelete; aRowobj[7] = aProviders.CanSend; aRowobj[8] = aProviders.CanCheck; aRowobj[9] = aProviders.CanApprove; aRowobj[10] = aProviders.CanPreview; aRowobj[11] = aProviders.CanReceive; } } HttpContext.Current.Session["pageControlsTable"] = aTableObj; } catch { throw; } }
private SqlCommand ProcedureFunction(PageControlsProvider aRow) { command = new SqlCommand(); ConnectionOpen(); command.Connection = Connection; BeginTransaction(true); command.Transaction = Transaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = StoredProcedureNames.UserPageControlsSet; command.Parameters.Add("@Ser", SqlDbType.Int).Value = 0; command.Parameters.Add("@MenuID", SqlDbType.Int).Value = aRow.MenuId; command.Parameters.Add("@RoleCode", SqlDbType.Int).Value = aRow.RoleCode; command.Parameters.Add("@CanSelect", SqlDbType.Bit).Value = aRow.CanSelect; command.Parameters.Add("@CanInsert", SqlDbType.Bit).Value = aRow.CanInsert; command.Parameters.Add("@CanUpdate", SqlDbType.Bit).Value = aRow.CanUpdate; command.Parameters.Add("@CanDelete", SqlDbType.Bit).Value = aRow.CanDelete; command.Parameters.Add("@CanPreview", SqlDbType.Bit).Value = aRow.CanPreview; command.Parameters.Add("@CanReceive", SqlDbType.Bit).Value = aRow.CanReceive; command.Parameters.Add("@AllChk", SqlDbType.Bit).Value = aRow.AllChk; return(command); }
private List <PageControlsProvider> PageControlsProviders() { List <PageControlsProvider> roleDetailList = new List <PageControlsProvider>(); //bool isSelected = false; try { #region by pre dev var alist = new List <PageControlsProvider>(); GetwithCaption(); DataTable aTable = (DataTable)(Session["pageControlsTable"]); foreach (DataRow aRow in aTable.Rows) { aProviders = new PageControlsProvider { CanSelect = Convert.ToBoolean(aRow[3].ToString()), CanInsert = Convert.ToBoolean(aRow[4].ToString()), CanUpdate = Convert.ToBoolean(aRow[5].ToString()), CanDelete = Convert.ToBoolean(aRow[6].ToString()), CanSend = Convert.ToBoolean(aRow[7].ToString()), CanCheck = Convert.ToBoolean(aRow[8].ToString()), CanApprove = Convert.ToBoolean(aRow[9].ToString()), CanPreview = Convert.ToBoolean(aRow[10].ToString()), CanReceive = Convert.ToBoolean(aRow[11].ToString()), //AllChk = Convert.ToBoolean(aRow[8].ToString()), MenuId = aRow[0].ToString() }; alist.Add(aProviders); } return(alist); #endregion } catch { throw; } //return roleDetailList; }