private void kryptonButton9_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txt_TenMon.Text.Trim())) { QuanLyQuanCafeApp.Models.Mon obj = new QuanLyQuanCafeApp.Models.Mon { TenMon = txt_TenMon.Text.Trim(), GiaBan = (double)num_updown_GiaBan.Value, IdThucDon = (int)cbthucdon.SelectedValue }; if (!string.IsNullOrEmpty(txtmamon.Text)) { //MessageBox.Show("Ok Sua"); obj.Id = int.Parse(txtmamon.Text.Trim()); int kq = app.Mon.UpdateMon(obj); if (kq >= 1) { MessageBox.Show("Sửa món thành công"); LoadMon(); //if (updateMon != null) //{ // updateMon(this, new EventArgs()); //} } else { MessageBox.Show("Sửa món thất bại"); } } else { //MessageBox.Show("Themmoi"); int kq = app.Mon.AddMon(obj); if (kq >= 1) { MessageBox.Show("Thêm món thành công"); LoadMon(); //if (addMon != null) //{ // addMon(this, new EventArgs()); //} } else { MessageBox.Show("Thêm món thất bại"); } } } else { MessageBox.Show("Mời nhập tên món!"); } }
public int AddMon(Mon obj) { Parameter[] parameters = { new Parameter { Name = "@TenMon", Value = obj.TenMon, DbType = DbType.String }, new Parameter { Name = "@Giaban", Value = obj.GiaBan, DbType = DbType.Double }, new Parameter { Name = "@IdThucDon", Value = obj.IdThucDon, DbType = DbType.Int32 } }; return(Save("AddMon", parameters)); }