private void BtnThanhToan_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); string date = DateTime.Now.Year + "-" + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString()) + "-" + (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString()); db.executeQuery("insert into tblHoaDon values (dbo.sinhmaHD()," + lbBanSo.Text + ",'" + date + " " + lblTime.Text + "'," + lbSoKhach.Text + ",'" + formLogin.MaNguoiDung + "'," + formGoiMon.TongTien + ")"); DataTable dt = db.getData("select tblGoiMon1.MaThucDon, SoLuong from tblGoiMon1 join tblThucDon on tblGoiMon1.MaThucDon=tblThucDon.MaThucDon where MaBanAn=" + lbBanSo.Text + " and XacNhan!=N'Hủy'"); if (dt != null) { foreach (DataRow dr in dt.Rows) { db.executeQuery("insert into tblCTHD values (dbo.sinhmaCTHD(),'" + dr["MaThucDon"].ToString() + "'," + dr["SoLuong"].ToString() + ")"); } } db.executeQuery("delete from tblGoiMon1 where MaBanAn=" + lbBanSo.Text); MessageBox.Show("Đã lưu!"); } catch (Exception) { MessageBox.Show("Lỗi!"); } }
private void BtnSave_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); if (kt == "Them") { db.executeQuery("INSERT INTO tblThucDon values(dbo.sinhmaTD(), N'" + cbLoaiThucDon.Text + "', N'" + textTenThucDon.Text + "', N'" + textDonViTinh.Text + "'," + textDonGia.Text + ")"); MessageBox.Show("Thêm thực đơn thành công!"); } if (kt == "Sua") { db.executeQuery("update tblThucDon set Loai =N'" + cbLoaiThucDon.Text + "' where MaThucDon = '" + MaTD + "'"); db.executeQuery("update tblThucDon set TenThucDon =N'" + textTenThucDon.Text + "' where MaThucDon = '" + MaTD + "'"); db.executeQuery("update tblThucDon set DonViTinh =N'" + textDonViTinh.Text + "' where MaThucDon = '" + MaTD + "'"); db.executeQuery("update tblThucDon set DonGia =" + textDonGia.Text + "where MaThucDon = '" + MaTD + "'"); MessageBox.Show("Sửa thực đơn thành công!"); } setControls(true); refreshDataGridView(); } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }
private void BtnSave_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); if (kt == "Them") { db.executeQuery("insert into tblNCC values (dbo.sinhmaNCC(),N'" + textTenNCC.Text + "',N'" + textDiaChi.Text + "','" + textSDT.Text + "',N'" + textEmail.Text + "')"); MessageBox.Show("Thêm nhà cung cấp thành công!"); } if (kt == "Sua") { db.executeQuery("update tblNCC set TenNCC=N'" + textTenNCC.Text + "' where MaNCC='" + MaNCC1 + "'"); db.executeQuery("update tblNCC set DiaChi=N'" + textDiaChi.Text + "' where MaNCC='" + MaNCC1 + "'"); db.executeQuery("update tblNCC set SDT='" + textSDT.Text + "' where MaNCC='" + MaNCC1 + "'"); db.executeQuery("update tblNCC set Email=N'" + textEmail.Text + "' where MaNCC='" + MaNCC1 + "'"); MessageBox.Show("Sửa nhà cung cấp thành công!"); } setControls(true); refreshDataGridView(); } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }
private void BtnXacNhan_Click(object sender, EventArgs e) { maNL_Nhap = dgvYeuCauMua.Rows[rowNhapNL].Cells[0].Value.ToString(); myDataBases db = new myDataBases(); db.executeQuery("insert into tblNhapNL values ('" + maNL_Nhap + "','" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "'," + dgvYeuCauMua.Rows[rowNhapNL].Cells[2].Value.ToString() + ", N'Đã Nhận, Chưa Thanh Toán Tiền')"); db.executeQuery("update tblNguyenLieu set SoLuong=SoLuong+" + dgvYeuCauMua.Rows[rowNhapNL].Cells[2].Value.ToString() + " where MaNL='" + maNL_Nhap + "'"); db.executeQuery("delete from tblYC_MuaNL where MaNL='" + maNL_Nhap + "'"); MessageBox.Show("Đã xác nhận nhập nguyên liệu thành công!"); refreshDataGridView(); rowNhapNL = 0; }
private void BtnXuat_Click(object sender, EventArgs e) { maNL = dgvYeuCauNL.Rows[dgvrowNL].Cells[0].Value.ToString(); myDataBases db = new myDataBases(); db.executeQuery("insert into tblXuatNL values ('" + maNL + "','" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "'," + textSoLuong.Text + ")"); db.executeQuery("update tblNguyenLieu set SoLuong=SoLuong-" + textSoLuong.Text + " where MaNL='" + maNL + "'"); db.executeQuery("delete from tblYeuCauNL where MaNL='" + maNL + "'"); refreshDataGridView(); MessageBox.Show("Xuất nguyên liệu thành công!"); dgvrowNL = 0; }
private void BtnTuChoi_Click(object sender, EventArgs e) { myDataBases db = new myDataBases(); db.executeQuery("delete from tblYC_MuaNL where MaNL='" + MaNL + "'"); refreshDataGridView(); }
private void BtnHuy_Click(object sender, EventArgs e) { myDataBases db = new myDataBases(); db.executeQuery("update tblYeuCauNL set XacNhan=N'Hủy' where MaNL='" + maNL + "'"); refreshDataGridView(); }
private void BtnAll_Click(object sender, EventArgs e) { myDataBases db = new myDataBases(); db.executeQuery("update tblYC_MuaNL set XacNhan=N'Chấp Nhận'"); refreshDataGridView(); }
private void BtnSave_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); if (kt == "Them") { db.executeQuery("insert into tblNguyenLieu values (dbo.sinhmaNL(),N'" + textTenNL.Text + "','" + cbMaNCC.Text + "'," + textSoLuong.Text + ",'" + formLogin.MaNguoiDung + "',N'" + textDonViTinh.Text + "'," + textDonGia.Text + ")"); MessageBox.Show("Thêm nguyên liệu thành công!"); } if (kt == "Sua") { db.executeQuery("update tblNguyenLieu set TenNL = N'" + textTenNL.Text + "' where MaNL='" + MaNL + "'"); db.executeQuery("update tblNguyenLieu set MaNCC = '" + cbMaNCC.Text + "' where MaNL='" + MaNL + "'"); db.executeQuery("update tblNguyenLieu set MaNVNhap = '" + formLogin.MaNguoiDung + "' where MaNL='" + MaNL + "'"); db.executeQuery("update tblNguyenLieu set SoLuong = " + textSoLuong.Text + " where MaNL='" + MaNL + "'"); db.executeQuery("update tblNguyenLieu set DonViTinh = N'" + textDonViTinh.Text + "' where MaNL='" + MaNL + "'"); db.executeQuery("update tblNguyenLieu set DonGia = " + textDonGia.Text + " where MaNL='" + MaNL + "'"); MessageBox.Show("Sửa nguyên liệu thành công!"); } setControls(true); refreshDataGridView(); } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }
private void BtnXacNhan_Click(object sender, EventArgs e) { MaNL = dgvThanhToan.Rows[row].Cells[0].Value.ToString(); myDataBases db = new myDataBases(); db.executeQuery("update tblNhapNL set XacNhan=N'Đã Thanh Toán' where MaNL='" + MaNL + "'"); MessageBox.Show("Đã xác nhận nhập nguyên liệu thành công!"); refreshDataGridView(); row = 0; }
private void BtnXoa_Click(object sender, EventArgs e) { DialogResult h = MessageBox.Show("Bạn có chắc muốn xóa thực đơn không?", "Thông báo", MessageBoxButtons.OKCancel); if (h == DialogResult.OK) { myDataBases db = new myDataBases(); db.executeQuery("delete from tblThucDon where MaThucDon='" + MaTD + "'"); refreshDataGridView(); } }
private void BtnYeuCau_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); db.executeQuery("insert into tblYC_MuaNL values ('" + dgvNguyenLieu.Rows[dgvrow].Cells[6].Value.ToString() + "'," + textSoLuong1.Text + ",N'Chưa')"); MessageBox.Show("Yêu cầu thành công!"); } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }
private void BtnXong_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); db.executeQuery("update tblGoiMon1 set XacNhan=N'Xong' where MaBanAn=" + cbChonBan.Text + "and XacNhan != N'Hủy'"); refreshDataGridView(); MessageBox.Show("Xác nhận thành công!"); } catch (Exception) { MessageBox.Show("Chưa chọn bàn!"); } }
private void BtnHuyMon_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); db.executeQuery("update tblGoiMon1 set XacNhan=N'Hủy' where MaBanAn=" + cbChonBan.Text + " and MaThucDon='" + dgvCheBien.Rows[dgvrow].Cells[3].Value.ToString() + "'"); refreshDataGridView(); MessageBox.Show("Hủy món thành công!"); } catch (Exception) { MessageBox.Show("Chưa chọn bàn!"); } }
private void BtnGoiMon_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); for (int i = 0; i < n; i++) { db.executeQuery("insert into tblGoiMon1 values (" + cbChonBan.Text + ",'" + lvThucDon.Items[i].SubItems[4].Text + "'," + lvThucDon.Items[i].SubItems[2].Text + ",N'Chưa Xong')"); } MessageBox.Show("Gọi món thành công!"); } catch (Exception) { MessageBox.Show("Chưa chọn bàn!"); } DataGridView_DuaMon(); }
private void BtnYeuCau_Click(object sender, EventArgs e) { try { if (int.Parse(textSoLuong.Text) < sl) { myDataBases db = new myDataBases(); db.executeQuery("insert into tblYeuCauNL values ('" + dgvNguyenLieu.Rows[dgvrowNL].Cells[6].Value.ToString() + "'," + textSoLuong.Text + ",N'Chưa')"); MessageBox.Show("Yêu cầu thành công!"); } else { MessageBox.Show("Số lượng yêu cầu quá lớn!"); } } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }
private void BtnSave_Click(object sender, EventArgs e) { try { myDataBases db = new myDataBases(); if (kt == "Them") { if (rbNam.Checked == true) { db.executeQuery("insert into tblNguoiDung values (dbo.sinhmaND(),N'" + textHoTen.Text + "','" + dateNgaySinh.Text + "',N'Nam',N'" + textQueQuan.Text + "','" + textSDT.Text + "','" + textTenDangNhap.Text + "','" + textMatKhau.Text + "',N'" + cbQuyen.Text + "')"); } if (rbNu.Checked == true) { db.executeQuery("insert into tblNguoiDung values (dbo.sinhmaND(),N'" + textHoTen.Text + "','" + dateNgaySinh.Text + "',N'Nữ',N'" + textQueQuan.Text + "','" + textSDT.Text + "','" + textTenDangNhap.Text + "','" + textMatKhau.Text + "',N'" + cbQuyen.Text + "')"); } if ((rbNam.Checked == false) && (rbNu.Checked == false)) { db.executeQuery("insert into tblNguoiDung values (dbo.sinhmaND(),N'" + textHoTen.Text + "','" + dateNgaySinh.Text + "',N'',N'" + textQueQuan.Text + "','" + textSDT.Text + "','" + textTenDangNhap.Text + "','" + textMatKhau.Text + "',N'" + cbQuyen.Text + "')"); } MessageBox.Show("Thêm nhân viên thành công!"); } if (kt == "Sua") { db.executeQuery("update tblNguoiDung set HoTen = N'" + textHoTen.Text + "' where MaNguoiDung='" + MaND + "'"); db.executeQuery("update tblNguoiDung set NgaySinh = N'" + dateNgaySinh.Text + "' where MaNguoiDung='" + MaND + "'"); if (rbNam.Checked == true) { db.executeQuery("update tblNguoiDung set GioiTinh = N'Nam' where MaNguoiDung='" + MaND + "'"); } if (rbNu.Checked == true) { db.executeQuery("update tblNguoiDung set GioiTinh = N'Nữ' where MaNguoiDung='" + MaND + "'"); } if ((rbNam.Checked == false) && (rbNu.Checked == false)) { db.executeQuery("update tblNguoiDung set GioiTinh = N'' where MaNguoiDung='" + MaND + "'"); } db.executeQuery("update tblNguoiDung set QueQuan = N'" + textQueQuan.Text + "' where MaNguoiDung='" + MaND + "'"); db.executeQuery("update tblNguoiDung set SDT = N'" + textSDT.Text + "' where MaNguoiDung='" + MaND + "'"); db.executeQuery("update tblNguoiDung set TenDangNhap = N'" + textTenDangNhap.Text + "' where MaNguoiDung='" + MaND + "'"); db.executeQuery("update tblNguoiDung set MatKhau = N'" + textMatKhau.Text + "' where MaNguoiDung='" + MaND + "'"); db.executeQuery("update tblNguoiDung set Quyen = N'" + cbQuyen.Text + "' where MaNguoiDung='" + MaND + "'"); MessageBox.Show("Sửa nhân viên thành công!"); } setControls(true); refreshDataGridView(); } catch (Exception) { MessageBox.Show("Lỗi! Không thành công!"); } }