private void cell_Click(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = this.dgvCapNhatDichVu.Rows[e.RowIndex]; int maDV = int.Parse(row.Cells[1].Value.ToString()); DichVu db = DichVu.GetDichVu(maDV); txtCapNhatDichVu.Text = db.TenDV.ToString(); txtGia.Text = db.GiaDV.ToString(); } }
private void btnLuuCapNhatDichVu_Click(object sender, EventArgs e) { DichVu s = GetDichVu(); s.DichVuID = (int)dgvCapNhatDichVu.CurrentRow.Cells[1].Value; DichVu db = DichVu.GetDichVu(s.DichVuID); if (db != null) { db = s; db.InsertUpdate(); MessageBox.Show("Sửa thành công!"); } BindGrid(DichVu.GetAll()); }
private void btnThemDichVu_Click(object sender, EventArgs e) { try { DichVu s = GetDichVu(); DichVu db = DichVu.GetDichVu(s.DichVuID); if (db == null) { s.InsertUpdate(); MessageBox.Show("Thêm dịch vụ thành công!"); } BindGrid(DichVu.GetAll()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnThemCuaCTPP_Click(object sender, EventArgs e) { try { DichVu dv = DichVu.GetDichVu(int.Parse(cmbTenDichVu.SelectedValue.ToString())); if (txtSoLuong.Text == "") { throw new Exception("Vui long nhap so luong!"); } int index = dgvChiTietDichVu.Rows.Add(); dgvChiTietDichVu.Rows[index].Cells[0].Value = (index + 1).ToString(); dgvChiTietDichVu.Rows[index].Cells[1].Value = dv.TenDV; dgvChiTietDichVu.Rows[index].Cells[2].Value = dv.GiaDV + ""; dgvChiTietDichVu.Rows[index].Cells[3].Value = txtSoLuong.Text + ""; int thanhtien = dv.GiaDV.Value * int.Parse(txtSoLuong.Text); dgvChiTietDichVu.Rows[index].Cells[4].Value = thanhtien.ToString(); dgvChiTietDichVu.Rows[index].Cells["id"].Value = dv.DichVuID + ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } }