public StockInViewModel StockById(string id) { var stockid = Convert.ToInt64(id); var stockInfo = new StockInViewModel(); using (_dbContext = new AccountdbContext()) { stockInfo = (from s in _dbContext.StockIn join v in _dbContext.Vendor on s.VendorId equals v.VendorId where s.IsActive.Equals(true) && s.StockId.Equals(stockid) select new StockInViewModel { id = s.StockId, loadName = s.LoadName, vendorId = s.VendorId, totalQuantity = s.Quantity, isActive = Convert.ToBoolean(s.IsActive), createdDate = s.CreatedDate, formattedCreatedDate = s.CreatedDate.HasValue ? s.CreatedDate.Value.ToString(_dateFormat) : "", formattedModifiedDate = s.UpdatedDate.HasValue ? s.UpdatedDate.Value.ToString(_dateFormat) : "", nickName = v.NickName, firstName = v.FirstName }).FirstOrDefault(); } return(stockInfo); }
//public bool IsRegNoExist(int companySl, string item) //{ // stockInModel.Type = "Buy"; // string query = "SELECT * FROM StockInOut WHERE Company='" + companySl + "' and Item='" + item + "' and Type='" + stockInModel.Type + "'"; // command = new SqlCommand(query, connection); // connection.Open(); // reader = command.ExecuteReader(); // bool isExist = reader.HasRows; // connection.Close(); // return isExist; //} //public int updateAvailableStock(StockInModel stockInModel) //{ // stockInModel.Type = "Buy"; // string query = "UPDATE StockInOut SET Quantity='" + stockInModel.Quantity + "' WHERE Company='" + stockInModel.CompanySl + "' and Item='" + stockInModel.Item + "' and Type='"+stockInModel.Type+"'"; // SqlCommand command = new SqlCommand(query, connection); // connection.Open(); // int rowAffect = command.ExecuteNonQuery(); // connection.Close(); // return rowAffect; //} public StockInViewModel GetQuantityByCompanyAndItem(StockInViewModel stockInViewModel) { stockInViewModel.Type = "Buy"; string query = "TotalStock"; command = new SqlCommand(query, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@item", stockInViewModel.ItemSl); connection.Open(); reader = command.ExecuteReader(); reader.Read(); stockInViewModel = null; if (reader.HasRows) { stockInViewModel = new StockInViewModel(); stockInViewModel.Quantity = Convert.ToInt32(reader["Quantity"]); } reader.Close(); connection.Close(); return(stockInViewModel); }
public ActionResult StockIn(StockInViewModel stockInViewModel) { if (ModelState.IsValid) { StockIn stockIn = Mapper.Map <StockIn>(stockInViewModel); db.StockIns.Add(stockIn); if (db.SaveChanges() > 0) { ModelState.Clear(); TempData["msg"] = "StockIn information has been successfully saved."; return(RedirectToAction("Index", "StockInDetails", new { area = "" })); } } var model = new StockInViewModel(); model.Categories = db.Categories.ToList(); model.Parties = _partyManager.PartyList(); ViewBag.ProductDropDown = new SelectList(new[] { new SelectListItem() { Value = "", Text = "Select Product" } }, "Value", "Text"); TempData["msg"] = "StockIn information has been failed to save!"; return(View(model)); }
public CommonResponseViewModel UpdateStock(StockInViewModel stockInVM) { CommonResponseViewModel response = new CommonResponseViewModel(); try { using (_dbContext = new AccountdbContext()) { var dbStockIn = _dbContext.StockIn.Where(s => s.StockId.Equals(stockInVM.id)).FirstOrDefault(); if (dbStockIn != null) { dbStockIn.Quantity = stockInVM.totalQuantity; dbStockIn.CreatedDate = stockInVM.createdDate.HasValue ? stockInVM.createdDate.Value : dbStockIn.CreatedDate; dbStockIn.UpdatedDate = DateTime.Now; _dbContext.StockIn.Update(dbStockIn); _dbContext.SaveChanges(); response.isSuccess = true; } } } catch (Exception ex) { throw ex; } return(response); }
private void ItemListByCompany(StockInViewModel stockInViewModel) { itemDropDownList.DataSource = stockInManager.GetAllItemByCompany(stockInViewModel); itemDropDownList.DataTextField = "ItemName"; itemDropDownList.DataValueField = "ItemSl"; itemDropDownList.DataBind(); itemDropDownList.Items.Insert(0, new ListItem("Select a Item")); }
//[HttpGet] public IActionResult StockIn() { StockInViewModel model = new StockInViewModel(); model.detailProductList = products; model.inList = inList; return(View(model)); }
private EfDbContext.StockIn ConstructStockInAddressAsPerContext(StockInViewModel item) { return(new EfDbContext.StockIn { VendorId = item.vendorId, LoadName = item.loadName, Quantity = item.totalQuantity, UpdatedDate = DateTime.Today, }); }
public int StockInCount(StockInViewModel stock) { var countOfRecords = 0; using (_dbContext = new AccountdbContext()) { countOfRecords = _dbContext.StockIn.Where(e => e.VendorId.Equals(stock.vendorId)).Count(); } return(countOfRecords); }
private void CompanyList(StockInViewModel stockInViewModel) { companyDropDownList.DataSource = stockInManager.GetAllItemCompany(); companyDropDownList.DataTextField = "CompanyName"; companyDropDownList.DataValueField = "CompanyId"; companyDropDownList.DataBind(); companyDropDownList.Items.Insert(0, new ListItem("Select a Company")); }
public CommonResponseViewModel SaveStock(StockInViewModel stockInVM) { if (stockInVM.id > 0) { return(_StockInRepository.UpdateStock(stockInVM)); } else { return(_StockInRepository.AddStock(stockInVM)); } }
private void GetReorderLevel(StockInViewModel stockInViewModel) { if (itemDropDownList.Text != "Select a Item") { stockInViewModel = stockInManager.GetReorderByItem(stockInViewModel); reorderTextBox.Text = stockInViewModel.ReorderLevel.ToString(); } else { reorderTextBox.Text = "0"; } }
public ActionResult StockIn() { var model = new StockInViewModel(); model.Categories = db.Categories.ToList(); model.Parties = _partyManager.PartyList(); ViewBag.ProductDropDown = new SelectList(new[] { new SelectListItem() { Value = "", Text = "Select Product" } }, "Value", "Text"); return(View(model)); }
private void GetQuantityByCompanyItem(StockInViewModel stockInViewModel) { stockInViewModel = stockInManager.GetQuantityByCompanyAndItem(stockInViewModel); //availableQuantityTextBox.Text = stockInModel.AvailableQuantity.ToString(); if (stockInViewModel == null) { availableQuantityTextBox.Text = "0"; } else { availableQuantityTextBox.Text = stockInViewModel.Quantity.ToString(); } }
public List <StockInViewModel> GetAllItemCompany() { string query = "SELECT * FROM CompanyInfo"; command = new SqlCommand(query, connection); connection.Open(); reader = command.ExecuteReader(); List <StockInViewModel> itemModelCompanyViewList = new List <StockInViewModel>(); while (reader.Read()) { StockInViewModel stockInViewModel = new StockInViewModel(); stockInViewModel.CompanyId = Convert.ToInt32(reader["Sl"]); stockInViewModel.CompanyName = reader["CompanyName"].ToString(); itemModelCompanyViewList.Add(stockInViewModel); } reader.Close(); connection.Close(); return(itemModelCompanyViewList); }
public StockInViewModel GetReorderByItem(StockInViewModel stockInViewModel) { string query = "SELECT * FROM ItemSetup WHERE Sl='" + stockInViewModel.ItemSl + "' and CompanyId='" + stockInViewModel.CompanyId + "'"; command = new SqlCommand(query, connection); connection.Open(); reader = command.ExecuteReader(); reader.Read(); stockInViewModel = null; if (reader.HasRows) { stockInViewModel = new StockInViewModel(); stockInViewModel.ReorderLevel = Convert.ToInt32(reader["ReorderLevel"]); } reader.Close(); connection.Close(); return(stockInViewModel); }
public List <StockInViewModel> GetAllItemByCompany(StockInViewModel stockInViewModel) { string query = "SELECT * FROM ItemSetup WHERE CompanyId='" + stockInViewModel.CompanyId + "'"; command = new SqlCommand(query, connection); connection.Open(); reader = command.ExecuteReader(); List <StockInViewModel> StockInModelViewList = new List <StockInViewModel>(); while (reader.Read()) { stockInViewModel = new StockInViewModel(); stockInViewModel.ItemName = reader["ItemName"].ToString(); stockInViewModel.ItemSl = Convert.ToInt32(reader["Sl"]); StockInModelViewList.Add(stockInViewModel); } reader.Close(); connection.Close(); return(StockInModelViewList); }
public CommonResponseViewModel AddStock(StockInViewModel stockInVM) { CommonResponseViewModel response = new CommonResponseViewModel(); try { using (_dbContext = new AccountdbContext()) { var dbStockIn = ConstructStockInAddressAsPerContext(stockInVM); dbStockIn.CreatedDate = stockInVM.createdDate.HasValue ? stockInVM.createdDate.Value : DateTime.Now; _dbContext.StockIn.Add(dbStockIn); _dbContext.SaveChanges(); response.recordId = dbStockIn.StockId; response.isSuccess = true; } } catch (Exception ex) { throw ex; } return(response); }
public StockInViewModel GetReorderByItem(StockInViewModel stockInModel) { return(stockInGateway.GetReorderByItem(stockInModel)); }
public int StockInCount(StockInViewModel stock) { return(_StockInRepository.StockInCount(stock)); }
public List <StockInViewModel> GetAllItemByCompany(StockInViewModel stockInViewModel) { return(stockInGateway.GetAllItemByCompany(stockInViewModel)); }
public StockInViewModel GetQuantityByCompanyAndItem(StockInViewModel stockInModel) { return(stockInGateway.GetQuantityByCompanyAndItem(stockInModel)); }