private void button3_Click(object sender, EventArgs e) { int Curr = dataDV.CurrentCell.RowIndex; int madichvu = (int)dataDV.Rows[Curr].Cells[0].Value; Danhsach ds = new Danhsach(0,madichvu); if (objds.XoaDV(ds) == true) { dataDV.DataSource = objds.GetDV(); MessageBox.Show("Xóa Dịch Vụ Thành Công"); } else { MessageBox.Show("Xóa Dịch Vụ Thất Bại"); } }
public bool ThemMonAn(Danhsach ds) { try { if (conn.State != ConnectionState.Open) conn.Open(); OleDbCommand cmd = new OleDbCommand("INSERT INTO MONAN(TenMonAn,DonGiaMonAn,GhiChu) VALUES ('" + ds.TenMonAn + "'," + ds.DonGiaMonAn + ",'" + ds.GhiChu + "')", conn); cmd.ExecuteNonQuery(); conn.Close(); return true; } catch (Exception e) { conn.Close(); return false; } }
private void button2_Click(object sender, EventArgs e) { int Curr = dataDV.CurrentCell.RowIndex; int madichvu = (int)dataDV.Rows[Curr].Cells[0].Value; string tendichvu = Convert.ToString(dataDV.Rows[Curr].Cells[1].Value.ToString()); int dongiadichvu = (int)dataDV.Rows[Curr].Cells[2].Value; string ghichu = Convert.ToString(dataDV.Rows[Curr].Cells[3].Value.ToString()); Danhsach ds = new Danhsach(tendichvu, dongiadichvu, ghichu, madichvu); if (objds.UpdateDV(ds) == true) { dataDV.DataSource = objds.GetDV(); MessageBox.Show("Cập Nhật Dịch Vụ Thành Công"); } else { MessageBox.Show("Cập Nhật Dịch Vụ Thất Bại"); } }
public bool XoaMonAn(Danhsach ds) { return objds.XoaMonAn(ds); }
public bool XoaDV(Danhsach ds) { return objds.XoaDichVu(ds); }
public bool UpdateMonAn(Danhsach ds) { return objds.UpdateMonAn(ds); }
public bool UpdateDV(Danhsach ds) { return objds.UpdateDichVu(ds); }
public bool ThemMonAn(Danhsach ds) { return objds.ThemMonAn(ds); }
public bool ThemDV(Danhsach ds) { return objds.ThemDichVu(ds); }
private void button5_Click(object sender, EventArgs e) { try { int Curr = dataDV.CurrentCell.RowIndex; if (Curr + 2 >= dataDV.Rows.Count) { string tendichvu = Convert.ToString(dataDV.Rows[Curr].Cells[1].Value.ToString()); int dongiadichvu = (int)dataDV.Rows[Curr].Cells[2].Value; string ghichu = Convert.ToString(dataDV.Rows[Curr].Cells[3].Value.ToString()); Danhsach ds = new Danhsach(tendichvu, dongiadichvu, ghichu, 0); if (tendichvu != "") { if (dongiadichvu != 0) { if (objds.ThemDV(ds) == true) { dataDV.DataSource = objds.GetDV(); MessageBox.Show("Thêm Dịch Vụ Thành Công"); } else { MessageBox.Show("Thêm Dịch Vụ Thất Bại"); } } else { MessageBox.Show("Vui Lòng Nhập Đơn Giá Dịch Vụ"); } } else { MessageBox.Show("Vui Lòng Nhập Tên Dịch Vụ"); } } else { MessageBox.Show("Thêm Dịch Vụ Thất Bại"); } } catch { MessageBox.Show("Vui Lòng Nhập Đầy Đủ Thông Tin"); } }
private void buttxoa_Click(object sender, EventArgs e) { int Curr = dataMonan.CurrentCell.RowIndex; int mamonan = (int)dataMonan.Rows[Curr].Cells[0].Value; Danhsach ds = new Danhsach(mamonan,0); if (objds.XoaMonAn(ds) == true) { dataMonan.DataSource = objds.GetMA(); MessageBox.Show("Xóa Món Ăn Thành Công"); } else { MessageBox.Show("Xóa Món Ăn Thất Bại"); } }
private void buttthem_Click(object sender, EventArgs e) { try { int Curr = dataMonan.CurrentCell.RowIndex; if (Curr + 2 >= dataMonan.Rows.Count) { string tenmonan = Convert.ToString(dataMonan.Rows[Curr].Cells[1].Value.ToString()); int dongiamonan = (int)dataMonan.Rows[Curr].Cells[2].Value; string ghichu = Convert.ToString(dataMonan.Rows[Curr].Cells[3].Value.ToString()); Danhsach ds = new Danhsach(0, tenmonan, dongiamonan, ghichu); if (tenmonan != "") { if (dongiamonan != 0) { if (objds.ThemMonAn(ds) == true) { dataMonan.DataSource = objds.GetMA(); MessageBox.Show("Thêm Món Ăn Thành Công"); } else { MessageBox.Show("Thêm Món Ăn Thất Bại"); } } else { MessageBox.Show("Vui Lòng Nhập Đơn Giá Món Ăn"); } } else { MessageBox.Show("Vui Lòng Nhập Tên Món Ăn"); } } else { MessageBox.Show("Thêm Món Ăn Thất Bại"); } } catch { MessageBox.Show("Vui Lòng Nhập đầy đủ thông tin"); } }
private void buttsua_Click(object sender, EventArgs e) { int Curr = dataMonan.CurrentCell.RowIndex; int mamonan = (int)dataMonan.Rows[Curr].Cells[0].Value; string tenmonan = Convert.ToString(dataMonan.Rows[Curr].Cells[1].Value.ToString()); int dongiamonan = (int)dataMonan.Rows[Curr].Cells[2].Value; string ghichu = Convert.ToString(dataMonan.Rows[Curr].Cells[3].Value.ToString()); Danhsach ds = new Danhsach(mamonan,tenmonan, dongiamonan, ghichu); if (objds.UpdateMonAn(ds) == true) { dataMonan.DataSource = objds.GetMA(); MessageBox.Show("Cập Nhật Thành Công"); } else { MessageBox.Show("Cập Nhật Thất Bại"); } }
public bool UpdateDichVu(Danhsach ds) { try { if (conn.State != ConnectionState.Open) conn.Open(); string strcmd = "UPDATE DICHVU SET TenDichVu='" + ds.TenDichVu + "', DonGiaDichVu=" + ds.DonGiaDichVu + ",GhiChu='" + ds.GhiChu + "' where MaDichVu=" + ds.MaDichVu; OleDbCommand cmd = new OleDbCommand(strcmd, conn); cmd.ExecuteNonQuery(); conn.Close(); return true; } catch (Exception e) { conn.Close(); return false; } }
public bool XoaMonAn(Danhsach ds) { try { if (conn.State != ConnectionState.Open) conn.Open(); OleDbCommand cmd = new OleDbCommand("DELETE FROM MONAN WHERE MaMonAn =" + ds.MaMonAn + "", conn); cmd.ExecuteNonQuery(); conn.Close(); return true; } catch (Exception e) { conn.Close(); return false; } }