public static int CheckCode(ItemsDTO inputData) { DataTable tb = new DataTable(); int returnCode = 0; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (MySqlConnection con = new MySqlConnection(constr)) { using (MySqlCommand cmd = new MySqlCommand()) { string sql = @"SELECT Count(*) FROM product_item WHERE TRUE"; if (inputData.code.IsNotNullOrEmpty()) { sql += " AND `code` = @code "; cmd.Parameters.AddWithValue("@code", inputData.code); } con.Open(); cmd.Connection = con; cmd.CommandText = sql; returnCode = int.Parse(cmd.ExecuteScalar().ToString()); } } return(returnCode); }
protected void btnSearch_Click(object sender, EventArgs e) { ItemsDTO dto = new ItemsDTO(); conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); SqlConnection myConn = new SqlConnection(conn); myConn.Open(); string selectStatement = "Select itemID, customerID, barcode, itemType, description, model, issue, dateBookedIn from Items where (itemID="; selectStatement += dropDownIDs.SelectedValue + ")"; SqlCommand selectCmd = new SqlCommand(selectStatement, myConn); SqlDataReader myReader; myReader = selectCmd.ExecuteReader(); while (myReader.Read()) { if (myReader.GetString(0) == dropDownIDs.SelectedValue) { dto.itemID = myReader.GetString(0); dto.custID = myReader.GetString(1); dto.barcode = myReader.GetString(2); dto.itemType = myReader.GetString(3); dto.description = myReader.GetString(4); dto.model = myReader.GetString(5); dto.issue = myReader.GetString(6); dto.dateIn = myReader.GetString(7); break; } } myConn.Close(); Session["ItemDTO"] = dto; Server.Transfer("ItemsEdit2.aspx"); }
public ActionResult ItemUpdate(ItemsDTO model) { ViewData["tool"] = model.manufacture_tool.ToString().ToLower(); ViewData["make"] = model.manufacture_make.ToString().ToLower(); ViewData["dangerous"] = model.dangerous.ToString().ToLower(); ViewData["good"] = model.manufacture_finished_goods.ToString().ToLower(); if (ModelState.IsValid) { if (model.discontinued_datetime.IsNotNullOrEmpty()) { string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss"); model.discontinued_datetime = datetime; } model.updated_by = 65; ItemBL bl = new ItemBL(); int result = bl.UpdateData(model); if (result == 1) { TempData["Error"] = "Update badly"; TempData["Success"] = ""; return(View(model)); } else { TempData["Error"] = ""; TempData["Success"] = "Update successfully"; return(RedirectToAction("ItemUpdate")); } } else { return(View(model)); } }
public ActionResult <IEnumerable <string> > UpdateItem([FromBody] ItemsDTO pItem) { Items objItem = _mapper.Map <Items>(pItem); Items returnedItem = _Inventory.UpdateItem(objItem); return(Ok(returnedItem)); }
public ActionResult ItemUpdate(int id) { ModelState.Clear(); CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); ItemBL bl = new ItemBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); ItemsDTO dto = new ItemsDTO(); bl.SearchID(id, out dto); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ViewData["tool"] = dto.manufacture_tool.ToString().ToLower(); ViewData["make"] = dto.manufacture_make.ToString().ToLower(); ViewData["dangerous"] = dto.dangerous.ToString().ToLower(); ViewData["good"] = dto.manufacture_finished_goods.ToString().ToLower(); ViewData["category"] = dto.category_id; ViewData["inventorymeasure"] = dto.inventory_measure_id; ViewData["sizemeasure"] = dto.manufacture_size_measure_id; ViewData["weightmeasure"] = dto.manufacture_weight_measure_id; return(View(dto)); }
public ActionResult ItemDetele(int?id) { ItemBL bl = new ItemBL(); List <ItemsDTO> dtResult; ItemsDTO dto = new ItemsDTO(); dto.id = id; bl.SearchData(dto, out dtResult); if (dtResult.Count > 0) { int equal = bl.DeleteData(id); if (equal == 1) { TempData["Error"] = "Delete badly"; TempData["Success"] = ""; } else { TempData["Error"] = ""; TempData["Success"] = "Delete successfully"; } } else { Response.StatusCode = 404; return(null); } return(RedirectToAction("ItemSearch")); }
public ActionResult ItemSearch(ItemsDTO item) { ItemBL bl = new ItemBL(); ItemsList model = new ItemsList(); DataTable dt; bl.SearchData(item, out dt); model.Items = CommonMethod.DataTableToList <ItemsDTO>(dt); return(View(model)); }
private WorkItem FillWorkItem(ItemsDTO items) { return(new WorkItem { Title = items.Title, CreatedDate = items.CreatedDate, WorkItemType = items.WorkItemType, IdWorkItem = items.IdWorkItem.Value }); }
private void Include(ItemsDTO items) { using (var db = new AzWorkItemContext()) { var newWorkItem = FillWorkItem(items); db.WorkItems.Add(newWorkItem); db.SaveChanges(); } }
public static int UpdateData(ItemsDTO dto) { int returnCode = 0; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (MySqlConnection connect = new MySqlConnection(constr)) { { using (MySqlCommand command = new MySqlCommand( @"Update product_item Set `name` = @name, `specification` = @specification, `description` = @description, `category_id` = @category_id, `discontinued_datetime` = @discontinued_datetime, `dangerous` = @dangerous, `inventory_measure_id` = @inventory_measure_id, `inventory_expired` = @inventory_expired, `inventory_standard_cost` = @inventory_standard_cost, `inventory_list_price` = @inventory_list_price, `manufacture_day` = @manufacture_day, `manufacture_make` = @manufacture_make, `manufacture_tool` = @manufacture_tool, `manufacture_finished_goods` = @manufacture_finished_goods, `manufacture_size` = @manufacture_size, `manufacture_size_measure_id` = @manufacture_size_measure_id, `manufacture_weight` = @manufacture_weight, `manufacture_weight_measure_id` = @manufacture_weight_measure_id, `manufacture_style` = @manufacture_style, `manufacture_class` = @manufacture_class, `manufacture_color` = @manufacture_color, `updated_datetime` = SYSDATE(), `updated_by` = @updated_by Where `id` = @ID", connect)) { command.Parameters.AddWithValue("@name", dto.name); command.Parameters.AddWithValue("@specification", dto.specification); command.Parameters.AddWithValue("@description", dto.description); command.Parameters.AddWithValue("@category_id", dto.category_id); command.Parameters.AddWithValue("@discontinued_datetime", dto.discontinued_datetime); command.Parameters.AddWithValue("@dangerous", dto.dangerous); command.Parameters.AddWithValue("@inventory_measure_id", dto.inventory_measure_id); command.Parameters.AddWithValue("@inventory_expired", dto.inventory_expired); command.Parameters.AddWithValue("@inventory_standard_cost", dto.inventory_standard_cost); command.Parameters.AddWithValue("@inventory_list_price", dto.inventory_list_price); command.Parameters.AddWithValue("@manufacture_day", dto.manufacture_day); command.Parameters.AddWithValue("@manufacture_make", dto.manufacture_make); command.Parameters.AddWithValue("@manufacture_tool", dto.manufacture_tool); command.Parameters.AddWithValue("@manufacture_finished_goods", dto.manufacture_finished_goods); command.Parameters.AddWithValue("@manufacture_size", dto.manufacture_size); command.Parameters.AddWithValue("@manufacture_size_measure_id", dto.manufacture_size_measure_id); command.Parameters.AddWithValue("@manufacture_weight", dto.manufacture_weight); command.Parameters.AddWithValue("@manufacture_weight_measure_id", dto.manufacture_weight_measure_id); command.Parameters.AddWithValue("@manufacture_style", dto.manufacture_style); command.Parameters.AddWithValue("@manufacture_class", dto.manufacture_class); command.Parameters.AddWithValue("@manufacture_color", dto.manufacture_color); command.Parameters.AddWithValue("@updated_by", dto.updated_by); command.Parameters.AddWithValue("@ID", dto.id); connect.Open(); command.ExecuteNonQuery(); } } } return(returnCode); }
protected void btnSubmit_Click(object sender, EventArgs e) { ItemsDTO dto = (ItemsDTO)Session["ItemsDTO"]; ModelFacade facade = new ModelFacade(); Items item = facade.createItem(dto); ItemsDAO dao = new ItemsDAO(); dao.bookInItem(item); Session.Abandon(); Response.Redirect("~/Staff/AdminHome.aspx"); }
public ActionResult DeclineRequest(int reqId, int itemId) { ItemsDTO dto = db.Items.Find(itemId); RequestsDTO dto2 = db.Requests.Find(reqId); db.Items.Remove(dto); db.Requests.Remove(dto2); db.SaveChanges(); return(RedirectToAction("Index")); }
private void Edit(ItemsDTO items) { using (var db = new AzWorkItemContext()) { var workItemOriginal = db.WorkItems.FirstOrDefault(w => w.Id == items.Id); workItemOriginal.WorkItemType = items.WorkItemType; workItemOriginal.Title = items.Title; workItemOriginal.CreatedDate = items.CreatedDate; db.SaveChanges(); } }
public ItemsVM(ItemsDTO item) { Id = item.Id; Title = item.Title; Description = item.Description; Price = item.Price; CategoryId = item.CategoryId; CategoryName = item.CategoryName; Score = item.Score; Status = false; Image = item.Image; }
public ActionResult ItemAdd(ItemsDTO model) { CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ItemBL bl = new ItemBL(); if (ModelState.IsValid) { int count = bl.CheckCode(model); if (count > 0) { TempData["Error"] = "Code already exists"; TempData["Success"] = ""; return(View(model)); } else { if (model.discontinued_datetime.IsNotNullOrEmpty() == true) { string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss"); model.discontinued_datetime = datetime; } model.created_by = 0; model.updated_by = 0; int equal = bl.InsertData(model); if (equal == 1) { TempData["Error"] = "Insert badly"; TempData["Success"] = ""; return(View(model)); } else { TempData["Error"] = ""; TempData["Success"] = "Insert successfully"; return(RedirectToAction("ItemAdd")); } } } else { return(View(model)); } }
public ActionResult AddToCartPartial(int id) { List <CartVM> cart = Session["cart"] as List <CartVM> ?? new List <CartVM>(); CartVM model = new CartVM(); //check item is in the cart using (Db db = new Db()) { ItemsDTO item = db.Items.Find(id); var itemInCart = cart.FirstOrDefault(x => x.ItemID == id); //if not, add a new one if (itemInCart == null) { cart.Add(new CartVM() { ItemID = item.Id, ItemName = item.Title, Quantity = 1, Price = item.Price, Image = item.Image }); } //if it is, increment quantity else { itemInCart.Quantity++; } } //get grand quantity and price and add to model int qty = 0; decimal price = 0m; foreach (var item in cart) { qty += item.Quantity; price += item.Quantity * item.Price; } model.Quantity = qty; model.Price = price; //Save cart to session Session["cart"] = cart; return(PartialView(model)); }
public Items createItem(ItemsDTO dto) { Items item = new Items(); item.itemID = dto.itemID; item.custID = dto.custID; item.barcode = dto.barcode; item.itemType = dto.itemType; item.description = dto.description; item.model = dto.model; item.issue = dto.issue; item.dateIn = dto.dateIn; item.dateOut = dto.dateOut; return(item); }
public ActionResult DeleteItem(int id) { using (Db db = new Db()) { ItemsDTO dto = db.Items.Find(id); //remove the item db.Items.Remove(dto); db.SaveChanges(); TempData["Status"] = "Item deleted! <3"; return(RedirectToAction("Items")); } }
public ActionResult ItemAdd() { CategoryBL catelogy = new CategoryBL(); MeasureBL measure = new MeasureBL(); DataTable catelogydt; DataTable measuredt; catelogy.SearchList(out catelogydt); measure.SearchList(out measuredt); ViewBag.CatelogyList = CommonMethod.DataTableToList <CategoryDTO>(catelogydt); ViewBag.MeasureList = CommonMethod.DataTableToList <MeasureDTO>(measuredt); ItemsDTO model = new ItemsDTO(); return(View(model)); }
private void getSessionData() { ItemsDTO dto = (ItemsDTO)Session["ItemDTO"]; ModelFacade facade = new ModelFacade(); Items item = facade.createItem(dto); lblItemID.Text = item.itemID; lblCustID.Text = item.custID; lblBarcode.Text = item.barcode; lblItemType.Text = item.itemType; lblDescription.Text = item.description; lblModel.Text = item.model; lblIssue.Text = item.issue; lblDateIn.Text = item.dateIn; }
public ActionResult ItemDeleteMulti(FormCollection frm) { string[] ids = frm["ItemID"].Split(new char[] { ',' }); ItemBL bl = new ItemBL(); ItemsDTO dtResult; foreach (string item in ids) { ItemsDTO dto = new ItemsDTO(); int id = item.ParseInt32(); int equal = bl.SearchID(id, out dtResult); if (dtResult != null) { bl.DeleteData(id); } } return(RedirectToAction("ItemSearch")); }
public async Task <ItemsDTO <Order> > GetOrdersGridRowsInMemory(Action <IGridColumnCollection <Order> > columns, QueryDictionary <StringValues> query) { /** * var server = new GridServer<Order>(await GetAll(), new QueryCollection(query), true, "ordersGrid", columns) * .Sortable() * .WithPaging(10) * .Filterable() * .WithMultipleFilters() * .Groupable(true) * .Searchable(true, false, false); * * // return items to displays * var items = server.ItemsToDisplay; */ var items = new ItemsDTO <Order>(); return(items); }
public List <int> LoadItemIds(string region, string version) { List <int> itemIds = null; bool rateLimitHit = true; while (rateLimitHit) { string resource = "/static-data/" + region + "/v1.2/item/"; string rawResponse = ""; Dictionary <string, string> queryParams = new Dictionary <string, string>(); queryParams["version"] = version; _apiConnection.Get <RiotRestAPI.ItemsDTO>(resource, queryParams, ref rateLimitHit, ref rawResponse); // Use JSON.NET serializer for this, because DataSerializer doesn't get the dictionary right ItemsDTO items = JsonConvert.DeserializeObject <ItemsDTO>(rawResponse); if (items != null) { LogManager.LogMessage("Loaded items for " + region + "-" + version + " from the API."); itemIds = new List <int>(); foreach (string itemId in items.Items.Keys) { itemIds.Add(Convert.ToInt32(itemId)); } itemIds.Sort(); } else if (rateLimitHit) { LogManager.LogMessage("Hit rate limit. Waiting to retry."); System.Threading.Thread.Sleep(RATE_LIMIT_WAIT_IN_MS); } else { LogManager.LogMessage("Unable to load item list for " + region + "-" + version); } } return(itemIds); }
public ActionResult ItemSearch(string Page, ItemsSearch model) { ItemsDTO dto = new ItemsDTO(); ModelState.Clear(); if (!string.IsNullOrEmpty(model.SearchButton) || Page.IsNotNullOrEmpty()) { if (Page != null) { dto.page = int.Parse(Page); model.Page = dto.page; } ItemBL bl = new ItemBL(); List <ItemsDTO> result = new List <ItemsDTO>(); if (model.ItemName.IsNotNullOrEmpty()) { dto.name = model.ItemName; } if (model.ItemCode.IsNotNullOrEmpty()) { dto.code = model.ItemCode; } if (model.Category.HasValue) { dto.category_id = model.Category; } bl.SearchData(dto, out result); model.PageCount = bl.CountPage(dto); model.SearchResults = new StaticPagedList <ItemsDTO>(result, model.Page, 20, model.PageCount); } CategoryBL category = new CategoryBL(); List <CategoryDTO> categorydt; category.SearchList(out categorydt); CategoryDTO cate = new CategoryDTO(); categorydt.Add(cate); ViewBag.CategoryList = categorydt; return(View(model)); }
public ActionResult EditItem(int id) { ItemsVM item; using (Db db = new Db()) { ItemsDTO dto = db.Items.Find(id); if (dto == null) { return(Content("The item doesn't exist")); } item = new ItemsVM(dto); List <CategoryVM> categories; item.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); } return(View(item)); }
public static int CountPage(ItemsDTO inputData) { DataTable tb = new DataTable(); int returnCode = 0; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (MySqlConnection con = new MySqlConnection(constr)) { using (MySqlCommand cmd = new MySqlCommand()) { string sql = @"SELECT Count(*) FROM product_item WHERE TRUE"; if (inputData.id.HasValue) { sql += " AND `id` = @ID "; cmd.Parameters.AddWithValue("@ID", inputData.id); } if (inputData.code.IsNotNullOrEmpty()) { sql += " AND `code` LIKE CONCAT('%',@code,'%') "; cmd.Parameters.AddWithValue("@code", inputData.code); } if (inputData.name.IsNotNullOrEmpty()) { sql += " AND `name` LIKE CONCAT('%',@name,'%') "; cmd.Parameters.AddWithValue("@name", inputData.name); } if (inputData.category_id.HasValue) { sql += " AND `category_id` = @category "; cmd.Parameters.AddWithValue("@category", inputData.category_id); } con.Open(); cmd.Connection = con; cmd.CommandText = sql; returnCode = int.Parse(cmd.ExecuteScalar().ToString()); } } return(returnCode); }
public ActionResult AcceptRequest(int reqId, int itemId) { ItemsVM item; ItemsDTO dto = db.Items.Find(itemId); RequestsDTO dto2 = db.Requests.Find(reqId); if (dto == null) { return(Content("The item doesn t exist anymore :(")); } //set status to true => the item will be visible db.Items.Attach(dto); db.Entry(dto).Property(x => x.Status).IsModified = true; db.SaveChanges(); //remove the request db.Requests.Remove(dto2); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> PostItem(Items item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Items.Add(item); await db.SaveChangesAsync(); var dto = new ItemsDTO() { Id = item.Id, Title = item.Title, Description = item.Description, Date = item.Date, Status = item.Status, Hours = item.Hours, Minute = item.Minute }; return(CreatedAtRoute("DefaultApi", new { id = item.Id }, dto)); }
public static int SearchData(ItemsDTO inputData, out DataTable dt) { dt = new DataTable(); int returnCode = 0; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (MySqlConnection con = new MySqlConnection(constr)) { using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM product_item WHERE TRUE ", con)) { using (MySqlDataAdapter sda = new MySqlDataAdapter()) { sda.SelectCommand = cmd; sda.Fill(dt); if (dt.Rows.Count == 0) { returnCode = 1; } } } } return(returnCode); }
public ActionResult EditItem(ItemsVM item, HttpPostedFileBase file) { using (Db db = new Db()) { item.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); } if (!ModelState.IsValid) { return(View(item)); } //unique name using (Db db = new Db()) { if (db.Items.Where(x => x.Id != item.Id).Any(x => x.Title == item.Title)) { ModelState.AddModelError("", "That item name is already taken! :("); return(View(item)); } } using (Db db = new Db()) { ItemsDTO dto = db.Items.Find(item.Id); dto.Id = item.Id; dto.Title = item.Title; dto.Description = item.Description; dto.Price = item.Price; dto.Image = item.Image; int id = dto.Id; var directory = new DirectoryInfo(string.Format("{0}Images\\Uploads", Server.MapPath(@"\"))); var path1 = Path.Combine(directory.ToString(), "Items"); var path2 = Path.Combine(directory.ToString(), "Items" + id.ToString()); if (!Directory.Exists(path1)) { Directory.CreateDirectory(path1); } if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } if (file != null && file.ContentLength > 0) { string extension = file.ContentType.ToLower(); if (extension != "image/jpg" && extension != "image/jpeg" && extension != "image/png") { item.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); ModelState.AddModelError("", "The image was not uploaded - wrong image extension."); return(View(item)); } string imageName = file.FileName; ItemsDTO dto1 = db.Items.Find(id); dto1.Image = imageName; db.SaveChanges(); file.SaveAs(string.Format("{0}\\{1}", path2, imageName)); WebImage img = new WebImage(file.InputStream); img.Resize(200, 200); img.Save(path2, "png", true); } CategoriesDTO catDto = db.Categories.FirstOrDefault(x => x.Id == item.CategoryId); dto.CategoryName = catDto.Name; db.SaveChanges(); TempData["Status"] = "Item edited! <3"; } return(RedirectToAction("Items")); }