コード例 #1
0
        private void btn_handle_Click(object sender, EventArgs e)
        {
            List <String> listError = new List <String>();

            if (txt_diachi.Text == "" || txt_email.Text == "" || txt_hoten.Text == "" || txt_pass.Text == "" || txt_sodt.Text == "")
            {
                listError.Add("Trường không được rỗng");
            }
            if (listError.Count == 0)
            {
                bool rs = this.NhanVien == null?NhanVien_BUL.Them(txt_email.Text, txt_hoten.Text, txt_sodt.Text, txt_diachi.Text, txt_pass.Text, comb_chucvu.SelectedItem.ToString()) : NhanVien_BUL.ChinhSua(this.NhanVien.ID, txt_email.Text, txt_hoten.Text, txt_sodt.Text, txt_diachi.Text, txt_pass.Text, comb_chucvu.SelectedItem.ToString());

                if (rs == true)
                {
                    MessageSucess();
                }
                else
                {
                    MesageFaild();
                }
            }
            else
            {
                MessageValidate(listError);
            }
        }
コード例 #2
0
 private void IntoDataTodtgv()
 {
     if (comb_danhmuc.SelectedIndex == 0)
     {
         dtgv.DataSource = LoaiHang_BUL.getDataTable(txt_search.Text);
     }
     else if (comb_danhmuc.SelectedIndex == 1)
     {
         dtgv.DataSource = HangHoa_BUL.getDataTable(txt_search.Text);
     }
     else if (comb_danhmuc.SelectedIndex == 2)
     {
         dtgv.DataSource = KhachHang_BUL.getDataTable(txt_search.Text);
     }
     else if (comb_danhmuc.SelectedIndex == 3)
     {
         dtgv.DataSource = NhaCungCap_BUL.getDataTable(txt_search.Text);
     }
     else if (comb_danhmuc.SelectedIndex == 4)
     {
         dtgv.DataSource = NhanVien_BUL.getDataTable(txt_search.Text);
     }
     else if (comb_danhmuc.SelectedIndex == 5)
     {
         dtgv.DataSource = DoiTacQuangCao_BUL.getDataTable(txt_search.Text);
     }
 }
コード例 #3
0
        private void btn_sua_Click(object sender, EventArgs e)
        {
            Form fr_lh = null;

            if (comb_danhmuc.SelectedIndex == 0)
            {
                int       pos = dtgv.CurrentRow.Index;
                int       ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                LoaiHoang lh  = LoaiHang_BUL.TimLoaiHang(ID);
                fr_lh = new fr_QuanLy_LoaiHang(lh);
            }
            else if (comb_danhmuc.SelectedIndex == 1)
            {
                int     pos = dtgv.CurrentRow.Index;
                int     ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                HangHoa hh  = HangHoa_BUL.TimLoaiHang(ID);
                fr_lh = new fr_QuanLy_HangHoa(hh);
            }
            else if (comb_danhmuc.SelectedIndex == 2)
            {
                int       pos = dtgv.CurrentRow.Index;
                int       ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                KhachHang hh  = KhachHang_BUL.TimKhachHang(ID);
                fr_lh = new fr_QuanLy_KhachHang(hh);
            }
            else if (comb_danhmuc.SelectedIndex == 3)
            {
                int        pos = dtgv.CurrentRow.Index;
                int        ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                NhaCungCap hh  = NhaCungCap_BUL.TimNCC(ID);
                fr_lh = new fr_QuanLy_NhaCungCap(hh);
            }
            else if (comb_danhmuc.SelectedIndex == 4)
            {
                int      pos = dtgv.CurrentRow.Index;
                int      ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                NhanVien hh  = NhanVien_BUL.TimNhanVien(ID);
                fr_lh = new fr_QuanLy_NhanVien(hh);
            }
            else if (comb_danhmuc.SelectedIndex == 5)
            {
                int            pos = dtgv.CurrentRow.Index;
                int            ID  = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
                DoiTacQuangCao hh  = DoiTacQuangCao_BUL.TimLoaiHang(ID);
                fr_lh = new fr_QuanLy_DoiTacQuanCao(hh);
            }
            if (fr_lh != null)
            {
                fr_lh.FormClosing += Frm2_Closing;
                fr_lh.ShowDialog();
                resetAfterHandle();
            }
        }
コード例 #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (combDomain.SelectedIndex == 0)
     {
         KhachHang kh = KhachHang_BUL.CheckKhachHang(txtUser.Text, txtPass.Text);
         if (kh != null)
         {
             fr_KhachHang_main KhachHangForm = new fr_KhachHang_main(kh);
             this.Hide();
             KhachHangForm.Show();
             KhachHangForm.FormClosing += Frm2_Closing;
         }
         else
         {
             ShowMessage();
         }
     }
     else if (combDomain.SelectedIndex == 1)
     {
         NhanVien nv = NhanVien_BUL.CheckNhanVien(txtUser.Text, txtPass.Text);
         if (nv != null)
         {
             if (nv.ChucVu == "NhanVien")
             {
                 fr_NhanVien_main NhanVien = new fr_NhanVien_main(nv);
                 this.Hide();
                 NhanVien.Show();
                 NhanVien.FormClosing += Frm2_Closing;
             }
             else if (nv.ChucVu == "QuanLy")
             {
                 fr_QuanLy_main QuanLy = new fr_QuanLy_main(nv);
                 this.Hide();
                 QuanLy.Show();
                 QuanLy.FormClosing += Frm2_Closing;
             }
             else
             {
                 ShowMessage();
             }
         }
         else
         {
             ShowMessage();
         }
     }
 }
コード例 #5
0
        private void init()
        {
            List <LoaiHoang> listLoaihang = LoaiHang_BUL.getList();

            comb_loaihang.DataSource    = listLoaihang;
            comb_loaihang.DisplayMember = "TenLoai";
            List <NhanVien> listQuanLy = NhanVien_BUL.getListNhanVien();

            comb_quanly.DataSource    = listQuanLy;
            comb_quanly.DisplayMember = "HoTen";
            List <NhaCungCap> listNCC = NhaCungCap_BUL.getList();

            comb_ncc.DataSource    = listNCC;
            comb_ncc.DisplayMember = "TenNCC";
            txt_sltra.Enabled      = false;
            txt_sltra.Text         = "0";
        }
コード例 #6
0
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            int          pos          = dtgv.CurrentRow.Index;
            int          ID           = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value);
            DialogResult dialogResult = MessageBox.Show("Bạn chắc chắn muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (comb_danhmuc.SelectedIndex == 0)
                {
                    if (LoaiHang_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (comb_danhmuc.SelectedIndex == 1)
                {
                    if (HangHoa_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (comb_danhmuc.SelectedIndex == 2)
                {
                    if (KhachHang_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (comb_danhmuc.SelectedIndex == 3)
                {
                    if (NhaCungCap_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (comb_danhmuc.SelectedIndex == 4)
                {
                    if (NhanVien_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (comb_danhmuc.SelectedIndex == 5)
                {
                    if (DoiTacQuangCao_BUL.Xoa(ID))
                    {
                        MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK);
                        IntoDataTodtgv();
                    }
                    else
                    {
                        MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }