Пример #1
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //bmp = new Bitmap(width + 1, height + 1);
            //cx = width / 2;
            //cy = height / 2;
            //this.BackColor = Color.White;
            //t.Interval = 1000;
            //t.Tick += new EventHandler(this.t_Tick);
            //t.Start();


            using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
            {
                Nhanvien nv = quanli.Nhanviens.FirstOrDefault(p => p.MaNV == manv);
                if (nv != null)
                {
                    if (nv.Chucvu.ToString().Equals("Nhanvien"))
                    {
                        btnchuyenbay.Enabled = false;
                        GunaButton4.Enabled  = false;
                        btnnhanvien.Enabled  = false;
                        btnsanbay.Enabled    = false;
                        btnthongke.Enabled   = false;
                    }
                }
            }
            loadform(new Form13());
            timer5.Start();
        }
Пример #2
0
        private void gunaButton6_Click(object sender, EventArgs e)
        {
            {
                if (!kiemtra())
                {
                    return;
                }
                using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
                {
                    string manv       = quanli.Nhanviens.Max(p => p.MaNV);
                    string ma         = manv.Substring(2, manv.Length - 2);
                    int    manhanvien = int.Parse(ma) + 1;
                    if (manhanvien <= 9)
                    {
                        manv = "NV0" + manhanvien;
                    }
                    else
                    {
                        manv = "NV" + manhanvien;
                    }
                    Nhanvien nv = new Nhanvien();
                    nv.MaNV   = manv;
                    nv.Hoten  = txtten.Text;
                    nv.SĐT    = txtsdt.Text;
                    nv.Diachi = txtdiachi.Text;
                    nv.CMND   = int.Parse(txtcmnd.Text);
                    quanli.Nhanviens.Add(nv);
                    quanli.SaveChanges();

                    Form9_Load(sender, e);
                }
            }
        }
Пример #3
0
        private void gunaButton4_Click(object sender, EventArgs e)
        {
            {
                if (manv == "")
                {
                    MessageBox.Show("Hãy chọn nhân viên cần sửa!");
                    return;
                }
                using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
                {
                    Nhanvien nv = quanli.Nhanviens.FirstOrDefault(p => p.MaNV == manv);

                    nv.Hoten  = txtten.Text;
                    nv.SĐT    = txtsdt.Text;
                    nv.Diachi = txtdiachi.Text;
                    nv.CMND   = int.Parse(txtcmnd.Text);
                    quanli.SaveChanges();
                    MessageBox.Show("Sua thanh cong!");
                    Form9_Load(sender, e);
                }
            }
        }
Пример #4
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            if (temp)
            {
                {
                    if (!kiemtra())
                    {
                        return;
                    }
                    using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
                    {
                        string manv       = quanli.Nhanviens.Max(p => p.MaNV);
                        string ma         = manv.Substring(2, manv.Length - 2);
                        int    manhanvien = int.Parse(ma) + 1;
                        if (manhanvien <= 9)
                        {
                            manv = "NV0" + manhanvien;
                        }
                        else
                        {
                            manv = "NV" + manhanvien;
                        }
                        Nhanvien nv = new Nhanvien();
                        nv.MaNV   = manv;
                        nv.Hoten  = txtten.Text;
                        nv.SĐT    = txtsdt.Text;
                        nv.Diachi = txtdiachi.Text;
                        nv.CMND   = int.Parse(txtcmnd.Text);
                        quanli.Nhanviens.Add(nv);
                        quanli.SaveChanges();

                        Form9_Load(sender, e);
                        btnthem.Enabled    = true;
                        dtnhanvien.Enabled = true;
                        clearData();
                    }
                }
            }
            {
                if (manv == "")
                {
                    MessageBox.Show("Hãy chọn nhân viên cần sửa!");
                    return;
                }
                using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
                {
                    Nhanvien nv = quanli.Nhanviens.FirstOrDefault(p => p.MaNV == manv);

                    nv.Hoten  = txtten.Text;
                    nv.SĐT    = txtsdt.Text;
                    nv.Diachi = txtdiachi.Text;
                    nv.CMND   = int.Parse(txtcmnd.Text);
                    nv.Chucvu = txtchucvu.Text;
                    quanli.SaveChanges();
                    MessageBox.Show("Sua thanh cong!");
                    Form9_Load(sender, e);
                    btnthem.Enabled    = true;
                    dtnhanvien.Enabled = true;
                    clearData();
                }
            }
        }