public static List <LoaiDichVu_DTO> HienThiTenLoaiDichVuLenComboBox() { List <LoaiDichVu_DTO> lstTenLoaiDichVu = new List <LoaiDichVu_DTO>(); try { string strTruyVan = string.Format("SELECT * FROM LoaiDichVu"); DataTable _dt = new DataTable(); _dt = DataProvider.fillDataTable(strTruyVan); if (_dt != null) { for (int i = 0; i < _dt.Rows.Count; i++) { LoaiDichVu_DTO ldvDTO = new LoaiDichVu_DTO(); ldvDTO.MaLoaiDichVu = _dt.Rows[i]["MaLoaiDichVu"].ToString(); ldvDTO.TenLoaiDichVu = _dt.Rows[i]["TenLoaiDichVu"].ToString(); lstTenLoaiDichVu.Add(ldvDTO); } } } catch (Exception ex) { XtraMessageBox.Show("Error : " + ex.Message); } return(lstTenLoaiDichVu); }
private void toolStripButton4_Click(object sender, EventArgs e) { try { LoaiDichVu_DTO tho = new LoaiDichVu_DTO(); if (txtMaLoaidv.Text.CompareTo("") != 0) { tho.MaLoaiDV = Int16.Parse(txtMaLoaidv.Text); } else { tho.MaLoaiDV = 0; } tho.TenLoaiDV = txtTenLoaidv.Text; if (txtDonGia.Text.CompareTo("") != 0) { tho.DonGia = Decimal.Parse(txtDonGia.Text); } else { tho.DonGia = 0; } dataGridView.DataSource = loaidichvu_bus.Search(tho); } catch (FormatException ex) { } catch (Exception ex2) { } }
public void LoaiDichVu_Upd(LoaiDichVu_DTO a) { var obj = vbdq.LOAIDICHVUs.Single(x => x.MaLoaiDV == a.MaLoaiDV); obj.TenLoaiDV = a.TenLoaiDV; obj.DonGia = a.DonGia; vbdq.SubmitChanges(); }
public FormLoaiDichVu_AddUpd(LoaiDichVu_DTO loaidv) { InitializeComponent(); txtMaLoaidv.Text = loaidv.MaLoaiDV.ToString(); txtTenLoaidv.Text = loaidv.TenLoaiDV; txtDonGia.Text = loaidv.DonGia.ToString(); btnThem.Enabled = false; }
public void LoaiDichVu_Add(LoaiDichVu_DTO a) { LOAIDICHVU b = new LOAIDICHVU(); b.MaLoaiDV = a.MaLoaiDV; b.TenLoaiDV = a.TenLoaiDV; b.DonGia = a.DonGia; vbdq.LOAIDICHVUs.InsertOnSubmit(b); vbdq.SubmitChanges(); }
private void cmbTenLoaiDichVu_SelectedIndexChanged(object sender, EventArgs e) { if (cmbTenLoaiDichVu.SelectedItem == null) { return; } LoaiDichVu_DTO ldvDTO = (LoaiDichVu_DTO)cmbTenLoaiDichVu.SelectedItem; cmbTenDichVu.DataSource = DichVu_BLL.HienThiTenDichVuTheoMaDichVu(ldvDTO.MaLoaiDichVu); cmbTenDichVu.DisplayMember = "TenDichVu"; cmbTenDichVu.ValueMember = "MaDichVu"; }
public List <LoaiDichVu_DTO> Search(LoaiDichVu_DTO loaidv) { var list = (from loaidichvu in vbdq.LOAIDICHVUs where (loaidichvu.MaLoaiDV == loaidv.MaLoaiDV || loaidv.MaLoaiDV == 0) && (loaidichvu.TenLoaiDV.Contains(loaidv.TenLoaiDV)) && (loaidichvu.DonGia == loaidv.DonGia || loaidv.DonGia == 0) select new LoaiDichVu_DTO { MaLoaiDV = loaidichvu.MaLoaiDV, TenLoaiDV = loaidichvu.TenLoaiDV, DonGia = Decimal.Parse(loaidichvu.DonGia.ToString()) }); return(list.ToList()); }
public List <LoaiDichVu_DTO> LayDanhSachLoaiDichVu() { lsLoaiDV = new List <LoaiDichVu_DTO>(); SqlConnection conn = DataProvider.TaoKetNoi(); string strTruyVan = "Select * From [LoaiDichVu] Where TrangThai = 1"; SqlDataReader sdr = DataProvider.TruyVanDuLieu(strTruyVan, conn); while (sdr.Read()) { LoaiDichVu_DTO LoaiDV = new LoaiDichVu_DTO(); LoaiDV.MaLoaiDV = sdr["MaLoaiDV"].ToString(); LoaiDV.TenLoaiDV = sdr["TenLoaiDV"].ToString(); lsLoaiDV.Add(LoaiDV); } sdr.Close(); conn.Close(); return(lsLoaiDV); }
private void btnSua_Click(object sender, EventArgs e) { if (txtMaLoaidv.Text.CompareTo("") == 0) { MessageBox.Show("Vui lòng chọn dòng dữ liệu muốn Sửa !"); } else { LoaiDichVu_DTO loaidv = new LoaiDichVu_DTO(); loaidv.MaLoaiDV = Int16.Parse(txtMaLoaidv.Text); loaidv.TenLoaiDV = txtTenLoaidv.Text; loaidv.DonGia = Decimal.Parse(txtDonGia.Text); FormLoaiDichVu_AddUpd form = new FormLoaiDichVu_AddUpd(loaidv); DialogResult dr = form.ShowDialog(); dataGridView.DataSource = loaidichvu_bus.LayTatCa(); } }
private void btnThem_Click(object sender, EventArgs e) { LoaiDichVu_DTO a = new LoaiDichVu_DTO(); a.MaLoaiDV = Int16.Parse(txtMaLoaidv.Text); a.TenLoaiDV = txtTenLoaidv.Text; decimal number; if (Decimal.TryParse(txtDonGia.Text, out number) == true) { a.DonGia = Decimal.Parse(txtDonGia.Text); loaidv_bus.LoaiDichVu_Add(a); this.Close(); } else { MessageBox.Show("Nhập sai đơn giá - Chỉ nhập số!"); } }