public LOAI GetDVByMa(string pTen) { LOAI result = new LOAI(); result = context.LOAI.FirstOrDefault(m => m.TenLoai == pTen); return(result); }
public LOAI GetDVByMa(int?pMa) { LOAI result = new LOAI(); result = context.LOAI.FirstOrDefault(m => m.MaLoai == pMa); return(result); }
public ActionResult SelectFood() { LOAI se_loai = new LOAI(); se_loai.listLoai = _db.LOAIs.ToList <LOAI>(); return(PartialView(se_loai)); }
public int Add(LOAI p) { int result = 0; context.LOAI.Add(p); result = context.SaveChanges(); return(result); }
public ActionResult DeleteConfirmed(string id) { LOAI lOAI = db.LOAIs.Find(id); db.LOAIs.Remove(lOAI); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool delete(LOAI entity) { if (admin.phanquyen) { return(loairepository.Delete(entity)); } return(false); }
public bool update(LOAI entity) { if (validate(entity)) { return(loairepository.Attach(entity)); } return(false); }
public bool add(LOAI entity) { if (validate(entity)) { return(loairepository.Add(entity)); } return(false); }
public int Delete(int pMa) { int result = 0; LOAI k = context.LOAI.FirstOrDefault(m => m.MaLoai == pMa); context.LOAI.Remove(k); result = context.SaveChanges(); return(result); }
public ActionResult Edit([Bind(Include = "MaLoai,TenLoai")] LOAI lOAI) { if (ModelState.IsValid) { db.Entry(lOAI).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lOAI)); }
public ActionResult Create([Bind(Include = "MaLoai,TenLoai")] LOAI lOAI) { if (ModelState.IsValid) { db.LOAIs.Add(lOAI); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lOAI)); }
public int Update(LOAI pma) { int result = 0; LOAI k = context.LOAI.FirstOrDefault(m => m.MaLoai == pma.MaLoai); if (k != null) { k.TenLoai = pma.TenLoai; } result = context.SaveChanges(); return(result); }
public ActionResult CapNhatLoaiHoa(LOAI loai) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } if (ModelState.IsValid) { UpdateModel(loai); db.SubmitChanges(); } return(RedirectToAction("QLLoaiHoa")); }
// GET: QuanLyLoai/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LOAI lOAI = db.LOAIs.Find(id); if (lOAI == null) { return(HttpNotFound()); } return(View(lOAI)); }
public ActionResult ThemLoaiHoa(LOAI loai) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } if (ModelState.IsValid) { db.LOAIs.InsertOnSubmit(loai); db.SubmitChanges(); } // Lưu vào cơ sở dữ liệu return(RedirectToAction("QLLoaiHoa", "HomeAdmin")); }
public ActionResult Create(LOAI loai) { try { // TODO: Add insert logic here _db.LOAIs.Add(loai); _db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult CapNhatLoaiHoa(int id) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } LOAI loai = db.LOAIs.SingleOrDefault(n => n.MALOAI == id); if (loai == null) { Response.StatusCode = 404; return(null); } return(View(loai)); }
public void add(LoaiSachFrm f) { LOAI ls = new LOAI(); if (f.tenLoaiTxt.Text == "") { MessageBox.Show("Tên loại không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ls.TenLoai = f.tenLoaiTxt.Text; db.database().LOAIs.InsertOnSubmit(ls); db.database().SubmitChanges(); loadAllData(f); } }
//xóa loại sản phẩm private void xoaloai(object sender, EventArgs args) { LOAI entity = new LOAI(); entity.MALOAI = loaidgv.SelectedCells[0].Value.ToString(); loaibus bus = new loaibus(); bool delete = bus.delete(entity); common.successorerror(delete); if (delete) { loaidgv.DataSource = bus.list(); } else { } }
public ActionResult XacNhanLoaiHoa(int id) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } LOAI loai = db.LOAIs.SingleOrDefault(n => n.MALOAI == id); ViewBag.MALOAI = loai.MALOAI; if (loai == null) { Response.StatusCode = 404; return(null); } db.LOAIs.DeleteOnSubmit(loai); db.SubmitChanges(); return(RedirectToAction("QLLoaiHoa")); }
//thêm vào loại sản phẩm private void button2_Click(object sender, EventArgs e) { LOAI entity = new LOAI(); entity.MALOAI = maloaitxt.Text; entity.TENLOAI = tenloaitxt.Text; loaibus bus = new loaibus(); bool success = bus.add(entity); if (success) { loaidgv.DataSource = bus.find(entity.MALOAI); } else { ViewErrors(bus.validatedictionary); } }
public JsonResult Save(int id, string flag, string value) { if (flag == "mau") { MAU mau = _connect.MAUs.SingleOrDefault(p => p.ID == id); mau.MAUSP = value; } if (flag == "hang") { HANG hang = _connect.HANGs.SingleOrDefault(p => p.ID == id); hang.HANGSX = value; } if (flag == "loai") { LOAI loai = _connect.LOAIs.SingleOrDefault(p => p.ID == id); loai.LOAISP = value; } _connect.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); }
public bool validate(LOAI entity) { if (entity.MALOAI.Trim().Length == 0 || Regex.IsMatch(entity.MALOAI, @"[^a-zA-Z0-9]")) { validatedictionary.Add("MALOAI", "Không được để trống mã loại"); } else if (ktidtontai(entity.MALOAI)) { validatedictionary.Add("MALOAI", "Mã loại trùng"); } if (entity.TENLOAI.Trim().Length == 0) { validatedictionary.Add("TENLOAI", "Không được để trống tên loại"); } if (validatedictionary.Count() <= 0) { return(true); } return(false); }
//button sửa loại sản phẩm private void button17_Click(object sender, EventArgs e) { button17.Enabled = false; LOAI entity = new LOAI(); entity.TENLOAI = tenloaitxt.Text; entity.MALOAI = maloailbl.Text; loaibus bus = new loaibus(); bool update = bus.update(entity); common.successorerror(update); if (update) { loaidgv.DataSource = bus.find(loaidgv.SelectedCells[0].Value.ToString()); maloailbl.Visible = false; maloaitxt.Visible = true; tenloaitxt.Clear(); } else { } }
public JsonResult Delete(int id, string flag) { if (flag == "mau") { MAU mau = _connect.MAUs.SingleOrDefault(p => p.ID == id); _connect.MAUs.Remove(mau); } if (flag == "hang") { HANG hang = _connect.HANGs.SingleOrDefault(p => p.ID == id); _connect.HANGs.Remove(hang); } if (flag == "loai") { LOAI loai = _connect.LOAIs.SingleOrDefault(p => p.ID == id); _connect.LOAIs.Remove(loai); } _connect.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); }
public JsonResult Add(string flag, string value) { if (flag == "mau") { MAU mau = new MAU(); mau.MAUSP = value; _connect.MAUs.Add(mau); } if (flag == "hang") { HANG hang = new HANG(); hang.HANGSX = value; _connect.HANGs.Add(hang); } if (flag == "loai") { LOAI loai = new LOAI(); loai.LOAISP = value; _connect.LOAIs.Add(loai); } _connect.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); }
private void btnNhapHD_Click(object sender, RoutedEventArgs e) {// xử lý btn nhập ErrorNotice.Visibility = Visibility.Hidden; int checkCategory; int checkProduct; string maloai = txtBoxMaLoai.Text; string tenloai = txtBoxLoaiSP.Text; string tensp = txtBoxTenSP.Text; string masp = txtBoxMaSP.Text; int soluong = 0; double dongia, tienxuat; // Kiểm tra nhà cung cấp if (txtBoxNCC.Text == null || txtBoxNCC.Text == "") { ErrorNotice.Content = "*Thông tin nhà cung cấp không phù hợp"; ErrorNotice.Visibility = Visibility.Visible; return; } // Kiểm tra số lượng if (int.TryParse(txtBoxSoLuong.Text, out soluong) == false) { ErrorNotice.Content = "*Định dạng số lượng không phù hợp"; ErrorNotice.Visibility = Visibility.Visible; return; } // Kiêm tra đợn giá và tiền xuất if (double.TryParse(txtBoxDonGia.Text, out dongia) == false) { ErrorNotice.Content = "*Thông tin đơn giá không phù hợp"; ErrorNotice.Visibility = Visibility.Visible; return; } tienxuat = dongia * soluong; txtBoxThanhTien.Text = tienxuat.ToString(); // Kiểm tra và cập nhật mã loại if (txtBoxMaSP.Text == null || txtBoxMaSP.Text == "" || txtBoxTenSP.Text == null || txtBoxTenSP.Text == "" || txtBoxMaLoai.Text == null || txtBoxMaLoai.Text == "" || txtBoxLoaiSP.Text == null || txtBoxLoaiSP.Text == "") { ErrorNotice.Content = "*Định dạng thông tin sản phẩm không phù hợp"; ErrorNotice.Visibility = Visibility.Visible; return; } else { checkCategory = checkLoai(maloai, tenloai); // kiểm tra loại if (checkCategory == 1) { // nếu loại mới TruongHop = 1; // loại mới, sản phẩm mới newCategory = new LOAI() { MaLoai = txtBoxMaLoai.Text, TenLoai = txtBoxLoaiSP.Text, }; // Tiếp tục kiểm tra và nạp thêm vào sản phẩm checkProduct = checkSP(masp, tensp); if (checkProduct == 1) { newProduct = new SANPHAM() { MaSP = masp, TenSP = tensp, MaLoai = maloai, SoLuong = soluong, DonGia = dongia, NgayNhap = ngayNhap, TinhTrang = true, NhaCungCap = txtBoxNCC.Text, }; } else {// trường hợp còn lại ErrorNotice.Content = "*Một sản phẩm không thể có thuộc nhiều loại"; ErrorNotice.Visibility = Visibility.Visible; return; } } else if (checkCategory == 0) {// bổ sung loại cũ checkProduct = checkSP(masp, tensp); if (checkProduct == 1) {// sản phẩm mới TruongHop = 2; newProduct = new SANPHAM() { MaSP = masp, TenSP = tensp, MaLoai = maloai, SoLuong = soluong, DonGia = dongia, NgayNhap = ngayNhap, TinhTrang = true, NhaCungCap = txtBoxNCC.Text, }; } else if (checkProduct == 0) {// bổ sung sản phẩm cũ TruongHop = 3; // Cập nhật vào CSDL } else { ErrorNotice.Content = "*Không tồn tại sản phẩm hợp với mã này"; ErrorNotice.Visibility = Visibility.Visible; return; } } else { ErrorNotice.Content = "*Tên loại và mã loại không phù hợp"; ErrorNotice.Visibility = Visibility.Visible; return; } } // Sau khi kiểm tra thành công hết thì tạo hóa đợn newImport = new NHAPHANG() { MaSP = masp, MaLoai = maloai, SoLuong = soluong, DonGia = dongia, NgayNhap = ngayNhap, TienTra = tienxuat, NhaCungCap = txtBoxNCC.Text, GhiChu = txtBoxGhiChu.Text, }; // Kết thúc quá trình làm hóa đơn, hiển thị cho người quản lý xem Man_che.Visibility = Visibility.Visible; btnNhapHD.Visibility = Visibility.Hidden; lblHeader.Content = "XEM LẠI HÓA ĐƠN"; }
public loaidto(LOAI entity) { maloai = entity.MALOAI; tenloai = entity.TENLOAI; }
// GET: NhanVien/LoaiMon/Create public ActionResult Create() { LOAI loai = new LOAI(); return(View(loai)); }