Beispiel #1
0
        public static string getemailIDs(List <user> list, string menuID)
        {
            //if opt==1, then check the email privilege for the user for the menu item
            string emailIDs = "";

            try
            {
                if (list.Count != 0)
                {
                    foreach (user us in list)
                    {
                        string[]        userOptionArray;
                        MenuPrivilegeDB mpdb           = new MenuPrivilegeDB();
                        String          menuPrivString = mpdb.getUserMenuPrivilege(us.userID);
                        userOptionArray = menuPrivString.Split(';');
                        for (int i = 0; i < userOptionArray.Length; i++)
                        {
                            if (userOptionArray[i].StartsWith(menuID))
                            {
                                string[] privileges = userOptionArray[i].Split(',');
                                if (privileges[5] == "M")
                                {
                                    //find email id and add in to address
                                    string eid = EmployeeDB.getEmployeeEmailID(us.userEmpID);
                                    if (eid.Trim().Length > 0)
                                    {
                                        emailIDs = emailIDs + EmployeeDB.getEmployeeEmailID(us.userEmpID) + ";";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(emailIDs);
        }
Beispiel #2
0
        //04-04-2018
        public static DataGridView PrivilageListView(string docid)
        {
            DataGridView LV = new DataGridView();

            try
            {
                DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
                dataGridViewCellStyle1.Alignment          = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
                dataGridViewCellStyle1.BackColor          = System.Drawing.Color.LightSeaGreen;
                dataGridViewCellStyle1.Font               = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                dataGridViewCellStyle1.ForeColor          = System.Drawing.SystemColors.WindowText;
                dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
                dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
                dataGridViewCellStyle1.WrapMode           = System.Windows.Forms.DataGridViewTriState.True;
                LV.EnableHeadersVisualStyles              = false;
                LV.AllowUserToAddRows            = false;
                LV.AllowUserToDeleteRows         = false;
                LV.BackgroundColor               = System.Drawing.SystemColors.GradientActiveCaption;
                LV.BorderStyle                   = System.Windows.Forms.BorderStyle.None;
                LV.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                LV.EditMode            = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
                LV.ColumnHeadersHeight = 27;
                LV.RowHeadersVisible   = false;
                LV.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;

                DataGridViewTextBoxColumn colempid = new DataGridViewTextBoxColumn();
                colempid.Width      = 50;
                colempid.Name       = "EmployeeID";
                colempid.HeaderText = "Employee ID";
                colempid.ReadOnly   = false;
                LV.Columns.Add(colempid);

                DataGridViewTextBoxColumn colempname = new DataGridViewTextBoxColumn();
                colempname.Width      = 50;
                colempname.Name       = "EmployeeName";
                colempname.HeaderText = "Employee Name";
                colempname.ReadOnly   = false;
                LV.Columns.Add(colempname);

                DataGridViewCheckBoxColumn colview = new DataGridViewCheckBoxColumn();
                colview.Width      = 50;
                colview.Name       = "View";
                colview.HeaderText = "View";
                colview.ReadOnly   = false;
                LV.Columns.Add(colview);

                DataGridViewCheckBoxColumn colAdd = new DataGridViewCheckBoxColumn();
                colAdd.Width      = 50;
                colAdd.Name       = "Add";
                colAdd.HeaderText = "Add";
                colAdd.ReadOnly   = false;
                LV.Columns.Add(colAdd);

                DataGridViewCheckBoxColumn colEdit = new DataGridViewCheckBoxColumn();
                colEdit.Width      = 50;
                colEdit.Name       = "Edit";
                colEdit.HeaderText = "Edit";
                colEdit.ReadOnly   = false;
                LV.Columns.Add(colEdit);

                DataGridViewCheckBoxColumn colDel = new DataGridViewCheckBoxColumn();
                colDel.Width      = 50;
                colDel.Name       = "Delete";
                colDel.HeaderText = "Delete";
                colDel.ReadOnly   = false;
                LV.Columns.Add(colDel);

                DataGridViewCheckBoxColumn colMail = new DataGridViewCheckBoxColumn();
                colMail.Width      = 50;
                colMail.Name       = "Mail";
                colMail.HeaderText = "E-Mail";
                colMail.ReadOnly   = false;
                LV.Columns.Add(colMail);

                MenuPrivilegeDB          MPDB    = new MenuPrivilegeDB();
                List <usermenuprivilege> Allpriv = MPDB.getUserMenuPrivilegeforall();
                int i = 0;
                foreach (usermenuprivilege fordoc in Allpriv)
                {
                    LV.Rows.Add();
                    LV.Rows[i].Cells[0].Value = fordoc.EmpID.ToString();
                    LV.Rows[i].Cells[1].Value = fordoc.EmpName.ToString();
                    string mpString = fordoc.menuItemString;

                    string[] strArr = mpString.Split(';');
                    int      intex  = 0;
                    intex = Utilities.checkMenuPrivilege(docid, strArr);
                    if (intex >= 0)
                    {
                        string[] prvArr = strArr[intex].Split(',');
                        if (prvArr[1].Equals("V"))
                        {
                            LV.Rows[i].Cells[2].Value = true;
                        }
                        if (prvArr[2].Equals("A"))
                        {
                            LV.Rows[i].Cells[3].Value = true;
                        }
                        if (prvArr[3].Equals("E"))
                        {
                            LV.Rows[i].Cells[4].Value = true;
                        }
                        if (prvArr[4].Equals("D"))
                        {
                            LV.Rows[i].Cells[5].Value = true;
                        }
                        try
                        {
                            if (prvArr[5].Equals("M"))
                            {
                                LV.Rows[i].Cells[6].Value = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            LV.Rows[i].Cells[6].Value = false;
                        }
                    }
                    else
                    {
                        LV.Rows[i].Cells[2].Value = false;
                        LV.Rows[i].Cells[3].Value = false;
                        LV.Rows[i].Cells[4].Value = false;
                        LV.Rows[i].Cells[5].Value = false;
                        LV.Rows[i].Cells[6].Value = false;
                    }
                    i++;
                }
            }
            catch (Exception)
            {
            }
            return(LV);
        }