Example #1
0
        private void btThem_Click(object sender, EventArgs e)
        {
            DAO_NhaCungCap dao = new DAO_NhaCungCap();

            if (ex.KiemTraChuoi(tbTen.Text, 100) && ex.KiemTraChuoi(tbDiaChi.Text, 500))
            {
                if (ex.KiemTraSoLuong(tbSDT.Text, 11))
                {
                    DTO_NhaCungCap dto = new DTO_NhaCungCap(tbTen.Text, tbDiaChi.Text, Convert.ToInt32(tbSDT.Text));
                    dao.Insert(dto);
                    tbTen.Text    = "";
                    tbDiaChi.Text = "";
                    tbSDT.Text    = "";
                }
                else
                {
                    MessageBox.Show("Nhập Sai SĐT");
                }
            }
            else
            {
                MessageBox.Show("Tên Hoặc Địa Chỉ Quá Dài");
            }

            FNhaCungCap_Load(sender, e);
        }
Example #2
0
        private void FNhaCungCap_Load(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            List <DTO_NhaCungCap> list = new List <DTO_NhaCungCap>();
            DAO_NhaCungCap        dao  = new DAO_NhaCungCap();

            list = dao.Load();
            foreach (var item in list)
            {
                ListViewItem it = new ListViewItem(item.ID.ToString());

                it.SubItems.Add(item.Ten);
                it.SubItems.Add(item.Diachi);
                it.SubItems.Add(item.Sdt.ToString());
                listView1.Items.Add(it);
            }
        }
Example #3
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            DAO_NhaCungCap dao = new DAO_NhaCungCap();
            DTO_NhaCungCap dto = new DTO_NhaCungCap();

            dto.ID = ID;
            if (ID != 0)
            {
                dao.Delete(dto);
                tbTen.Text    = "";
                tbDiaChi.Text = "";
                tbSDT.Text    = "";
            }
            else
            {
                MessageBox.Show("Click on Item");
            }
            FNhaCungCap_Load(sender, e);
        }
 public BUS_NhaCungCap()
 {
     da = new DAO_NhaCungCap();
 }