Ejemplo n.º 1
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("ต้องการเพิ่มสิทธิ์!", "เพิ่ม", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (DataClasses1DataContext db = new DataClasses1DataContext())
                    {
                        foreach (GridViewRowInfo rd in radGridView1.Rows)
                        {
                            if (rd.IsSelected)
                            {
                                tb_UserPermission pm = new tb_UserPermission();
                                pm.LayoutName = rd.Cells["dgvLayout"].Value.ToString();
                                pm.ScreenName = rd.Cells["dgvTextNode"].Value.ToString();
                                pm.UserID     = cboUserSelect1.Text.Trim();
                                db.tb_UserPermissions.InsertOnSubmit(pm);
                                db.SubmitChanges();
                            }
                        }
                        dbClss.AddHistory(this.Name, "เพิ่มสิทธ์", "ทำการเพิ่มสิทธ์  [" + cboUserSelect1.Text + "] เข้าระบบ", "จากเครื่อง " + System.Environment.MachineName);

                        DataLoad2(cboUserSelect1.Text);
                        DataLoad(cboUserSelect1.Text);
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Ejemplo n.º 2
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("ต้องการ ลบ สิทธิ์!", "ลบ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (DataClasses1DataContext db = new DataClasses1DataContext())
                    {
                        //string TextName = "";
                        //string Layout = "";
                        foreach (GridViewRowInfo rd in radGridView2.Rows)
                        {
                            if (rd.IsSelected)
                            {
                                tb_UserPermission pm = db.tb_UserPermissions.Where(p => p.UserID == cboUserSelect1.Text &&
                                                                                   p.ScreenName == rd.Cells["dgvTextNode"].Value.ToString() &&
                                                                                   p.LayoutName == rd.Cells["dgvLayout"].Value.ToString()).FirstOrDefault();
                                if (pm != null)
                                {
                                    db.tb_UserPermissions.DeleteOnSubmit(pm);
                                    db.SubmitChanges();
                                }
                            }
                        }

                        dbClss.AddHistory(this.Name, "ลบ สิทธิ์!", "ทำการลบ สิทธิ์!  [" + cboUserSelect1.Text + "] ในระบบ", "จากเครื่อง " + System.Environment.MachineName);
                        DataLoad2(cboUserSelect1.Text);
                        DataLoad(cboUserSelect1.Text);
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Ejemplo n.º 3
0
        public static bool PermissionScreen(string ScreenName)
        {
            bool ck = false;

            try
            {
                using (DataClasses1DataContext db = new DataClasses1DataContext())
                {
                    OpenForm op = db.OpenForms.Where(o => o.LinkNode == ScreenName).FirstOrDefault();
                    if (op != null)
                    {
                        tb_UserPermission up = db.tb_UserPermissions.Where(u => u.ScreenName == op.TextNode && u.UserID == dbClss.UserID).FirstOrDefault();
                        if (up != null)
                        {
                            ck = true;
                        }
                    }
                    //TextNode
                }
            }
            catch { }


            return(ck);
        }
Ejemplo n.º 4
0
        private void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("ต้องการ copy สิทธิ์!", "copy", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (!cboUserSelect2.Text.Equals("") && !cboUserSelect2.Text.Equals(cboUserSelect1.Text))
                    {
                        using (DataClasses1DataContext db = new DataClasses1DataContext())
                        {
                            var de = db.tb_UserPermissions.Where(p => p.UserID == cboUserSelect1.Text).ToList();
                            foreach (var rd in de)
                            {
                                tb_UserPermission ps = db.tb_UserPermissions.Where(p1 => p1.UserID == rd.UserID && p1.ScreenName == rd.ScreenName && p1.LayoutName == rd.LayoutName).FirstOrDefault();
                                if (ps != null)
                                {
                                    db.tb_UserPermissions.DeleteOnSubmit(ps);
                                    db.SubmitChanges();
                                }
                            }

                            var copy = db.tb_UserPermissions.Where(p => p.UserID == cboUserSelect2.Text).ToList();
                            foreach (var rd in copy)
                            {
                                tb_UserPermission ps = new tb_UserPermission();
                                ps.UserID     = cboUserSelect1.Text;
                                ps.ScreenName = rd.ScreenName;
                                ps.LayoutName = rd.LayoutName;
                                db.tb_UserPermissions.InsertOnSubmit(ps);
                                db.SubmitChanges();
                            }
                        }
                        dbClss.AddHistory(this.Name, "copy สิทธิ์!", "copy Screen  [" + cboUserSelect1.Text + "] ในระบบ", "จากเครื่อง " + System.Environment.MachineName);

                        DataLoad2(cboUserSelect1.Text);
                        DataLoad(cboUserSelect1.Text);
                    }
                    else
                    {
                        MessageBox.Show("เลือกข้อมูลไม่ถูกต้อง !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }