/// <summary> /// Mothod which Retrives the Permissions for the Currnt SmartPart /// </summary> /// <param name="formId">SmartPart Id to get permissions</param> /// <returns>PermissionFilds Struc</returns> public PermissionFields GetFormPermissions(int formId) { SupportFormData.GetFormDetailsDataTable permissionDataTable = new SupportFormData.GetFormDetailsDataTable(); if (TerraScanCommon.SupportFormUserId != -1) { permissionDataTable = TerraScanCommon.GetFormPermissionDetails(formId, TerraScanCommon.SupportFormUserId); } else { permissionDataTable = TerraScanCommon.GetFormPermissionDetails(formId, TerraScanCommon.UserId); } if (permissionDataTable.Rows.Count > 0) { this.permissionFields.openPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionOpen"]); this.permissionFields.newPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionAdd"]); this.permissionFields.editPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionEdit"]); this.permissionFields.deletePermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionDelete"]); } ////string stringExp = "Form =" + formId; ////DataRow[] permissionSet; ////if (TerraScanCommon.formPermissionsDataSet != null) ////{ //// permissionSet = TerraScanCommon.formPermissionsDataSet.Tables[0].Select(stringExp); //// if (permissionSet.Length > 0) //// { //// this.permissionFields.openPermission = Convert.ToBoolean((int)permissionSet[0]["IsPermissionOpen"]); //// this.permissionFields.newPermission = Convert.ToBoolean((int)permissionSet[0]["IsPermissionAdd"]); //// this.permissionFields.editPermission = Convert.ToBoolean((int)permissionSet[0]["IsPermissionEdit"]); //// this.permissionFields.deletePermission = Convert.ToBoolean((int)permissionSet[0]["IsPermissionDelete"]); //// } ////} return(this.permissionFields); }
/// <summary> /// Method to Get The Form Permissions for each User from database /// </summary> /// <param name="currentForm">Current Form</param> private void GetFormPermissions(Form currentForm) { //// Code Added for Immediate Permissions Effect when Changes Made int formId = 0; if (currentForm != null) { ////formId = currentForm.Tag.ToString(); if (this.parentFormId != 0) { formId = this.parentFormId; } else if (currentForm.Tag != null) { int.TryParse(currentForm.Tag.ToString(), out formId); } else { formId = 0; } } SupportFormData.GetFormDetailsDataTable permissionDataTable = new SupportFormData.GetFormDetailsDataTable(); permissionDataTable = TerraScanCommon.GetFormPermissionDetails(formId, TerraScanCommon.UserId); if (permissionDataTable.Rows.Count > 0) { this.formPermissionFields.openPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionOpen"]); this.formPermissionFields.newPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionAdd"]); this.formPermissionFields.editPermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionEdit"]); this.permissionEdit = this.formPermissionFields.editPermission; this.formPermissionFields.deletePermission = Convert.ToBoolean(permissionDataTable.Rows[0]["IsPermissionDelete"]); this.SetFormPermissions(currentForm, this.formPermissionFields.openPermission, this.formPermissionFields.newPermission, this.formPermissionFields.deletePermission); } //// End #region Commented the Code Existing Permissions Handling /* * FormPermissions = TerraScanCommon.FormPermissionsDataSet; * * string formId = String.Empty; * if (currentForm != null) * { * ////formId = currentForm.Tag.ToString(); * formId = this.parentFormId.ToString(); * } * * int permissionOpen, permissionAdd, permissionDelete; * string stringExp = "Form =" + formId.Trim(); * DataRow[] permissionSet; * if (formPermissions != null) * { * permissionSet = formPermissions.Tables[0].Select(stringExp); * if (permissionSet.Length > 0) * { * permissionOpen = (int)permissionSet[0]["IsPermissionOpen"]; * permissionAdd = (int)permissionSet[0]["IsPermissionAdd"]; * this.permissionEdit = (int)permissionSet[0]["IsPermissionEdit"]; * permissionDelete = (int)permissionSet[0]["IsPermissionDelete"]; * * //// Added Code to Store the Permission Details in the Struct * this.formPermissionFields.openPermission = Convert.ToBoolean(permissionSet[0]["IsPermissionOpen"]); * this.formPermissionFields.newPermission = Convert.ToBoolean(permissionSet[0]["IsPermissionAdd"]); * this.formPermissionFields.editPermission = Convert.ToBoolean(permissionSet[0]["IsPermissionEdit"]); * this.formPermissionFields.deletePermission = Convert.ToBoolean(permissionSet[0]["IsPermissionDelete"]); * * this.SetFormPermissions(currentForm, permissionOpen, permissionAdd, permissionDelete); * } * } */ #endregion }