public void Save(string userName, string url, bool allowAddNew, bool allowUpdate, bool allowDelete, bool allowRead) { bool isNew = false; var form = ctx.FormAccesses.SingleOrDefault(frm => frm.FormUrl == url && frm.UserName == userName); if (form == null) { form = new FormAccess(); isNew = true; } form.UserName = userName; form.FormUrl = url; form.CanAddNew = allowAddNew; form.CanDelete = allowDelete; form.CanRead = allowRead; form.CanUpdate = allowUpdate; if (isNew) { ctx.FormAccesses.InsertOnSubmit(form); } ctx.SubmitChanges(); }
public static void ApplyUserSecurity(this Page page, WebControl addNewButton, WebControl deleteButton, WebControl saveButton, WebControl grid) { FormAccessProvider formAccessProvider = UnityContainerHelper.Container.Resolve <FormAccessProvider>(); FormAccess formAccess = formAccessProvider.Get(page.User.Identity.Name, VirtualPathUtility.GetFileName(page.AppRelativeVirtualPath)); if (formAccess != null) { if (addNewButton != null) { addNewButton.Enabled = formAccess != null && formAccess.CanAddNew; } if (deleteButton != null) { deleteButton.Enabled = formAccess != null && formAccess.CanDelete; } if (saveButton != null) { saveButton.Enabled = formAccess != null && formAccess.CanUpdate; } if (grid != null) { grid.Enabled = formAccess != null && formAccess.CanRead; } } }
public ActionResult formQuery([DataSourceRequest] DataSourceRequest request) { DataTable dtForm = FormAccess.GetForm(); List <eForm> lstForm = bForm.listFormFromDatatable(dtForm); return(Json(lstForm.ToDataSourceResult(request))); }
public ActionResult Edit(int id) { FormAccess Frmacs = _FormAccessService.Get(id); FormAccessViewModel model = new FormAccessViewModel(); model.FormAccess = Frmacs; model.frms = new SelectList(_FormInfoService.GetAll(), "Id", "Name", Frmacs.FormIdFK); model.Rols = new SelectList(_RoleServices.GetAll(), "Id", "Name", Frmacs.RoleidFK); return(View(model)); }
public ActionResult createForm([DataSourceRequest] DataSourceRequest request, eForm _form) { FormEntity formEntity = new FormEntity(); formEntity.FormID = _form.FORM_CODE; formEntity.FormName = _form.FORM_NAME; formEntity.DictionaryID = ""; formEntity.CREATE_UID = "hieuht"; formEntity.FilePath = _form.FILE_PATH; formEntity.ModuleID = ""; bool result = FormAccess.InsertForm(formEntity); return(Json(new[] { _form }.ToDataSourceResult(request, ModelState))); }
private void UpdateEntity() { m_user.CODE = textBoxCode.Text.Trim(); m_user.NAME = textBoxName.Text.Trim(); m_user.PASSWORD = passwordKryptonTextBox.Text.Trim(); m_user.ACTIVE = activekryptonCheckBox.Checked; m_user.MODIFIED_BY = m_mainForm.CurrentUser.NAME; m_user.MODIFIED_COMPUTER_NAME = Environment.MachineName; m_user.EMPLOYEE = (Employee)employeekryptonComboBox1.SelectedItem; m_user.FORM_ACCESS_LIST.Clear(); for (int i = 0; i < formAccessKryptonDataGridView1.Rows.Count; i++) { if (formAccessKryptonDataGridView1[FormAccessCodeColumn.Index, i].Value == null) { continue; } FormAccess c = (FormAccess)formAccessKryptonDataGridView1.Rows[i].Tag; if (c == null) { c = new FormAccess(); } FormAccess x = (FormAccess)Utils.FindEntityInList(formAccessKryptonDataGridView1[FormAccessCodeColumn.Index, i].Value.ToString(), m_mainForm.GetFormAccessList()); c.CODE = x.CODE; c.NAME = x.NAME; c.SAVE = Convert.ToBoolean(formAccessKryptonDataGridView1[SaveColumn.Index, i].Value); c.DELETE = Convert.ToBoolean(formAccessKryptonDataGridView1[DeleteColumn.Index, i].Value); c.VIEW = Convert.ToBoolean(formAccessKryptonDataGridView1[ViewColumn.Index, i].Value); c.POST = Convert.ToBoolean(formAccessKryptonDataGridView1[ViewColumn.Index, i].Value); c.PRINT = Convert.ToBoolean(formAccessKryptonDataGridView1[ViewColumn.Index, i].Value); c.MODIFIED_BY = m_mainForm.CurrentUser.NAME; c.MODIFIED_COMPUTER_NAME = Environment.MachineName; c.USER = m_user; //foreach (FormAccess d in m_mainForm.GetFormAccessList()) //{ // if (d.CODE == c.CODE) // { // c.FORM_TYPE = d.FORM_TYPE; // break; // } //} if (!m_user.FORM_ACCESS_LIST.ContainsKey(c.CODE)) { m_user.FORM_ACCESS_LIST.Add(c.CODE, c); } } }
public void setEnableForm(bool enable) { textBoxCode.ReadOnly = !enable; textBoxName.ReadOnly = !enable; passwordKryptonTextBox.ReadOnly = !enable; FormAccessCodeColumn.ReadOnly = !enable; SaveColumn.ReadOnly = !enable; DeleteColumn.ReadOnly = !enable; ViewColumn.ReadOnly = !enable; PostColumn.ReadOnly = !enable; PrintColumn.ReadOnly = !enable; accessColumn.ReadOnly = !enable; employeekryptonComboBox1.Enabled = enable; formAccessKryptonDataGridView1.AllowUserToAddRows = enable; formAccessKryptonDataGridView1.AllowUserToDeleteRows = enable; for (int t = 0; t < formAccessKryptonDataGridView1.Rows.Count; t++) { if (formAccessKryptonDataGridView1[FormAccessCodeColumn.Index, t].Value == null) { continue; } FormAccess c = (FormAccess)formAccessKryptonDataGridView1.Rows[t].Tag; switch (c.FORM_TYPE) { case FormType.Master: formAccessKryptonDataGridView1[PostColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PostColumn.Index, t].ReadOnly = true; break; case FormType.Report: formAccessKryptonDataGridView1[PostColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PostColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[SaveColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[SaveColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[DeleteColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[DeleteColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[PrintColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PrintColumn.Index, t].ReadOnly = true; break; } } }
private void loadData() { try { m_user = r_userRep.getUser(m_user.CODE); m_user.EMPLOYEE = (Employee)r_empRep.GetById(m_user.EMPLOYEE); textBoxCode.Text = m_user.CODE; textBoxName.Text = m_user.NAME; passwordKryptonTextBox.Text = m_user.PASSWORD; activekryptonCheckBox.Checked = m_user.ACTIVE; employeekryptonComboBox1.Text = m_user.EMPLOYEE.ToString(); foreach (string kys in m_user.FORM_ACCESS_LIST.Keys) { FormAccess f = m_user.FORM_ACCESS_LIST[kys]; int t = formAccessKryptonDataGridView1.Rows.Add(f.NAME, true, f.SAVE, f.DELETE, f.VIEW, f.POST, f.PRINT); formAccessKryptonDataGridView1.Rows[t].Tag = f; switch (f.FORM_TYPE) { case FormType.Master: formAccessKryptonDataGridView1[PostColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PostColumn.Index, t].ReadOnly = true; break; case FormType.Report: formAccessKryptonDataGridView1[PostColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PostColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[SaveColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[SaveColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[DeleteColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[DeleteColumn.Index, t].ReadOnly = true; formAccessKryptonDataGridView1[PrintColumn.Index, t].Style.BackColor = System.Drawing.SystemColors.InactiveCaption; formAccessKryptonDataGridView1[PrintColumn.Index, t].ReadOnly = true; break; } } } catch (Exception x) { } }