private void btnThemDV_Click(object sender, EventArgs e) { if (cbxHoten.SelectedIndex == -1) { MessageBox.Show("Chưa chọn KH", "Error"); return; } CDatDichVu a = timKHOld(); if (a != null) { foreach (int j in lvwDSDV.SelectedIndices) { CDichVu dv = new CDichVu(); dv.Smadv = lvwDSDV.Items[j].Text; dv.Stendv = lvwDSDV.Items[j].SubItems[1].Text; dv.Giatien = Convert.ToInt32(lvwDSDV.Items[j].SubItems[2].Text); a.Arrdv.Add(dv); } } else { a = new CDatDichVu(); foreach (CKhachHang item in frmmng.Data.ArrKH) { if (item.CMND == iCMND) { a.Kh = item; break; } } foreach (int j in lvwDSDV.SelectedIndices) { CDichVu dv = new CDichVu(); dv.Smadv = lvwDSDV.Items[j].Text; dv.Stendv = lvwDSDV.Items[j].SubItems[1].Text; dv.Giatien = Convert.ToInt32(lvwDSDV.Items[j].SubItems[2].Text); a.Arrdv.Add(dv); } frmmng.Data.ArrDDV.Add(a); } hienthiChooseDSDV(iCMND); txtTongGiaTien.Text = a.tinhTongGiaTien().ToString(); if (frmmng.Data.ArrDV.Count > 0) { hienthiDSDV(); } foreach (CBill item in frmmng.Data.ArrBill) { if (item.Kh.CMND == iCMND) { item.Ddv = a; break; } } }
public void hienThiDV(int j) { CDichVu dv = frmmng.Data.ArrDV[j]; txtMaDV.Text = dv.Smadv; txtTenDV.Text = dv.Stendv; txtGiaTien.Text = dv.Giatien.ToString(); }
private CDichVu timDV(string madv) { CDichVu dv = null; if (frmmng.Data.ArrDV.Count > 0) { foreach (CDichVu item in frmmng.Data.ArrDV) { if (string.Equals(madv, item.Smadv)) { dv = item; break; } } } return(dv); }
private void btnSua_Click(object sender, EventArgs e) { CDichVu dv = new CDichVu(); dv.Smadv = txtMaDV.Text; dv.Stendv = txtTenDV.Text; dv.Giatien = Convert.ToInt32(txtGiaTien.Text); CDichVu a = timDV(dv.Smadv); if (a != null) { a.Stendv = dv.Stendv; a.Giatien = dv.Giatien; } else { MessageBox.Show("Trùng mã DV or Không có Data", "Error"); } hienThiDSDV(); }
private void btnThem_Click(object sender, EventArgs e) { CDichVu dv = new CDichVu(); dv.Smadv = txtMaDV.Text; dv.Stendv = txtTenDV.Text; dv.Giatien = Convert.ToInt32(txtGiaTien.Text); CDichVu a = timDV(dv.Smadv); if (a == null) { frmmng.Data.ArrDV.Add(dv); } else { MessageBox.Show("Trùng mã DV", "Error"); } i++; hienThiDSDV(); }