コード例 #1
0
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            MonAnTheoNgay   ma  = new MonAnTheoNgay();
            DAODoAntheongay dao = new DAODoAntheongay();

            try
            {
                ma.Mamonan = (int)dtg_doan.CurrentRow.Cells[0].Value;
                ma.Gia     = float.Parse(dtg_doan.CurrentRow.Cells[2].Value.ToString());
                ma.Soluong = (int)dtg_doan.CurrentRow.Cells[3].Value;
                if (dao.xoaMonAntheongay(ma) == false)
                {
                    MessageBox.Show("Xóa món ăn thành công");
                }
                else
                {
                    MessageBox.Show("Xóa món ăn thất bại");
                }
                load_doan_theo_ngay();
                load_nguyen_lieu();
            }
            catch (Exception a)
            {
                MessageBox.Show(a.ToString());
            }
        }
コード例 #2
0
        public bool xoaMonAntheongay(MonAnTheoNgay ma)
        {
            SqlCommand command = new SqlCommand("execute xoaMonAntheongay @mamonan", db.GetConnection);

            command.Parameters.Add("@mamonan", SqlDbType.Int).Value = ma.Mamonan;
            db.openConection();
            if (command.ExecuteNonQuery() == 1)
            {
                db.closedConection();
                return(true);
            }
            else
            {
                db.closedConection();
                return(false);
            }
        }