Example #1
0
 private void initVariables()
 {
     try
     {
         ComboFIll.fillStaticCombos();
         ////connString = Login.connString;
         ////userLoggedIn = Login.userLoggedIn;
         ////userLoggedInName = Login.userLoggedInName;
         ////empLoggedIn = Login.empLoggedIn;
         currentFY         = FinancialYearDB.getCurrentFinancialYear();
         documentDirectory = CatalogueValueDB.getParamValue("SysParam", "DocumentDirectory");
         showTime();
         lblEmployeeName.Text = Login.userLoggedInName;
         MenuPrivilegeDB mpDB     = new MenuPrivilegeDB();
         MenuItemDB      dbrecord = new MenuItemDB();
         menuhdritems = MenuItemDB.getMenuItemsHeader();
         foreach (menuitem menu in menuhdritems)
         {
             dictMainHeader.Add(menu.menugrp, 0);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Main() : Error 2");
     }
 }
Example #2
0
 private void createMainHeaderButtons()
 {
     try
     {
         MenuPrivilegeDB mpDB     = new MenuPrivilegeDB();
         MenuItemDB      dbrecord = new MenuItemDB();
         menuitems = dbrecord.getMenuItems();
         MenuPrivilegeDB mpdb = new MenuPrivilegeDB();
         menuPrivString  = mpdb.getUserMenuPrivilege(Login.userLoggedIn);
         userOptionArray = menuPrivString.Split(';');
         intex           = 0;
         removpnlcontrols();
         foreach (menuitem menu in menuhdritems)
         {
             int             count = 0;
             List <menuitem> mnm   = menuitems.Where(x => x.menugrp == menu.menugrp).ToList();
             foreach (menuitem menuin in mnm)
             {
                 if (Utilities.checkMenuPrivilege(menuin.menuItemID, userOptionArray) >= 0)
                 {
                     if (menuin.menuitemStatus == 1)
                     {
                         count++;
                     }
                 }
             }
             if (count > 0)
             {
                 val = 0;
                 addButtonheader(menu.menugrp, intex, menu.menugrp);
                 intex++;
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Main() : Error 3");
     }
 }
Example #3
0
        ////private void applyPrivilege()
        ////{
        ////    try
        ////    {

        ////    }
        ////    catch (Exception)
        ////    {
        ////    }
        ////}
        private void fillUserMenuPrivileges()
        {
            try
            {
                MenuPrivilegeDB mpdb     = new MenuPrivilegeDB();
                string          mpString = mpdb.getUserMenuPrivilege(userIDSelected);
                if (mpString.Length > 0)
                {
                    userPrivilegeExists = true;
                }
                string[] strArr = mpString.Split(';');
                int      intex  = 0;
                foreach (DataGridViewRow row in grdUserPrivileges.Rows)
                {
                    try
                    {
                        string docID = row.Cells[0].Value.ToString();
                        intex = Utilities.checkMenuPrivilege(docID, strArr);
                        if (intex >= 0)
                        {
                            string[] prvArr = strArr[intex].Split(',');
                            if (prvArr[1].Equals("V"))
                            {
                                row.Cells[2].Value = "true";
                            }
                            if (prvArr[2].Equals("A"))
                            {
                                row.Cells[3].Value = "true";
                            }
                            if (prvArr[3].Equals("E"))
                            {
                                row.Cells[4].Value = "true";
                            }
                            if (prvArr[4].Equals("D"))
                            {
                                row.Cells[5].Value = "true";
                            }
                            try
                            {
                                if (prvArr[5].Equals("M"))
                                {
                                    row.Cells[6].Value = "true";
                                }
                            }
                            catch (Exception ex)
                            {
                                row.Cells[6].Value = "false";
                            }
                            //DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[2];
                            //chk.Selected = true;
                        }
                        else
                        {
                            row.Cells[2].Value = "false";
                            row.Cells[3].Value = "false";
                            row.Cells[4].Value = "false";
                            row.Cells[5].Value = "false";
                            row.Cells[6].Value = "false";
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #4
0
        private void brnSave_Click(object sender, EventArgs e)
        {
            Boolean status = false;

            userMenuString = "";
            try
            {
                MenuPrivilegeDB   mpDB = new MenuPrivilegeDB();
                usermenuprivilege ump  = new usermenuprivilege();
                ump.userID = userIDSelected;
                foreach (DataGridViewRow row in grdUserPrivileges.Rows)
                {
                    ////if (Convert.ToBoolean(row.Cells[2].Value) == true)
                    {
                        userMenuString = userMenuString + row.Cells[0].Value.ToString();
                        if (Convert.ToBoolean(row.Cells[2].Value) == true)
                        {
                            userMenuString = userMenuString + ",V";
                        }
                        else
                        {
                            userMenuString = userMenuString + ",";
                        }

                        if (Convert.ToBoolean(row.Cells[3].Value) == true)
                        {
                            userMenuString = userMenuString + ",A";
                        }
                        else
                        {
                            userMenuString = userMenuString + ",";
                        }
                        if (Convert.ToBoolean(row.Cells[4].Value) == true)
                        {
                            userMenuString = userMenuString + ",E";
                        }
                        else
                        {
                            userMenuString = userMenuString + ",";
                        }
                        if (Convert.ToBoolean(row.Cells[5].Value) == true)
                        {
                            userMenuString = userMenuString + ",D";
                        }
                        else
                        {
                            userMenuString = userMenuString + ",";
                        }
                        if (Convert.ToBoolean(row.Cells[6].Value) == true)
                        {
                            userMenuString = userMenuString + ",M";
                        }
                        else
                        {
                            userMenuString = userMenuString + ",";
                        }
                        userMenuString = userMenuString + ";";
                    }
                }
                ump.menuItemString = userMenuString;
                if (userPrivilegeExists)
                {
                    //update
                    if (mpDB.updateUserMenuPrivilege(ump))
                    {
                        MessageBox.Show("User Menu Privileges updated");
                        status = true;
                    }
                    else
                    {
                        MessageBox.Show("Failed to update User Menu Privileges");
                        status = false;
                    }
                }
                else
                {
                    //add
                    mpDB.deleteUserMenuPrivilege(userIDSelected);

                    if (mpDB.insertUserMenuPrivilege(ump))
                    {
                        MessageBox.Show("User Menu Privileges Added");
                        status = true;
                    }
                    else
                    {
                        MessageBox.Show("Failed to Add User Menu Privileges");
                        status = false;
                    }
                }
                if (status)
                {
                    closegrdUserPrivileges();
                }
                enableBottomButtons();
            }
            catch (Exception)
            {
                MessageBox.Show("Error updating User Menu Privileges");
            }
        }
Example #5
0
        private void grdUserPrivileges_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                try
                {
                    string docid   = grdUserPrivileges.Rows[e.RowIndex].Cells[0].Value.ToString();
                    string docname = grdUserPrivileges.Rows[e.RowIndex].Cells[1].Value.ToString();
                    frmPopup = new Form();
                    frmPopup.StartPosition   = FormStartPosition.CenterScreen;
                    frmPopup.BackColor       = Color.CadetBlue;
                    frmPopup.MaximizeBox     = false;
                    frmPopup.MinimizeBox     = false;
                    frmPopup.ControlBox      = false;
                    frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle;
                    frmPopup.Size            = new Size(550, 320);

                    Label lblDoc = new Label();
                    lblDoc.BackColor = Color.CadetBlue;
                    lblDoc.Text      = docname;
                    lblDoc.Location  = new Point(5, 5);
                    frmPopup.Controls.Add(lblDoc);

                    grdMpList        = MenuPrivilegeDB.PrivilageListView(docid);
                    grdMpList.Bounds = new Rectangle(new Point(0, 30), new Size(550, 250));
                    grdMpList.Columns["EmployeeName"].Width = 180;
                    grdMpList.Columns["EmployeeID"].Width   = 100;
                    grdMpList.ReadOnly = true;
                    foreach (DataGridViewRow row in grdMpList.Rows)
                    {
                        row.Visible = false;
                        foreach (DataGridViewColumn col in grdMpList.Columns)
                        {
                            if (col.Name != "EmployeeID")
                            {
                                if (col.Name != "EmployeeName")
                                {
                                    bool isSelected = Convert.ToBoolean(row.Cells[col.Name].Value);
                                    if (isSelected)
                                    {
                                        row.Visible = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }


                    frmPopup.Controls.Add(grdMpList);



                    Button lvCancel = new Button();
                    lvCancel.BackColor = Color.Tan;
                    lvCancel.Text      = "CANCEL";
                    lvCancel.Location  = new Point(5, 290);
                    lvCancel.Click    += new System.EventHandler(this.lvCancel_Clicked);
                    frmPopup.Controls.Add(lvCancel);
                    frmPopup.ShowDialog();
                }
                catch (Exception ex)
                {
                }
            }
        }