private void btnAdd_Click(object sender, EventArgs e) { try { var listcur = this.hangHoaBindingSource.DataSource as List <HangHoa.Domain.HangHoa>; if (listcur != null) { using (var cmd = new HangHoaAddRepository()) { foreach (var item in listcur) { cmd.item = item; cmd.Execute(); } } using (var cmd = new HangHoaListRepository()) { cmd.Execute(); } } } catch { } }
private void cbbNhomHangHoa_SelectedIndexChanged(object sender, EventArgs e) { using (var cmd = new HangHoaListRepository()) { cmd.NhomHanghoaId = this.cbbNhomHangHoa.SelectedValue.ToString(); this.cbbHangHoa.DataSource = cmd.Execute(); this.cbbHangHoa.DisplayMember = "TenHanghoa"; this.cbbHangHoa.ValueMember = "HanghoaId"; } }
private void cbbHangHoa_SelectedIndexChanged(object sender, EventArgs e) { using (var cmd = new HangHoaListRepository()) { cmd.HanghoaId = this.cbbHangHoa.SelectedValue.ToString(); var data = cmd.Execute(); this.txtGiaBan.Text = data[0].GiaBan.ToString(); this.txtSoLuong.Text = ""; this.txtSoLuong.HintText = "Số lượng tồn kho là " + data[0].SoLuongTonKho.ToString(); } }
private void nhomHangHoaDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { var cur = this.nhomHangHoaBindingSource.Current as NhomHangHoa.Domain.NhomHangHoa; if (cur != null && !string.IsNullOrWhiteSpace(cur.NhomHanghoaId)) { using (var cmd = new HangHoaListRepository()) { cmd.NhomHanghoaId = cur.NhomHanghoaId; this.hangHoaBindingSource.DataSource = cmd.Execute(); } } }
private void button3_Click(object sender, EventArgs e) { var cur = this.hangHoaBindingSource.Current as HangHoa.Domain.HangHoa; if (cur != null && !string.IsNullOrWhiteSpace(cur.HanghoaId)) { using (var cmd = new HangHoaDeleteRepository()) { cmd.hangHoaId = cur.HanghoaId; cmd.Execute(); } using (var cmd = new HangHoaListRepository()) { this.hangHoaBindingSource.DataSource = cmd.Execute(); } } }
private void btnEdit_Click(object sender, EventArgs e) { var cur = this.hangHoaBindingSource.Current as HangHoa.Domain.HangHoa; if (cur != null && !string.IsNullOrWhiteSpace(cur.HanghoaId)) { var listcur = this.hangHoaBindingSource.DataSource as List <HangHoa.Domain.HangHoa>; using (var cmd = new HangHoaSaveBusiness()) { foreach (var item in listcur) { cmd.item = item; cmd.Execute(); } } using (var cmd = new HangHoaListRepository()) { cmd.NhomHanghoaId = cur.NhomHanghoaId; this.hangHoaBindingSource.DataSource = cmd.Execute(); } } }
private void btnDel_Click(object sender, EventArgs e) { try { var cur = this.hangHoaBindingSource.Current as HangHoa.Domain.HangHoa; if (cur != null && !string.IsNullOrWhiteSpace(cur.HanghoaId)) { using (var cmd = new HangHoaDeleteRepository()) { cmd.hangHoaId = cur.HanghoaId; cmd.Execute(); } using (var cmd = new HangHoaListRepository()) { this.hangHoaBindingSource.DataSource = cmd.Execute(); } } } catch { MessageBox.Show("Lỗi không xác định, vui lòng thử lại!", "THÔNG BÁO!", MessageBoxButtons.OK); } }