Beispiel #1
0
 private void btnCuaSoChinh_Click(object sender, EventArgs e)
 {
     try
     {
         UCcuaSoChinh oUCcsc = new UCcuaSoChinh(mUsers, this);
         currentUC   = oUCcsc;
         oUCcsc.Dock = DockStyle.Fill;
         pnlMain.Controls.Clear();
         pnlMain.Controls.Add(oUCcsc);
         btnCuaSoChinhStatus.Visible      = true;
         btnQuanLyDonGiaStatus.Visible    = false;
         btnQuanLyNguoiDungStatus.Visible = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.WindowState == FormWindowState.Normal)
                {
                    this.WindowState    = FormWindowState.Maximized;
                    btnMaxximum.Visible = false;
                    btnRes.Visible      = true;
                }
                string       DisplayRole = string.Empty;
                frmLoginFlat oFrmLogin   = new frmLoginFlat(mUsers);
                oFrmLogin.ShowDialog();
                if (mUsers.ID == -1)
                {
                    Application.Exit();
                }
                mUR = new User_RoleLDM().GetElements(mUsers.ID);

                if (mUsers.isAdmin == 1)
                {
                    DisplayRole = "quản trị viên";
                }
                else
                if (mUsers.isAdmin == 2)
                {
                    DisplayRole = "nhân viên";
                }
                else
                {
                    DisplayRole = "khách hàng";
                }
                label1.Text = $"Xin chào {DisplayRole} {mUsers.DisplayName}";



                if (mUsers.isAdmin == 3) // khach hang
                {
                    UCquanLyTieuThu mUC = new UCquanLyTieuThu(mUsers, new KhachHangLDM().GetElementByUserID(mUsers.ID).ID, this);
                    currentUC = mUC;
                    mUC.Dock  = DockStyle.Fill;
                    pnlMain.Controls.Add(mUC);
                    btnCuaSoChinh.Enabled            = false;
                    btnCuaSoChinhStatus.Visible      = false;
                    btnQuanLyNguoiDung.Enabled       = false;
                    btnQuanLyNguoiDungStatus.Visible = false;
                    btnQuanLyDonGia.Enabled          = false;
                    btnQuanLyDonGiaStatus.Visible    = false;
                }
                else
                {
                    if (mUsers.isAdmin == 2)
                    {
                        if (mUR.Where(x => x.Role.RoleName == "Quản lý khách hàng").First().isView.Value)
                        {
                            UCcuaSoChinh oCuaSoChinh = new UCcuaSoChinh(mUsers, this);
                            currentUC        = oCuaSoChinh;
                            oCuaSoChinh.Dock = DockStyle.Fill;
                            pnlMain.Controls.Add(oCuaSoChinh);
                            btnCuaSoChinhStatus.Visible = true;
                        }
                        else
                        {
                            btnCuaSoChinh.Enabled       = false;
                            btnCuaSoChinhStatus.Visible = false;
                        }

                        if (mUR.Where(x => x.Role.RoleName == "Quản lý nhân viên").First().isView.Value == false)
                        {
                            btnQuanLyNguoiDung.Enabled       = false;
                            btnQuanLyNguoiDungStatus.Visible = false;
                        }

                        if (mUR.Where(x => x.Role.RoleName == "Quản lý đơn giá").First().isView.Value == false)
                        {
                            btnQuanLyDonGia.Enabled       = false;
                            btnQuanLyDonGiaStatus.Visible = false;
                        }
                    }
                    else
                    {
                        if (mUsers.isAdmin == 1)
                        {
                            UCcuaSoChinh oCuaSoChinh = new UCcuaSoChinh(mUsers, this);
                            currentUC        = oCuaSoChinh;
                            oCuaSoChinh.Dock = DockStyle.Fill;
                            pnlMain.Controls.Add(oCuaSoChinh);
                            btnCuaSoChinhStatus.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }