public ActionResult SuaThucDon(ThucDonModel model, HttpPostedFileBase file) { ThucDon dv = db.ThucDons.Find(model.Id); if (dv != null) { dv.TenThucDon = model.TenThucDon; dv.MoTa = model.MoTa; dv.MaNhom = model.MaNhom; db.SaveChanges(); } string subPath = "~/Content/UserUpload/img/ThucDon/"; // your code goes here bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } try { if (file != null && file.ContentLength > 0) { var path = Path.Combine(Server.MapPath(subPath), dv.Id.ToString() + ".png"); file.SaveAs(path); } } catch (Exception ex) { //return Json(new { Success = "false", Error = ex.Message }); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
//chuyen trang sau dialog //public void chuyenPage(IUICommand command) //{ // //Frame.Navigate(typeof(KaloNgoaiPage)); //} private void CheckBox_Checked(object sender, RoutedEventArgs e) { ThucDon td = new ThucDon(); // them cac IdThongKeNgay o day td.IdThongKeNgay = thongkengay.IdThongKeNgay; var checkMonAn = sender as CheckBox; td.IdMonAn = (int)(checkMonAn.Content as StackPanel).Tag; td.SoLuong = Int32.Parse(((checkMonAn.Content as StackPanel).Children.OfType <ComboBox>().FirstOrDefault().SelectedItem as ComboBoxItem).Content.ToString()); var listBlock = AllChildren(checkMonAn.Content as StackPanel).OfType <TextBlock>(); foreach (var item in listBlock) { if ((item as TextBlock).Name.Equals("kaloBlock")) { td.LuongKalo = double.Parse((item as TextBlock).Text); TongLuongKalo += double.Parse((item as TextBlock).Text); } } // chua co idThongKeNgay monanChonList.Add(td); }
public JsonResult LoadForm() { IQueryable <ThucDon> lstThucDon = thucDonBll.LayTatCa() as IQueryable <ThucDon>; int totalRow = lstThucDon.Count(); List <ThucDon> lst = new List <ThucDon>(); foreach (var item in lstThucDon) { ThucDon td = new ThucDon() { MaThucDon = item.MaThucDon, TenThucDon = item.TenThucDon, LoaiThucDon = item.LoaiThucDon, }; lst.Add(td); } return(Json(new { data = lst, total = totalRow, status = true }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveData(string strThucDon) { JavaScriptSerializer serialiser = new JavaScriptSerializer(); ThucDon thucDon = serialiser.Deserialize <ThucDon>(strThucDon); bool status = false; string message = string.Empty; ScriptFunctionsDataContext function = new ScriptFunctionsDataContext(); ThucDon td = new ThucDon() { MaThucDon = function.auto_maThucDon(), TenThucDon = thucDon.TenThucDon, LoaiThucDon = thucDon.LoaiThucDon, }; if (bll.ThemMoi(td) == true) { status = true; } return(Json(new { status = status })); }
public JsonResult Search(int page, int pageSize, string information) { IQueryable <ThucDon> lstThucDon = null; if (string.IsNullOrEmpty(information)) { lstThucDon = bll.LayTatCa() as IQueryable <ThucDon>; //lstNhanVien = db.NhanViens as IQueryable<NhanVien>; } else { lstThucDon = bll.TimKiemGanDungTheoTen(information) as IQueryable <ThucDon>; //lstNhanVien = db.NhanViens.Where(x => x.TenNhanVien.Contains(information)) as IQueryable<NhanVien>; } int totalRow = lstThucDon.Count(); List <ThucDon> lst = new List <ThucDon>(); foreach (var item in lstThucDon) { ThucDon td = new ThucDon() { MaThucDon = item.MaThucDon, TenThucDon = item.TenThucDon, LoaiThucDon = item.LoaiThucDon, }; lst.Add(td); } return(Json(new { data = lst.Skip((page - 1) * pageSize).Take(pageSize), total = totalRow, status = true }, JsonRequestBehavior.AllowGet)); }
public JsonResult LoadData(int page, int pageSize) { IQueryable <ThucDon> lstThucDon = bll.LayTatCa() as IQueryable <ThucDon>; int totalRow = lstThucDon.Count(); List <ThucDon> lst = new List <ThucDon>(); foreach (var item in lstThucDon) { ThucDon td = new ThucDon() { MaThucDon = item.MaThucDon, TenThucDon = item.TenThucDon, LoaiThucDon = item.LoaiThucDon, }; lst.Add(td); } return(Json(new { data = lst.Skip((page - 1) * pageSize).Take(pageSize), total = totalRow, status = true }, JsonRequestBehavior.AllowGet)); }
static void Main(string[] args) { //string[] ds = new string[100]; //int len = 0; string[] ds = new string[] { "nguyen Duc Anh", "Hoang Thi Phuong", "Bui Tien Dung", "Nguyen Cong Binh", "Nguyen Van Toan" }; //Xuat danh sach //Console.WriteLine(ds[0]); //Console.WriteLine(ds[1]); //Console.WriteLine(ds[2]); //Console.WriteLine(ds[3]); //int dem = 0; //for (int i = 0; i < ds.Length; i++) //{ // string hoVaTen = ds[i].TrimStart(); // int vt = hoVaTen.IndexOf(" "); // string ho = hoVaTen.Substring(0, vt); // if (ho.ToLower() == "nguyen") // dem++; //} //dem = 0; //for (int i = 0; i < ds.Length; i++) //{ // string hoVaTen = ds[i].TrimStart(); // int vt = hoVaTen.IndexOf(" "); // string ho = hoVaTen.Substring(0, vt); // if (ho.ToLower() == "tran") // dem++; //} //Console.WriteLine(DemHoTrongDanhSach(ds,"nguyen")); //Console.WriteLine(DemHoTrongDanhSach(ds, "bui")); //XuatDanhSach(ds); //Console.WriteLine("-------------------------------"); //HienThiDanhSachTheoChieuTangCuaTen(ds); //Console.WriteLine("-------------------------------"); //HienThiDanhSachTheoChieuGiamCuaTen(ds); //Console.WriteLine(dem); //while (true) //{ // Console.Clear(); // Console.WriteLine("------------------------------------------"); // Console.WriteLine("Nhap 1 de them 1 sinh vien "); // Console.WriteLine("Nhap 2 de hien thi danh sach"); // Console.WriteLine("Nhap 3 de hien thi theo chieu tang cua ten "); // Console.WriteLine("Nhap 4 de hien thi theo chieu giamm cua ten"); // Console.WriteLine("Nhap 5 de thoat"); // int nhap = int.Parse(Console.ReadLine()); // switch (nhap) // { // case 1: break; // case 2: // XuatDanhSach(ds); // break; // case 3: // HienThiDanhSachTheoChieuTangCuaTen(ds); // break; // case 4: // HienThiDanhSachTheoChieuGiamCuaTen(ds); // break; // case 5: return; // } // Console.ReadKey(); //} while (true) { Console.Clear(); Console.WriteLine("------------------------------------------"); Console.WriteLine("Nhap {0} de them 1 sinh vien ", (int)ThucDon.ThemSinhVien); Console.WriteLine("Nhap {0} de hien thi danh sach", (int)ThucDon.XuatDanhSach); Console.WriteLine("Nhap {0} de hien thi theo chieu tang cua ten ", (int)ThucDon.HienThiTheoChieuTangCuaTen); Console.WriteLine("Nhap {0} de hien thi theo chieu giamm cua ten", (int)ThucDon.HienThiTheoChieuGiamCuaTen); Console.WriteLine("Nhap {0} de thoat", (int)ThucDon.Thoat); ThucDon nhap = (ThucDon)int.Parse(Console.ReadLine()); switch (nhap) { case ThucDon.ThemSinhVien : //Console.Write("Nhap mot ho ten moi "); //string ht = Console.ReadLine(); //ds. break; case ThucDon.XuatDanhSach: XuatDanhSach(ds); break; case ThucDon.HienThiTheoChieuTangCuaTen: HienThiDanhSachTheoChieuTangCuaTen(ds); break; case ThucDon.HienThiTheoChieuGiamCuaTen: HienThiDanhSachTheoChieuGiamCuaTen(ds); break; case ThucDon.Thoat: return; } Console.ReadKey(); } }
public ActionResult Create(FormCollection form, HttpPostedFileBase HinhAnh) { string tenThucDon = form["TenThucDon"]; decimal donGia = Convert.ToDecimal(form["DonGia"]); int idMonAn = Convert.ToInt32(form["IDMonAn"]); ViewBag.MessageFail = string.Empty; if (string.IsNullOrWhiteSpace(tenThucDon)) { ViewBag.MessageFail += "Tên thực đơn không hợp lệ. "; } if (Convert.ToInt32(donGia) % 500 != 0) { ViewBag.MessageFail += "Đơn giá không hợp lệ. "; } if (!string.IsNullOrEmpty(ViewBag.MessageFail)) { return(View()); } string _FileName = ""; try { if (HinhAnh.ContentLength > 0) { string _folderPath = Path.Combine(Server.MapPath("~/Images/MonAn/")); // Determine whether the directory exists. if (!Directory.Exists(_folderPath)) { DirectoryInfo di = Directory.CreateDirectory(_folderPath); } _FileName = Path.GetFileName(HinhAnh.FileName); string _path = Path.Combine(Server.MapPath("~/Images/ThucDon/"), _FileName); if (!System.IO.File.Exists(_path)) { HinhAnh.SaveAs(_path); } } } catch { } ThucDon thucDon = new ThucDon(); thucDon.TenThucDon = tenThucDon; thucDon.HinhAnh = _FileName; thucDon.DonGia = donGia; thucDon.SoLuongDaDat = 0; thucDon.IDMonAn = idMonAn; if (ModelState.IsValid) { data.ThucDons.InsertOnSubmit(thucDon); data.SubmitChanges(); } ViewBag.MessageSuccess = "Thêm thực đơn [" + tenThucDon + "] thành công"; return(View()); }
public void Add(ThucDon thucdon) { db.ThucDons.Add(thucdon); db.SaveChanges(); }
public bool Create(ThucDon model) { return(_res.Create(model)); }
public bool updateThucDon(ThucDon thucdon) { return(ThucDonController.Instance.updateThucDon(thucdon)); }
public double?getGiaByMaThucDon(string mathucdon) { ThucDon td = qlnh.ThucDons.Where(a => a.MaThucDon == mathucdon).FirstOrDefault(); return(td.Gia); }
public static int Insert(ThucDon dish) { return(MenuDAO.Insert(dish)); }
static void Main(string[] args) { int[] a = new int[100]; int length = 0; int vt; int x; bool kq; int max, min; int[] mkq = new int[100]; int nkq = 0; while (true) { Console.Clear(); Console.WriteLine("\n".PadRight(30, '*') + "HE THONG CHUC NANG" + "".PadRight(30, '*')); Console.WriteLine(" Nhan {0}: Thoat khoi chuong trinh", (int)ThucDon.Thoat); Console.WriteLine(" Nhan {0}: Nhap thu cong", (int)ThucDon.NhapThuCong); Console.WriteLine(" Nhan {0}: Nhap tu dong", (int)ThucDon.NhapTuDong); Console.WriteLine(" Nhan {0}: Tim so am lon nhat", (int)ThucDon.TimAm_Max); Console.WriteLine(" Nhan {0}: Tim so am nho nhat", (int)ThucDon.TimAm_Min); Console.WriteLine(" Nhan {0}: Tim so duong lon nhat", (int)ThucDon.TimDuong_Max); Console.WriteLine(" Nhan {0}: Tim so duong nho nhat", (int)ThucDon.TimDuong_Min); Console.WriteLine(" Nhan {0}: Tim tat ca cac so am trong mang", (int)ThucDon.TimAm); Console.WriteLine(" Nhan {0}: Tim tat ca cac so duong trong mang", (int)ThucDon.TimDuong); Console.WriteLine(" Nhan {0}: Tong tat ca cac so am trong mang", (int)ThucDon.TongAm); Console.WriteLine(" Nhan {0}: Tong cac so duong trong mang", (int)ThucDon.TongDuong); Console.WriteLine(" Nhan {0}: Xoa mot so tai vi tri vt trong mang", (int)ThucDon.XoaTai_VT); Console.WriteLine(" Nhan {0}: Xoa phan tu dau tien trong mang", (int)ThucDon.Xoa_Dau); Console.WriteLine(" Nhan {0}: Xoa phan tu cuoi cung trong mang", (int)ThucDon.Xoa_Cuoi); Console.WriteLine(" Nhan {0}: Xoa phan tu x trong mang", (int)ThucDon.Xoa_x); Console.WriteLine(" Nhan {0}: Them mot so tai vi tri vt trong mang", (int)ThucDon.ThemTai_VT); Console.WriteLine(" Nhan {0}: Them phan tu dau tien trong mang", (int)ThucDon.Them_Dau); Console.WriteLine(" Nhan {0}: Them phan tu cuoi cung trong mang", (int)ThucDon.Them_Cuoi); Console.WriteLine(" Nhan {0}: Xoa tat ca so am trong mang", (int)ThucDon.Xoa_Am); Console.WriteLine(" Nhan {0}: Xoa tat ca so duong trong mang", (int)ThucDon.Xoa_Duong); Console.WriteLine(" Nhan {0}: Dem so phan tu am trong mang", (int)ThucDon.Dem_Am); Console.WriteLine(" Nhan {0}: Dem so phan tu duong trong mang", (int)ThucDon.Dem_Duong); Console.WriteLine(" Nhan {0}: Tim cac phan tu co gia tri la x trong mang.", (int)ThucDon.Tim_x); Console.WriteLine("".PadRight(78, '*')); Console.Write(" Nhap so thu tu chuc nang: "); ThucDon td = (ThucDon)int.Parse(Console.ReadLine()); Console.Clear(); switch (td) { case ThucDon.Thoat: Console.WriteLine("0.Thoat khoi chuong trinh"); Console.ReadKey(); return; case ThucDon.NhapThuCong: Console.WriteLine("1.Nhap thu cong"); NhapThuCong(a, ref length); SapXepTang(a, length); Xuat(a, length); break; case ThucDon.NhapTuDong: Console.WriteLine("2.Nhap tu dong"); NhapTD(a, ref length); SapXepTang(a, length); Xuat(a, length); break; case ThucDon.TimAm_Max: Console.WriteLine("3.Tim so am lon nhat"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); max = TimMaxAm(a, length); if (max == 0) { Console.WriteLine("\nKhong co gia tri am!"); } else { Console.WriteLine("\nGia tri am lon nhat " + max); } break; case ThucDon.TimAm_Min: Console.WriteLine("4.Tim so am nho nhat"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); min = TimMinAm(a, length); if (min == 0) { Console.WriteLine("\nKhong co gia tri am!"); } else { Console.WriteLine("\nGia tri am nho nhat " + min); } break; case ThucDon.TimDuong_Max: Console.WriteLine("5.Tim so duong lon nhat"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); max = TimMaxDuong(a, length); if (max == 0) { Console.WriteLine("\nKhong co gia tri duong!"); } else { Console.WriteLine("\nGia tri duong lon nhat " + max); } break; case ThucDon.TimDuong_Min: Console.WriteLine("6.Tim so duong nho nhat"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); min = TimMinDuong(a, length); if (min == 0) { Console.WriteLine("\nKhong co gia tri duong!"); } else { Console.WriteLine("\nGia tri duong nho nhat " + min); } break; case ThucDon.TimAm: Console.WriteLine("7.Tim tat ca cac so am trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); mkq = TimTatCaSoAm(a, length, ref nkq); if (nkq == 0) { Console.WriteLine("\nKhong co gia tri am!"); } else { Console.WriteLine("\nKet qua:"); Xuat(mkq, nkq); } break; case ThucDon.TimDuong: Console.WriteLine("8.Tim tat ca cac so duong trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); mkq = TimTatCaSoDuong(a, length, ref nkq); if (nkq == 0) { Console.WriteLine("\nKhong co gia tri duong!"); } else { Console.WriteLine("\nKet qua:"); Xuat(mkq, nkq); } break; case ThucDon.TongAm: Console.WriteLine("9.Tong tat ca cac so am trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); mkq = TimTatCaSoAm(a, length, ref nkq); if (nkq == 0) { Console.WriteLine("\nKhong co gia tri am!"); } else { Console.WriteLine("\nDanh sach cac so am trong mang"); Xuat(mkq, nkq); Console.WriteLine("\nKet qua: {0}", Tong(mkq, nkq)); } break; case ThucDon.TongDuong: Console.WriteLine("10.Tong cac so duong trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); mkq = TimTatCaSoDuong(a, length, ref nkq); if (nkq == 0) { Console.WriteLine("\nKhong co gia tri duong!"); } else { Console.WriteLine("\nDanh sach cac so duong trong mang"); Xuat(mkq, nkq); Console.WriteLine("\nKet qua: {0}", Tong(mkq, nkq)); } break; case ThucDon.XoaTai_VT: Console.WriteLine("11.Xoa mot so tai vi tri vt trong mang"); Xuat(a, length); Console.Write("\nNhap vi tri can xoa: "); vt = int.Parse(Console.ReadLine()); kq = Xoa_TaiVT(a, ref length, vt); if (kq) { Console.WriteLine("\nMang sau khi xoa : "); Xuat(a, length); } else { Console.WriteLine("\nBan nhap vi tri khong dung!"); } break; case ThucDon.Xoa_Dau: Console.WriteLine("12.Xoa phan tu dau tien trong mang"); Xuat(a, length); Console.WriteLine("\nMang sau khi xoa : "); Xoa_Dau(a, ref length); Xuat(a, length); break; case ThucDon.Xoa_Cuoi: Console.WriteLine("13.Xoa phan tu cuoi cung trong mang"); Xuat(a, length); Console.WriteLine("\nMang sau khi xoa : "); Xoa_Cuoi(a, ref length); Xuat(a, length); break; case ThucDon.Xoa_x: Console.WriteLine("14.Xoa phan tu x trong mang"); Xuat(a, length); Console.Write("\nNhap phan tu x can xoa: "); x = int.Parse(Console.ReadLine()); if (Tim_X(a, x) == -1) { Console.WriteLine("\nPhan tu x khong co trong mang"); } else { Xoa_X(a, ref length, x); Console.WriteLine("\nMang sau khi xoa : "); Xuat(a, length); } break; case ThucDon.ThemTai_VT: Console.WriteLine("15.Them mot so tai vi tri vt trong mang"); Xuat(a, length); Console.Write("\nNhap vi tri can chen: "); vt = int.Parse(Console.ReadLine()); Console.Write("\nNhap gia tri can chen: "); x = int.Parse(Console.ReadLine()); kq = Chen_TaiVT(a, ref length, x, vt); if (kq == true) { Xuat(a, length); } else { Console.WriteLine("\nBan nhap vi tri khong dung!"); } break; case ThucDon.Them_Dau: Console.WriteLine("16.Them phan tu dau tien trong mang"); Console.Write("\nNhap gia tri can chen: "); x = int.Parse(Console.ReadLine()); Console.WriteLine("\nMang ban dau : "); Xuat(a, length); Console.WriteLine("\nMang sau khi chen : "); ChenDau(a, ref length, x); Xuat(a, length); break; case ThucDon.Them_Cuoi: Console.WriteLine("17.Them phan tu cuoi cung trong mang"); Console.Write("\nNhap gia tri can chen: "); x = int.Parse(Console.ReadLine()); Console.WriteLine("\nMang ban dau : "); Xuat(a, length); ChenCuoi(a, ref length, x); Console.WriteLine("\nMang sau khi chen : "); Xuat(a, length); break; case ThucDon.Xoa_Am: Console.WriteLine("18.Xoa tat ca so am trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); Xoa_SoAm(a, ref length); Console.WriteLine("\nMang sau khi xoa: "); Xuat(a, length); break; case ThucDon.Xoa_Duong: Console.WriteLine("19.Xoa tat ca so duong trong mang"); Console.WriteLine("\nMang ban dau: "); Xuat(a, length); Xoa_SoDuong(a, ref length); Console.WriteLine("\nMang sau khi xoa: "); Xuat(a, length); break; case ThucDon.Dem_Am: Console.WriteLine("20.Dem so phan tu am trong mang"); Console.WriteLine("\nXem lai mang: "); Xuat(a, length); Console.WriteLine("\nMang tren co {0} so am", Dem_SoAm(a, length)); break; case ThucDon.Dem_Duong: Console.WriteLine("21.Dem so phan tu duong trong mang"); Console.WriteLine("\nXem lai mang: "); Xuat(a, length); Console.WriteLine("\nMang tren co {0} so duong", Dem_SoDuong(a, length)); break; case ThucDon.Tim_x: Console.WriteLine("22.Tim cac phan tu co gia tri la x trong mang."); Console.WriteLine("\nXem lai mang: "); Xuat(a, length); Console.Write("\nNhap phan tu X = "); x = int.Parse(Console.ReadLine()); Console.WriteLine("\nCo {0} so bang X", Dem_X(a, length, x)); break; default: break; } Console.ReadKey(); Xoa_Het(mkq, ref nkq); } }
private void BtnAccept_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Do you want to change present??", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { try { string productName = cbbName.Text; string menuName = txbName.Text; var menu = db.ThucDons.Where(s => s.TenThucDon == menuName && s.IsDeleted == false).SingleOrDefault(); var product = db.MonAns.Where(s => s.TenMonAn == productName).SingleOrDefault(); if (SelectedProductMenu == null) { if (menu == null) { ThucDon newMenu = new ThucDon { TenThucDon = menuName, IsDeleted = false }; db.ThucDons.Add(newMenu); db.SaveChanges(); var findNewMenuID = db.ThucDons.FirstOrDefault(s => s.TenThucDon == menuName); int menuId = findNewMenuID.ThucDonID; int productId = product.MonAnID; ThucDon_MonAn newProductMenu = new ThucDon_MonAn { ThucDonID = findNewMenuID.ThucDonID, MonAnID = product.MonAnID }; db.ThucDon_MonAn.Add(newProductMenu); db.SaveChanges(); } else if (menu != null) { var menuProduct = db.ThucDon_MonAn.Where(s => s.MonAnID == product.MonAnID && s.ThucDonID == menu.ThucDonID).SingleOrDefault(); if (menuProduct == null) { ThucDon_MonAn newProductMenu = new ThucDon_MonAn { ThucDonID = menu.ThucDonID, MonAnID = product.MonAnID }; db.ThucDon_MonAn.Add(newProductMenu); db.SaveChanges(); } else { MessageBox.Show("This Menu Already Has This Product"); return; } } } else { var findMenu = db.ThucDons.Where(s => s.ThucDonID == SelectedProductMenu.ThucDonID && s.IsDeleted == false).FirstOrDefault(); if (menu == null) { findMenu.TenThucDon = menuName; db.SaveChanges(); } else { MessageBox.Show("Menu name exsited"); return; } } db.SaveChanges(); MainWindow mainWindow = new MainWindow(EmployeeId); this.Close(); mainWindow.ShowDialog(); } catch { MessageBox.Show("Fail"); } } }
// find all child of parent private void soLuongCom_SelectionChanged(object sender, SelectionChangedEventArgs e) { //init_monandachon(); double kaloFollow; ComboBox combo = sender as ComboBox; // cho lan chay dau tien, khi tag chua duoc binding if (combo.Tag == null) { return; } // lay tag của nhóm int checkTag = (int)combo.Tag; // lấy số lượng chọn int soluong = Int32.Parse((combo.SelectedItem as ComboBoxItem).Content.ToString()); // thay doi phan tu o list ThucDon td = monanChonList.Find(r => r.IdMonAn == checkTag); if (td == null) { td = new ThucDon(); } td.SoLuong = soluong; var lstText = AllChildren(combo.Parent).OfType <TextBlock>(); // truong hop check box chua duoc check if (((combo.Parent as StackPanel).Parent as CheckBox).IsChecked == false) { foreach (var item in lstText) { if ((item as TextBlock).Name.Equals("kaloBlock")) { // lay luong kalo cua mon an tu list; double kaloBD = monAnList.Find(r => r.IdMonAn == checkTag).LuongKaloTrenDonVi; // nhan voi so luong kaloFollow = kaloBD * soluong; // roi day ra man hinh (item as TextBlock).Text = kaloFollow.ToString(); } } } // truong hop check box da duoc check else { foreach (var item in lstText) { if ((item as TextBlock).Name.Equals("kaloBlock")) { // phai tru di luong ban dau TongLuongKalo -= Double.Parse((item as TextBlock).Text); // lay luong kalo cua mon an tu list; double kaloBD = monAnList.Find(r => r.IdMonAn == checkTag).LuongKaloTrenDonVi; // nhan voi so luong kaloFollow = kaloBD * soluong; td.LuongKalo = kaloFollow; // cong lai luong thay doi TongLuongKalo += kaloFollow; // roi day ra man hinh (item as TextBlock).Text = kaloFollow.ToString(); } } } }
private void btnLuu_Click(object sender, EventArgs e) { if (_key == 1) { #region Lưu nút thêm DialogResult dg = new DialogResult(); dg = XtraMessageBox.Show("Bạn có muốn thêm thực đơn không !", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dg == DialogResult.Yes) { try { if (tbMaThucDon.Text == "" || tbTenThucDon.Text == "" || tbDonViTinh.Text == "" || tbDonGia.Text == "") { XtraMessageBox.Show("Thiếu thông tin, vui lòng nhập đủ !"); } else { #region Chuỗi regex để kiểm tra string reMa = @"^[TD]+[0-9]{4}$"; Regex rgMa = new Regex(reMa); string reTen = @"^[A-ZAÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶEÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢUÚÙỦŨỤƯỨỪỬỮỰYÝỲỶỸỴ]+[a-zĐaáàảãạâấầẩẫậăắằẳẵặeéèẻẽẹêếềểễệiíìỉĩịoóòỏõọôốồổỗộơớờởỡợuúùủũụưứừửữựyýỳỷỹỵđ]+(\s+[A-ZAÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶEÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢUÚÙỦŨỤƯỨỪỬỮỰYÝỲỶỸỴĐ]+[a-zaáàảãạâấầẩẫậăắằẳẵặeéèẻẽẹêếềểễệiíìỉĩịoóòỏõọôốồổỗộơớờởỡợuúùủũụưứừửữựyýỳỷỹỵđ]+)+$"; Regex rgTen = new Regex(reTen); #endregion if (!rgMa.IsMatch(tbMaThucDon.Text)) { XtraMessageBox.Show("Mã thực đơn phải có kí tự TD ở đầu và gồm 6 kí tự , vui lòng nhập lại !"); } else { _tenLoaiTD = cbbLoaiThucDon.Text; //Thêm bảng thực đơn ThucDon td1 = new ThucDon(); td1.maThucDon = tbMaThucDon.Text.Trim(); td1.tenThucDon = tbTenThucDon.Text.Trim(); td1.donViTinh = tbDonViTinh.Text; td1.donGia = Convert.ToDecimal(tbDonGia.Text); td1.maLoaiThucDon = ltdbll.layMaLoaiThucDon(_tenLoaiTD); if (tdbll.themThucDon(td1)) { XtraMessageBox.Show("Thêm thành công !"); _key = 0; loadThucDonLenDtgv(); #region Chỉnh trạng thái control sau khi thêm thành công xoaAllTB(); panelQuanLyTD.Enabled = false; dataGridView1.Enabled = true; btnLuu.Enabled = false; btnHuy.Enabled = false; btnThem.Enabled = true; #endregion } else { XtraMessageBox.Show("Bị trùng mã thực đơn, vui lòng nhập mã khác !"); } } } } catch (Exception ex) { XtraMessageBox.Show("Lỗi: " + ex); } } else { dg = DialogResult.Cancel; } #endregion } else if (_key == 2) { #region Lưu nút sửa DialogResult dg = new DialogResult(); dg = XtraMessageBox.Show("Bạn có muốn thay đổi thông tin thực đơn này không !", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dg == DialogResult.Yes) { try { if (tbMaThucDon.Text == "" || tbTenThucDon.Text == "" || tbDonViTinh.Text == "" || tbDonGia.Text == "") { XtraMessageBox.Show("Thiếu thông tin, vui lòng nhập đủ !"); } else { //Chuỗi regex để kiểm tra string reMa = @"^[DT]+[0-9]{4}$"; Regex rgMa = new Regex(reMa); if (!rgMa.IsMatch(tbMaThucDon.Text)) { XtraMessageBox.Show("Mã thực đơn phải có kí tự TD ở đầu và gồm 6 kí tự , vui lòng nhập lại !"); } else { _maTD = tbMaThucDon.Text; _tenLoaiTD = cbbLoaiThucDon.Text; ////Sửa bảng thực đơn ThucDon td1 = new ThucDon(); td1.maThucDon = tbMaThucDon.Text.Trim(); td1.tenThucDon = tbTenThucDon.Text.Trim(); td1.donViTinh = tbDonViTinh.Text.Trim(); td1.donGia = Convert.ToDecimal(tbDonGia.Text); td1.maLoaiThucDon = ltdbll.layMaLoaiThucDon(_tenLoaiTD); if (tdbll.suaThucDon(td1, _maTD)) { XtraMessageBox.Show("Sửa thành công !"); _key = 0; loadThucDonLenDtgv(); #region Chỉnh trạng thái control sau khi sửa thành công btnThem.Enabled = true; btnLuu.Enabled = false; btnHuy.Enabled = false; #endregion } else { XtraMessageBox.Show("Bị trùng mã thực đơn, vui lòng nhập mã khác !"); } } } } catch (Exception ex) { XtraMessageBox.Show("Lỗi: " + ex); } } else { dg = DialogResult.Cancel; } #endregion } }
public bool Update(ThucDon model) { return(_res.Update(model)); }
public ActionResult Index(int mathucdon) { ThucDon td = qltc.ThucDons.FirstOrDefault(t => t.MaThucDon == mathucdon); return(View(td)); }
public bool insertThucDon(ThucDon thucdon) { return(ThucDonController.Instance.insertThucDon(thucdon)); }