Beispiel #1
0
        private void btnXoaCongThuc_Click(object sender, EventArgs e)
        {
            try
            {
                string a = dgvCongThuc.Rows[index].Cells[0].Value.ToString().Trim();
                string b = dgvCongThuc.Rows[index].Cells[1].Value.ToString().Trim();

                if (lblMaNguyenLieu.Text != "")
                {
                    if (MsgBox.Show("Bạn có chăc chắn xóa công thức này không!", "Thông báo", MsgBox.Buttons.YesNo, MsgBox.Icon.Question) == DialogResult.Yes)
                    {
                        BUS_ChiTietMonAn chitiet = new BUS_ChiTietMonAn();
                        DTO_ChiTietMonAn dm      = new DTO_ChiTietMonAn(int.Parse(lblMaMonAn.Text), int.Parse(lblMaNguyenLieu.Text));
                        chitiet.XoaCongThuc(dm);
                        getChiTietMonAn();
                        MsgBox.Show("Xóa công thức " + a + "[" + b + "] thành công!", "Thông báo", MsgBox.Buttons.OK);
                    }
                }
            }
            catch (SqlException ex)
            {
                MsgBox.Show(ex.Message);
            }
            catch (Exception)
            {
                MsgBox.Show("Không có dữ liệu để xóa!", "Thông báo", MsgBox.Buttons.OK, MsgBox.Icon.Question);
            }
        }
Beispiel #2
0
        public void XoaCongThuc(DTO_ChiTietMonAn ct)
        {
            SqlConnection cnn = dp.getConnect();

            dp.Connect();//ham nay de ket noi thay thi cnn.open();
            string     xoaCongThuc = "DELETE FROM ChiTietMonAn WHERE MaMonAn = '" + ct.MaMonAn + "' AND MaNguyenLieu = '" + ct.MaNguyenLieu + "'";
            SqlCommand cmd         = new SqlCommand(xoaCongThuc, cnn);

            cmd.ExecuteNonQuery();
        }
Beispiel #3
0
        public void ThemCongThuc(DTO_ChiTietMonAn ct)
        {
            SqlConnection cnn = dp.getConnect();

            dp.Connect();
            string     themChiTiet = "INSERT INTO ChiTietMonAn(MaMonAn,MaNguyenLieu,GhiChu) VALUES(N'" + ct.MaMonAn + "','" + ct.MaNguyenLieu + "',N'" + ct.GhiChu + "')";
            SqlCommand cmd         = new SqlCommand(themChiTiet, cnn);

            cmd.ExecuteNonQuery();//Thuc thi cau truy van
        }
Beispiel #4
0
        private void btnThemCongThuc_Click(object sender, EventArgs e)
        {
            try
            {
                string maMonAn      = cbbTenMonAn.SelectedValue.ToString().Trim();
                string maNguyenLieu = cbbTenNguyenLieu.SelectedValue.ToString().Trim();
                //lay ma mon an trong bang mon an
                string           ghiChu = txtGhiChu.Text;
                DTO_ChiTietMonAn ct     = new DTO_ChiTietMonAn(Convert.ToInt32(maMonAn), Convert.ToInt32(maNguyenLieu), ghiChu);
                Ct.ThemCongThuc(ct);
                MsgBox.Show("Thêm nguyên liệu " + cbbTenNguyenLieu.GetItemText(cbbTenNguyenLieu.SelectedItem).Trim() + " vào " + cbbTenMonAn.GetItemText(cbbTenMonAn.SelectedItem).Trim() + " thành công!", "Thông báo", MsgBox.Buttons.OK);

                getChiTietMonAn();
            }

            catch (SqlException)
            {
                MsgBox.Show("Công thức món ăn đã tồn tại!", "Thông báo");
            }
            catch (NullReferenceException)// NullReferenceException kiem tra gia tri co bi null hay ko
            {
                MsgBox.Show("Vui lòng chọn tên món ăn và nguyên liệu!", "Thông báo", MsgBox.Buttons.OK, MsgBox.Icon.Question);
            }
        }
Beispiel #5
0
 public void XoaCongThuc(DTO_ChiTietMonAn ct)
 {
     chiTietMonAn.XoaCongThuc(ct);
 }
Beispiel #6
0
 public void ThemCongThuc(DTO_ChiTietMonAn ct)
 {
     chiTietMonAn.ThemCongThuc(ct);
 }