Example #1
0
        public void Execute()
        {
            HoaDon check = null;

            using (var repo = new HoaDon_view())
            {
                repo.MaHD = item.MaHD;
                check     = repo.Execute();
            }
            if (check != null)//đã tồn tại ==> ta tiến hành update
            {
                using (var repo = new HoaDon_delete())
                {
                    repo.item = item;
                    repo.Execute();
                }
            }
            else
            {
                //tien hanh insert
                using (var repo = new HoaDon_insert())
                {
                    repo.item = item;
                    repo.Execute();
                }
            }
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            var curRow = this.hoaDonBindingSource.Current as HoaDon;

            using (var repo = new HoaDon_delete())
            {
                repo.MaHD = curRow.MaHD;
                repo.Execute();
            }
            this.button1_Click(null, null);
            MessageBox.Show("Xoá thành công !");
        }