public void PrivilegeAdd(PrivilegeInfo privilegeinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PrivilegeAdd", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam6 = new SqlParameter(); sprmparam6 = sccmd.Parameters.Add("@formName", SqlDbType.VarChar); sprmparam6.Value = privilegeinfo.FormName; sprmparam6 = sccmd.Parameters.Add("@action", SqlDbType.VarChar); sprmparam6.Value = privilegeinfo.Action; sprmparam6 = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal); sprmparam6.Value = privilegeinfo.RoleId; sprmparam6 = sccmd.Parameters.Add("@exatra1", SqlDbType.VarChar); sprmparam6.Value = privilegeinfo.Extra1; sprmparam6 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam6.Value = privilegeinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
public PrivilegeInfo PrivilegeView(decimal decRoleId) { PrivilegeInfo privilegeinfo = new PrivilegeInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PrivilegeView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal); sprmparam2.Value = decRoleId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { privilegeinfo.PrivilegeId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString()); privilegeinfo.FormName = ((DbDataReader)sdrreader)[1].ToString(); privilegeinfo.Action = ((DbDataReader)sdrreader)[2].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(privilegeinfo); }
public int Insert(PrivilegeInfo oParam) { string sql = @"INSERT INTO Sys_Privilege ( SysNo, PrivilegeID, PrivilegeName, Status ) VALUES ( @SysNo, @PrivilegeID, @PrivilegeName, @Status )"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramPrivilegeID = new SqlParameter("@PrivilegeID", SqlDbType.NVarChar, 20); SqlParameter paramPrivilegeName = new SqlParameter("@PrivilegeName", SqlDbType.NVarChar, 50); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4); if (oParam.SysNo != AppConst.IntNull) { paramSysNo.Value = oParam.SysNo; } else { paramSysNo.Value = System.DBNull.Value; } if (oParam.PrivilegeID != AppConst.StringNull) { paramPrivilegeID.Value = oParam.PrivilegeID; } else { paramPrivilegeID.Value = System.DBNull.Value; } if (oParam.PrivilegeName != AppConst.StringNull) { paramPrivilegeName.Value = oParam.PrivilegeName; } else { paramPrivilegeName.Value = System.DBNull.Value; } if (oParam.Status != AppConst.IntNull) { paramStatus.Value = oParam.Status; } else { paramStatus.Value = System.DBNull.Value; } cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramPrivilegeID); cmd.Parameters.Add(paramPrivilegeName); cmd.Parameters.Add(paramStatus); return(SqlHelper.ExecuteNonQuery(cmd)); }
public static uint GetTopInFreeNum(uint balance) { if (NowPrivilege == null) { NowPrivilege = DataService.GetPriInfo(); } uint FreeNum = (balance - (balance % NowPrivilege.BuyN)) / NowPrivilege.BuyN * NowPrivilege.FreeN; return(FreeNum); }
/// <summary> /// Function to insert values to Privilege Table /// </summary> /// <param name="privilegeinfo"></param> public void PrivilegeAdd(PrivilegeInfo privilegeinfo) { try { PrivilegeSP spPrivilege = new PrivilegeSP(); spPrivilege.PrivilegeAdd(privilegeinfo); } catch (Exception ex) { MessageBox.Show("PRV4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void GetChild(PrivilegeInfo current, List <PrivilegeInfo> all) { var children = all.Where(p => p.ParentSysNo == current.SysNo).ToList(); foreach (var item in children) { if (current.Children == null) { current.Children = new List <Entity.ControlPannel.PrivilegeInfo>(); } current.Children.Add(item); GetChild(item, all); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { PrivilegeInfo infoPrivilege = new PrivilegeInfo(); PrivilegeBll BllPrivilege = new PrivilegeBll(); infoPrivilege.RoleId = Convert.ToDecimal(cmbRole.SelectedValue); infoPrivilege.Extra1 = string.Empty; infoPrivilege.Extra2 = string.Empty; foreach (Control tabPage in tcPrivillage.Controls) { string strTabPage = tabPage.Text; if (strTabPage == "Company") { infoPrivilege.FormName = "frm" + strTabPage +"Creation"; foreach (Control cbxCompany in tabPage.Controls) { if (cbxCompany is CheckBox) { CheckBox cbx = (CheckBox)cbxCompany; if (cbx.Checked == true) { string strCbx = cbx.Text.Replace(" ",string.Empty); if (strCbx == "Edit") { infoPrivilege.Action = "Update"; } else { infoPrivilege.Action = strCbx; } BllPrivilege.PrivilegeAdd(infoPrivilege); } } } } else { foreach (Control gbxControl in tabPage.Controls) { if (gbxControl is GroupBox) { string strFormName = gbxControl.Text.Replace(" ", string.Empty); foreach (Control cbxControl in gbxControl.Controls) { CheckBox cbx = (CheckBox)cbxControl; if (cbx.Checked == true) { string strCbx = cbx.Text.Replace(" ", string.Empty); if (gbxControl.Text == "Transactions" || gbxControl.Text == "Payroll") { infoPrivilege.FormName = "frm" + strCbx; infoPrivilege.Action = "View"; BllPrivilege.PrivilegeAdd(infoPrivilege); } /*------------------------------------*/ else { if (strCbx != "All" && strCbx != "Register") { if (gbxControl.Text == "Price List" || gbxControl.Text == "Standerd Rate") { infoPrivilege.FormName = "frm" + strFormName + "Popup"; if (strCbx == "Add") { infoPrivilege.Action = "Save"; } else if (strCbx == "Edit") { infoPrivilege.Action = "Update"; } else if (strCbx == "Delete") { infoPrivilege.Action = "Delete"; } BllPrivilege.PrivilegeAdd(infoPrivilege); } else { infoPrivilege.FormName = "frm" + strFormName; if (strCbx == "Add") { infoPrivilege.Action = "Save"; } else if (strCbx == "Edit") { infoPrivilege.Action = "Update"; } else if (strCbx == "Delete") { infoPrivilege.Action = "Delete"; } else if (strCbx == "View") { infoPrivilege.Action = "View"; } BllPrivilege.PrivilegeAdd(infoPrivilege); } } else if (strCbx == "Register") { string strFormNameCreationRemove = "frm" + strFormName.Replace("Creation", string.Empty) + "Register"; string strFormNameVoucherRemove = "frm" + strFormName.Replace("Voucher", string.Empty) + "Register"; infoPrivilege.FormName = strFormNameCreationRemove; infoPrivilege.Action = "View"; BllPrivilege.PrivilegeAdd(infoPrivilege); } } } } } else { if (gbxControl is CheckBox) { CheckBox cbx = (CheckBox)gbxControl; if (cbx.Checked == true) { string strFormName = "frm" + gbxControl.Text.Replace(" ", string.Empty); infoPrivilege.FormName = strFormName; infoPrivilege.Action = "View"; BllPrivilege.PrivilegeAdd(infoPrivilege); } } } } } } AllTabpageClear(); } catch (Exception ex) { MessageBox.Show("RLPRST:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Delete an items /// </summary> public void DeleteFunction() { try { PrivilegeInfo infoPrivilege = new PrivilegeInfo(); PrivilegeBll BllPrivilege = new PrivilegeBll(); decimal decRoleId = Convert.ToDecimal(cmbRole.SelectedValue); BllPrivilege.PrivilegeDeleteTabel(decRoleId); } catch (Exception ex) { MessageBox.Show("RLPRST:8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void SetModuleSubjects() { int moduleid = WebUtility.GetIntegerParameter("moduleid", -1); string data = WebUtility.GetStringParameter("data", string.Empty); Subject[] al = null; try { //al = (Subject[])WebUtility.DeserializeAjaxResult(data, typeof(Subject[])); try { al = (Subject[])WebUtility.DeserializeAjaxResult(data, typeof(Subject[])); } catch (Exception ex) { al = new Subject[] { (Subject)WebUtility.DeserializeAjaxResult(data, typeof(Subject)) }; } al = al == null ? new Subject[0] : al; } catch (Exception E) { WebUtility.WriteAjaxError("err_deserialize_json", E); return; } IList il = new ArrayList(); if (al != null) { for (int i = 0; i < al.Length; i++) { PrivilegeInfo pv = new PrivilegeInfo(); pv.Subject = al[i]; pv.Operations = 3; il.Add(pv); } } try { ipp.SetByResource(moduleid, il, new ModuleOperationAttributes(), false); WebUtility.WriteAjaxResult(true, "m55", null); } catch (Exception E) { WebUtility.WriteAjaxError("err_file_io", E); } }