示例#1
0
        //đăng nhập
        private void button24_Click(object sender, EventArgs e)
        {
            nhanvienbus bus = new nhanvienbus();

            if (bus.dangnhap(lg.tendangnhap, lg.matkhau))
            {
                currentuser.user = lg.tendangnhap;
                manvdangnhap     = currentuser.user;
                tp.nvdangnhap    = currentuser.user;
                xk.nvdangnhap    = currentuser.user;

                if (bus.phanquyen(currentuser.user) == false)
                {
                    tabthongke.TabPages.Remove(tabdanhsachnv);
                    admin.phanquyen = false;
                }
                else
                {
                    admin.phanquyen = true;
                }

                tabthongke.SelectedTab = tabtrangchinh;
                pndangnhapuser.Visible = false;
                common.ClearOnlyTextBoxes(pndangnhapuser);
                tabthongke.Visible = true;
                lg.Visible         = false;
                chaolbl.Text       = "Chào bạn vào giao diện chính";
                idnvlbl.Text       = "ID nhân viên: " + manvdangnhap;
                tennvlbl.Text      = "Tên nhân viên: " + bus.getname(manvdangnhap);
            }
            else
            {
                MessageBox.Show("Sai ID hoặc mật khẩu");
            }
        }
        //nut cap nhap nhan vien
        private void button37_Click(object sender, EventArgs e)
        {
            NHANVIEN entity = new NHANVIEN();

            entity.MANV      = suatxtidnhanvien.Text;
            entity.TENNV     = suatxtten.Text;
            entity.MATKHAU   = suatxtmatkhau.Text;
            entity.NGAYSINH  = dateTimePicker6.Value.Date;
            entity.DIACHI    = suatxtdiachi.Text;
            entity.DIENTHOAI = suatxtsdt.Text;
            // entity.PHANQUYEN = suatxtphanquyen.Text;
            if (comboBox2.SelectedItem.Equals("Admin"))
            {
                entity.PHANQUYEN = true;
            }
            else if (comboBox2.SelectedItem.Equals("User"))
            {
                entity.PHANQUYEN = false;
            }
            nhanvienbus bus = new nhanvienbus();

            bool success = bus.update(entity);

            common.successorerror(success);
            if (success)
            {
                common.ClearTextBoxes(tabPage17);
                thanhviendgv.DataSource = bus.findall(textBox19.Text);
                thanhviendgv.Columns["NHANVIENs"].Visible = false;
            }
            else
            {
                ViewErrors(bus.validatedictionary);
            }
        }
示例#3
0
        //nút back tất cả mọi thứ
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            switch (tabthongke.SelectedIndex)
            {
            case 0:
            { }
            break;

            case 1:
            {
                if (tp.Visible == true)
                {
                    tp.hoantat();
                }
                HidePanels(tabquanlinhapkho);
                qlnhapkho.Visible = true;
            }
            break;

            case 2:
            {
                HidePanels(tabquanlixuatkho);
                qlxuatkho.Visible = true;
            }
            break;

            case 3:
            {
                HidePanels(tabdanhsachsp);
                danhsachsanpham.Visible = true;
            }
            break;

            case 4:
            {
                HidePanels(tabthongketimkiem);
                pnthongke.Visible = true;
            }
            break;

            case 5:
            {
                nhanvienbus bus = new nhanvienbus();
                if (bus.phanquyen(currentuser.user) == true)
                {
                    HidePanels(tabdanhsachnv);
                    pnnhanvien.Visible = true;
                }
            }
            break;
            }
        }
        private void textBox19_TextChanged(object sender, EventArgs e)
        {
            nhanvienbus bus = new nhanvienbus();

            thanhviendgv.DataSource = bus.findall(textBox19.Text);
            thanhviendgv.Columns["MANV"].HeaderText      = "Mã nhân viên";
            thanhviendgv.Columns["TENNV"].HeaderText     = "Tên nhân viên";
            thanhviendgv.Columns["DIACHI"].HeaderText    = "Địa chỉ";
            thanhviendgv.Columns["DIENTHOAI"].HeaderText = "Điện thoại";
            thanhviendgv.Columns["NGAYSINH"].HeaderText  = "Ngày sinh";
            thanhviendgv.Columns["NHANVIENs"].Visible    = false;
            thanhviendgv.Columns["MATKHAU"].Visible      = false;
            thanhviendgv.Columns["PHANQUYEN"].Visible    = false;
            thanhviendgv.Columns["XUATKHOes"].Visible    = false;
        }
        //thêm nhân viên
        private void button35_Click(object sender, EventArgs e)
        {
            NHANVIEN    entity = new NHANVIEN();
            nhanvienbus bus    = new nhanvienbus();

            entity.MANV      = textBox11.Text;
            entity.TENNV     = textBox16.Text;
            entity.DIACHI    = textBox17.Text;
            entity.DIENTHOAI = textBox18.Text;
            entity.NGAYSINH  = dateTimePicker5.Value.Date;
            entity.MATKHAU   = txtpass.Text;

            //   var item = this.comboBox1.GetItemText(this.comboBox1.FindStringExact("Admin"));
            // entity.PHANQUYEN = Convert.ToString(item);
            if (comboBox1.SelectedItem.Equals("Admin"))
            {
                entity.PHANQUYEN = true;
            }
            else if (comboBox1.SelectedItem.Equals("User"))
            {
                entity.PHANQUYEN = false;
            }

            if (txtpass.Text != txtrepass.Text)
            {
                MessageBox.Show("Mật khẩu không trùng khớp!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                bool success = bus.add(entity);
                if (success)
                {
                    common.successorerror(success);
                }
                else
                {
                    ViewErrors(bus.validatedictionary);
                }
            }
        }
        //xoa user
        private void button36_Click(object sender, EventArgs e)
        {
            NHANVIEN entity = new NHANVIEN();

            entity.MANV      = suatxtidnhanvien.Text;
            entity.TENNV     = suatxtten.Text;
            entity.MATKHAU   = suatxtmatkhau.Text;
            entity.DIACHI    = suatxtdiachi.Text;
            entity.DIENTHOAI = suatxtsdt.Text;


            nhanvienbus bus = new nhanvienbus();

            bool success = bus.delete(entity);

            common.successorerror(success);
            if (success)
            {
                common.ClearTextBoxes(tabPage17);
                thanhviendgv.DataSource = bus.findall(textBox19.Text);
                thanhviendgv.Columns["NHANVIENs"].Visible = false;
            }
        }