public ActionResult Services(string userUID) { if (!String.IsNullOrEmpty(userUID)) { userUID = userUID.Trim(); Database db = new Database(); CustomerDAO cDAO = new CustomerDAO(db); CustomerModel cModel = cDAO.FindByUid(userUID); db.Close(); /// ถ้ามีข้อมูลให้เก็บไว้ที่ วิวดาต้าเพื่อนำไปแสดง <-- james if (cModel != null) { ViewData["CUST"] = cModel; db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); List <ProductTypeModel> listPTModel = ptDAO.FindAll(); db.Close(); ViewData["PROTYPE"] = listPTModel; } else { ViewData["CUST"] = null; } } return(View()); }
// GET: Admin/Products public ActionResult Index(int page = 1, int pageSize = 5) { var sessionLogin = SessionHelper.GetSessionLogin(); if (sessionLogin == null)//ERROR: != { //load product type dropdownlist ProductTypeDAO typeDao = new ProductTypeDAO(); var productTypes = typeDao.GetSelectLists(); ViewBag.productTypes = productTypes; //load list products var products = Session["productsShowing"] as List <Product>; if (products == null) { ProductDAO proDao = new ProductDAO(); products = proDao.GetProducts(); } return(View(products.ToPagedList(page, pageSize))); } else { return(RedirectToAction("Login", "User")); } }
// GET: Admin/Products/Create public ActionResult Create() { ProductTypeDAO typeDAO = new ProductTypeDAO(); var types = typeDAO.GetSelectLists(); Session["types"] = types; return(View()); }
public async Task <bool> Delete(ProductType ProductType) { ProductTypeDAO ProductTypeDAO = await DataContext.ProductType.Where(x => x.Id == ProductType.Id).FirstOrDefaultAsync(); DataContext.ProductType.Remove(ProductTypeDAO); await DataContext.SaveChangesAsync(); return(true); }
public JsonResult ProductTypeName_DataLoading(int proTypeID) { Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); ProductTypeModel ptModel = ptDAO.FindById(proTypeID); db.Close(); return(Json(new { typeName = ptModel.PRO_TYPE_NAME, typeID = ptModel.PRO_TYP_ID })); }
public ActionResult ProductTypeManagement() { Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); List <ProductTypeModel> ptModel = ptDAO.FindAll(); db.Close(); ViewBag.ProductType = ptModel; return(View()); }
public static LOAISP_DTO LayLoaiSanPhamTheoMaLoaiSP(int malsp) { try { return(ProductTypeDAO.LayLoaiSanPhamTheoMaLoaiSP(malsp)); } catch (Exception ex) { throw ex; } }
public async Task <bool> Update(ProductType ProductType) { ProductTypeDAO ProductTypeDAO = DataContext.ProductType.Where(x => x.Id == ProductType.Id).FirstOrDefault(); ProductTypeDAO.Id = ProductType.Id; ProductTypeDAO.Code = ProductType.Code; ProductTypeDAO.Name = ProductType.Name; await DataContext.SaveChangesAsync(); return(true); }
public static List <LOAISP_DTO> SelectingAllProductType() { try { return(ProductTypeDAO.SelectingAllProductType()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <LOAISP_DTO> SelectingAllProductTypeByGroup(int maNhomLoaiSanPham) { try { return(ProductTypeDAO.SelectingAllProductTypeByGroup(maNhomLoaiSanPham)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult ManageProduct() { Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); List <ProductTypeModel> lisPTModel = ptDAO.FindAll(); db.Close(); ViewData["PRODUCT_TYPE"] = lisPTModel; return(View()); }
public async Task <bool> Create(ProductType ProductType) { ProductTypeDAO ProductTypeDAO = new ProductTypeDAO(); ProductTypeDAO.Id = ProductType.Id; ProductTypeDAO.Code = ProductType.Code; ProductTypeDAO.Name = ProductType.Name; await DataContext.ProductType.AddAsync(ProductTypeDAO); await DataContext.SaveChangesAsync(); ProductType.Id = ProductTypeDAO.Id; return(true); }
public ActionResult ProductTypeUpdating(int proType_id, string proType_name) { ProductTypeModel ptModel = new ProductTypeModel(); ptModel.PRO_TYP_ID = proType_id; ptModel.PRO_TYPE_NAME = proType_name; Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); ptDAO.Update(ptModel); db.Close(); return(Redirect("~/Product/ProductTypeManagement")); }
// GET: Admin/Products/Edit/5 public ActionResult Edit(int id) { ProductTypeDAO typeDAO = new ProductTypeDAO(); ProductDAO proDAO = new ProductDAO(); Product product = proDAO.GetProductByID(id); Session["product"] = product; var types = typeDAO.GetSelectLists(product.productTypeId.GetValueOrDefault()); Session["types"] = types; return(View()); }
public ActionResult ProductTypeDeleting(int typeID) { try { ProductTypeModel ptModel = new ProductTypeModel(); ptModel.PRO_TYP_ID = typeID; Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); ptDAO.Delete(ptModel); db.Close(); return(Redirect("~/Product/ProductTypeManagement")); } catch { return(RedirectToAction("alert", "Product", new { link = "ProductTypeManagement", massage = "มีรายการที่อ้างถึงข้อมูลนี้อยู่ ไม่สามารถลบได้" })); } }
private async Task Sync(DataContext context, string json) { List <EventMessage <ProductType> > EventMessageReceived = JsonConvert.DeserializeObject <List <EventMessage <ProductType> > >(json); await SaveEventMessage(context, SyncKey, EventMessageReceived); List <Guid> RowIds = EventMessageReceived.Select(a => a.RowId).Distinct().ToList(); List <EventMessage <ProductType> > ProductTypeEventMessages = await ListEventMessage <ProductType>(context, SyncKey, RowIds); List <ProductType> ProductTypes = ProductTypeEventMessages.Select(x => x.Content).ToList(); List <ProductTypeDAO> ProductTypeInDB = await context.ProductType.ToListAsync(); try { List <ProductTypeDAO> ProductTypeDAOs = new List <ProductTypeDAO>(); foreach (var ProductType in ProductTypes) { ProductTypeDAO ProductTypeDAO = ProductTypeInDB.Where(x => x.Id == ProductType.Id).FirstOrDefault(); if (ProductTypeDAO == null) { ProductTypeDAO = new ProductTypeDAO(); } ProductTypeDAO.Id = ProductType.Id; ProductTypeDAO.CreatedAt = ProductType.CreatedAt; ProductTypeDAO.UpdatedAt = ProductType.UpdatedAt; ProductTypeDAO.DeletedAt = ProductType.DeletedAt; ProductTypeDAO.Id = ProductType.Id; ProductTypeDAO.Code = ProductType.Code; ProductTypeDAO.Name = ProductType.Name; ProductTypeDAO.StatusId = ProductType.StatusId; ProductTypeDAO.Description = ProductType.Description; ProductTypeDAO.Used = ProductType.Used; ProductTypeDAO.RowId = ProductType.RowId; ProductTypeDAOs.Add(ProductTypeDAO); } await context.BulkMergeAsync(ProductTypeDAOs); } catch (Exception ex) { Log(ex, nameof(ProductTypeHandler)); } }
public ActionResult EditRepair() { int repairID = Int32.Parse(Request.Params["repID"]); // ค้นข้อมูลของรายการซ่อมเพื่อแก้ไข Database db = new Database(); RepairDAO rDAO = new RepairDAO(db); RepairModel lsRModel = rDAO.FindById(repairID); db.Close(); ViewData["REPAIR"] = lsRModel; // รายการประเภทสินค้า db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); List <ProductTypeModel> lPTModel = ptDAO.FindAll(); db.Close(); ViewData["PRODUCTTYPE"] = lPTModel; // รายการยี่ห้อสินค้า db = new Database(); ProductDAO pDAO = new ProductDAO(db); List <ProductModel> pModel = pDAO.FindByTypeID(lsRModel.PRODUCT.TYPE.PRO_TYP_ID); db.Close(); ViewData["BRAND"] = pModel; //รายการผู้รับผิดชอบ db = new Database(); UsersDAO uDAO = new UsersDAO(db); List <UsersModel> uModel = uDAO.FindAll(); db.Close(); ViewData["STAFF"] = uModel; return(View()); }
public ActionResult AddProductType() { string proTypeName = Request.Params["protype_name"].Trim(); ProductTypeModel ptModel = new ProductTypeModel(); ptModel.PRO_TYPE_NAME = proTypeName; Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); int id = ptDAO.Add(ptModel); db.Close(); System.Diagnostics.Debug.WriteLine("LAST ID PRODUCT_TYPE : " + id); if (id > 0) { return(RedirectToAction("Alert", "Product", new { link = "~/Product/ManageProduct", massage = "เพิ่มข้อมูลเรียบร้อย" })); } else { return(RedirectToAction("ManageProduct", "Product")); } }
public static List <ProductType> ProductTypeValues() => ProductTypeDAO.SubProductsTypeValues();
public static ProductType TypeById(string id) => ProductTypeDAO.TypeById("select * from tb_tipo_produto where cd_tipo_produto ='" + id + "'");
public ActionResult Show(FormCollection form, int page = 1, int pageSize = 5) { ProductTypeDAO typeDao = new ProductTypeDAO(); var productTypes = typeDao.GetSelectLists(); ViewBag.productTypes = productTypes; //create search by multiple condition SearchModel searchModel = new SearchModel(); //typeID condition bool check = int.TryParse(form["ddlType"], out int typeID); //Response.Write("<script>alert('"+check.ToString()+"');</script>"); if (check) { searchModel.typeId = typeID; } //key words condition string keyWords = form["textSearch"].Trim(); if (!string.IsNullOrEmpty(keyWords)) { searchModel.keyWords = keyWords; } //prices condition string indexPrice = form["ddlPrice"]; switch (indexPrice) { case "1": searchModel.fromNumber = 0; searchModel.toNumber = 500000; break; case "2": searchModel.fromNumber = 500000; searchModel.toNumber = 1000000; break; case "3": searchModel.fromNumber = 1000000; searchModel.toNumber = 1500000; break; case "4": searchModel.fromNumber = 1500000; searchModel.toNumber = 200000; break; case "5": searchModel.fromNumber = 200000; searchModel.toNumber = 200000000; break; default: break; } //search ProductDAO pDao = new ProductDAO(); var searchResult = pDao.Search(searchModel); return(View("~/Areas/Admin/Views/Products/Index.cshtml", searchResult.ToPagedList(page, pageSize))); }
private void GetTypeProduct(string ProductTypeID) { var dao = new ProductTypeDAO(); ViewBag.ListTypeProduct = new SelectList(dao.ListAll(), "ProductTypeID", "ProductTypeName", ProductTypeID); }