public async Task <ActionResult> Receiver(string id) { Guid out_id = Guid.Parse(id); Guid business_working = Guid.Parse(Session["BusinessWorking"].ToString()); StockOut stockOut = await applicationDbContext.StockOuts.Include("Product").Include("Product.Category").FirstOrDefaultAsync(x => x.Id == out_id); if (stockOut != null) { stockOut.Receiver_Id = User.Identity.GetUserId(); applicationDbContext.Entry(stockOut).State = System.Data.Entity.EntityState.Modified; BusinessUser businessUser = await applicationDbContext.BusinessUsers.FirstOrDefaultAsync(x => x.User_Id == stockOut.Receiver_Id && x.Business_Id == business_working); if (stockOut.Product.Category.ActionOut == ActionConstants.Sum) { businessUser.Cash += stockOut.SalePrice * stockOut.Quantity; } else if (stockOut.Product.Category.ActionOut == ActionConstants.Rest) { businessUser.Cash -= stockOut.SalePrice * stockOut.Quantity; } applicationDbContext.Entry(businessUser).State = System.Data.Entity.EntityState.Modified; await applicationDbContext.SaveChangesAsync(); await ActivityPublisher.Publish(User.Identity.GetUserId(), ActivityTypeConstants.Stock_Out_Receive, stockOut.Id, stockOut.Product.Name, business_working); } return(Json(true)); }
public Item GetFieldData(StockOut stockOut) { Item item = new Item(); dataTable = new DataTable(); try { conn = new SqlConnection(dbConn); string query = @"SELECT ReorderLevel, AvailableQuantity FROM Item WHERE ID = '" + stockOut.ItemID + "'"; cmd = new SqlCommand(query, conn); conn.Open(); dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { item.ReorderLevel += Convert.ToDecimal(dataReader["ReorderLevel"]); item.AvailableQuantity += Convert.ToDecimal(dataReader["AvailableQuantity"]); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(item); }
public int SaveStockOut(StockOut stockOut) { string query = "INSERT INTO StockOut (BranchId, EmployeeId, SaleDate, StockQuantity, ItemId, SalesTransactionId) " + "VALUES(@branchId, @employeeId, @saleDate, @stockQuantity, @itemId, @salesTransactionId)"; var salesTransactionId = GetSalesTransactionId(stockOut.SalesTransaction); Gateway gateway = new Gateway(query); int rowAffected = -1; foreach (Item anItem in stockOut.Items) { gateway.SqlCommand.Parameters.Clear(); gateway.SqlCommand.Parameters.AddWithValue("@branchId", stockOut.BranchId); gateway.SqlCommand.Parameters.AddWithValue("@employeeId", stockOut.EmployeeId); gateway.SqlCommand.Parameters.AddWithValue("@saleDate", stockOut.SaleDate); gateway.SqlCommand.Parameters.AddWithValue("@stockQuantity", anItem.Quantity); gateway.SqlCommand.Parameters.AddWithValue("@itemId", anItem.ItemId); gateway.SqlCommand.Parameters.AddWithValue("@salesTransactionId", salesTransactionId); rowAffected = gateway.SqlCommand.ExecuteNonQuery(); if (rowAffected <= 0) { gateway.Connection.Close(); return(rowAffected); } } gateway.Connection.Close(); return(rowAffected); }
public string SaveLostItem(StockOut aStockOut) { string Message = ""; if (aStockOut.AvailableQuentity > aStockOut.StockOutQuentity) { aStockOut.TotalQuentity = aStockOut.AvailableQuentity - aStockOut.StockOutQuentity; int row = aStockOutGateway.UpdateItem(aStockOut); int row1 = aStockOutGateway.SaveLostItem(aStockOut); if (row > 0 && row1 > 0) { Message = "Product Stock Out Successfully."; } else { Message = " failed."; } } else { Message = "Item Not available"; } return(Message); }
public ActionResult Save_Update(StockOut stockOut) { if (Session["OutList"] == null) { List <StockOut> s = new List <StockOut>(); //stockOut.ItemId = iId; //stockOut.Quantity = quantity; //stockOut.OutAction = oAction; stockOut.ItemName = ItemManager.GetItemName(stockOut.ItemId); stockOut.CompanyName = CompanyManager.GetCompanyName(stockOut.ItemId); s.Add(stockOut); Session["OutList"] = s; } else { stockOut.ItemName = ItemManager.GetItemName(stockOut.ItemId); stockOut.CompanyName = CompanyManager.GetCompanyName(stockOut.ItemId); var userList = (List <StockOut>)Session["OutList"]; userList.Add(stockOut); Session["OutList"] = userList; } ViewBag.companyList = CompanyManager.GetAllCompanys(); return(View()); }
public void CreateViewState() { int quantity = Convert.ToInt32(quantityTextBox.Text); int stockOutAmount = Convert.ToInt32(stockOutQantityTextBox.Text); if (quantity > stockOutAmount) { StockOut stockOut = new StockOut(); stockOut.ItemId = Convert.ToInt32(itemDropDownList.SelectedValue); stockOut.ItemName = itemDropDownList.SelectedItem.Text; stockOut.CompanyName = companyDropDownList.SelectedItem.Text; stockOut.Quantity = Convert.ToInt32(stockOutQantityTextBox.Text); stockOut.AvailableQuantity = Convert.ToInt32(quantityTextBox.Text) - stockOut.Quantity; List <StockOut> stockOutList = new List <StockOut>(); stockOutList.Add(stockOut); ViewState["gridVS"] = stockOutList; stockOutGridView.DataSource = stockOutList; stockOutGridView.DataBind(); outputLabel.Text = ""; } else { outputLabel.Text = "Quantity out-of-range"; outputLabel.ForeColor = Color.Red; } }
public ItemSummaryUi() { InitializeComponent(); itemSummary = new ItemSummary(); stockIn = new StockIn(); stockOut = new StockOut(); }
public Item GetFieldData(StockOut stockOut) { Item item = new Item(); item = _stockOutRepository.GetFieldData(stockOut); return(item); }
public DataTable DateWiseSearch(StockOut stockOut) { DataTable dt = new DataTable(); dt = _stockOutRepository.DateWiseSearch(stockOut); return(dt); }
public ActionResult Save(string InvoiceNo, string Notes, List <StockOut> stockOuts) { StockOut result = new StockOut(); StockOut FinalResult = new StockOut(); //if (ModelState.IsValid) { foreach (var item in stockOuts) { result.InvoiceNo = InvoiceNo; result.Notes = Notes; result.IsActive = true; result.CreatedDate = DateTime.Now; result.ProductionDate = DateTime.Now; result.CreatedBy = CurrentSession.GetCurrentSession().UserName; result.ProductId = item.ProductId; result.BaleWeight = item.BaleWeight; result.WarehouseId = item.WarehouseId; result.SupplierId = item.SupplierId; result.BaleQty = item.BaleQty; result.WeightInMon = item.WeightInMon; FinalResult = service.Save(result); } } return(Json(FinalResult, JsonRequestBehavior.AllowGet)); }
public List <StockOut> SalesStockOutsReport(string startDate, string endDate) { SqlConnection connection = new SqlConnection(connectionString); // query = "SELECT Item.ItemName,StockReport.ItemId,SUM(Quantity) AS TOTAL FROM StockReport ,Item WHERE StockReport.Date BETWEEN '"+startDate+"' AND '"+endDate+"' AND status='Sold' AND Item.ItemId=StockReport.ItemId GROUP BY StockReport.ItemId,Item.itemName "; query = "select itemName ,sum(Quantity) as total from StockreportView where date between @startDate AND @endDate group by ItemName"; connection.Open(); command = new SqlCommand(query, connection); command.Parameters.Clear(); command.Parameters.AddWithValue("startDate", startDate); command.Parameters.AddWithValue("endDate", endDate); reader = command.ExecuteReader(); List <StockOut> items = new List <StockOut>(); while (reader.Read()) { StockOut aItem = new StockOut(); aItem.ItemName = reader["ItemName"].ToString(); aItem.Quantity = Convert.ToInt32(reader["total"]); items.Add(aItem); } reader.Close(); connection.Close(); return(items); }
public string StockOutUpdate(StockOut stock) { Item item = new Item(); item = stockOutGateway.GetItemInfo(stock.ItemName); stock.ItemId = item.Sl; stock.CompanyId = item.CompanyName; int available = item.AvailableQuantity; available = available - stock.StockOutQuantity; item.AvailableQuantity = available; int rowAffect = stockOutGateway.StockOutSave(stock); stockOutGateway.StockUpdate(available, item.Sl); if (available > 0) { return("Stock Update"); } else { return("Stock Update Failed"); } }
public List <int> SaveStockOut(StockOut stockOut) { Query = "INSERT INTO StockSetup (CompanyId, Id, StockOutQuantity) VALUES(@CompanyId, @Id, @StockOutQuantity)"; Command = new SqlCommand(Query, Connection); Command.Parameters.Clear(); Command.Parameters.AddWithValue("CompanyId", stockOut.CompanyId); Command.Parameters.AddWithValue("Id", stockOut.ItemId); Command.Parameters.AddWithValue("StockInQuantity", stockOut.StockOutQuantity); Connection.Open(); int rowAffectedInSaveStockOut = Command.ExecuteNonQuery(); Connection.Close(); Query = "UPDATE ItemSetup SET Available = " + (stockOut.Available - stockOut.StockOutQuantity) + " WHERE Id = " + stockOut.ItemId; Command = new SqlCommand(Query, Connection); Connection.Open(); int rowAffectedInItemSetup = Command.ExecuteNonQuery(); Connection.Close(); return(new List <int>() { rowAffectedInSaveStockOut, rowAffectedInItemSetup }); }
protected void btnAdd_Click(object sender, EventArgs e) { if (ViewState["stockOuts"] == null) { ViewState["stockOuts"] = stockOutList; } stockOutList = (List <StockOut>)ViewState["stockOuts"]; string companyName = ddlCompany.SelectedItem.Text; string productName = ddlItem.SelectedItem.Text; int productId = Convert.ToInt32(ddlItem.SelectedValue); double stockOutQuantity = Convert.ToDouble(inputStockOutQuantity.Value); StockOut stockOut = new StockOut(); stockOut.Item = productName; stockOut.Company = companyName; stockOut.Quantity = stockOutQuantity; stockOut.Reason = ""; stockOut.Date = DateTime.Now; stockOutList.Add(stockOut); ViewState["stockOuts"] = stockOutList; gridStockOut.DataSource = ViewState["stockOuts"]; gridStockOut.DataBind(); btnSell.Visible = true; btnDamage.Visible = true; btnLost.Visible = true; }
private string SaveByMethod(string method) { if (ViewState["itemVS"] == null) { return("Please add some item."); } else { itemViewModels = (List <ItemView>)ViewState["itemVS"]; foreach (ItemView itemView in itemViewModels) { StockOut stockOut = new StockOut(); stockOut.ItemId = itemView.ItemId; stockOut.Quantity = itemView.Quantity; stockOut.Type = method; stockOut.Date = DateTime.Today; stockOutManager.Save(stockOut); stockInManager.Update(stockOut.ItemId, stockOut.Quantity); } stockOutGridView.DataSource = null; stockOutGridView.DataBind(); return("Saved into " + method); } }
public string StockOutInfo(StockOut stockOutObj) { string stockOutInfo = ""; if (stockOutObj.Item == "" || stockOutObj.Category == "" || stockOutObj.Company == "" || stockOutObj.StockOutQuantity == 0) { stockOutInfo = "Item,Category & Company should not be null"; } if (stockOutObj.StockOutQuantity == 0) { stockOutInfo = "Please select amount to stockout"; } if (stockOutObj.StockOutQuantity > stockOutObj.AvailableQuantity) { stockOutInfo = "There is no sufficient amount. You stock out maximum : " + stockOutObj.AvailableQuantity; } //StockOutRipository stcOutRipoObj=new StockOutRipository(); //stcOutRipoObj.StockOutInfo(stockOutObj); return(stockOutInfo); }
public List <StockOut> StockFindByDate(string fromDate, string toDate) { string query = "SELECT ItemId,SUM(Quantity) AS Total FROM StockOut WHERE Date BETWEEN @from AND @to AND OutAction='Sell' GROUP BY ItemId"; Command = new SqlCommand(query, Connection); Command.Parameters.AddWithValue("@from", fromDate); Command.Parameters.AddWithValue("@to", toDate); Connection.Open(); Reader = Command.ExecuteReader(); List <StockOut> stockOutList = new List <StockOut>(); while (Reader.Read()) { StockOut aStockOut = new StockOut(); aStockOut.ItemId = Convert.ToInt32(Reader["ItemId"]); aStockOut.ItemName = aItemGateway.GetItemNameById(aStockOut.ItemId); aStockOut.CompanyName = aItemGateway.GetCompanyNameByItemId(aStockOut.ItemId); aStockOut.Quantity = Convert.ToInt32(Reader["Total"]); stockOutList.Add(aStockOut); } Reader.Close(); Connection.Close(); return(stockOutList); }
public string StockOutUpdate(StockOut stock) { Item model = new Item(); model = stockIOutGateway.GetItemInfo(stock.ItemName); stock.ItemId = model.Sl; stock.CompanyId = model.CompanyName; int available = model.AvailableQuantity; available = available - stock.StockOutQuantity; model.AvailableQuantity = available; int rowAffect = stockIOutGateway.StockOutSave(stock); stockIOutGateway.StockUpdate(available, model.Sl); if (rowAffect > 0) { return("Stock Update"); } else { return("! Faild"); } }
public string StockOut(string type) { DateTime date = DateTime.Today; StockOut stockOut = new StockOut(); StockIn stockIn = new StockIn(); for (int i = 0; i < stockOutGridView.Rows.Count; i++) { HiddenField hiddenField = stockOutGridView.Rows[i].FindControl("HiddenField1") as HiddenField; Label quantityLabel = stockOutGridView.Rows[i].FindControl("ItemQuantity") as Label; stockOut.ItemId = Convert.ToInt32(hiddenField.Value); stockOut.StockOutQuantity = Convert.ToInt32(quantityLabel.Text); stockOut.Date = date; stockOut.Type = type; stockOutManager.SaveStockOut(stockOut); stockIn.ItemId = Convert.ToInt32(hiddenField.Value); int realQuantity = stockInManager.GetAvailableQuantity(stockIn.ItemId); if (realQuantity >= Convert.ToInt32(quantityLabel.Text)) { stockIn.AvailableQuantity = realQuantity - Convert.ToInt32(quantityLabel.Text); } else { errorMessegeLabel.Text = "Insufficient stock"; } stockInManager.SaveStockIn(stockIn); } return(type); }
private string SaveByMethod(string method) { if (ViewState["itemVS"] == null) { GetCompany(); return("Please add some item."); } else { ItemViewModels = (List <ItemViewModel>)ViewState["itemVS"]; foreach (ItemViewModel itemView in ItemViewModels) { StockOut stockOut = new StockOut(); stockOut.ItemId = itemView.ItemId; stockOut.Quantity = itemView.Quantity; stockOut.Method = method; stockOut.Date = DateTime.Today; StockOutManager.Save(stockOut); StockOutManager.Update(stockOut.ItemId, stockOut.Quantity); } ViewState.Clear(); GetCompany(); return("Saved Into " + method); } }
public bool SaveStockOut(StockOut aStockOut) { if (aStockOutGateway.SaveStockOut(aStockOut) > 0) { return(true); } return(false); }
public ActionResult DeleteConfirmed(int id) { StockOut stockOut = db.StockOut.Find(id); db.StockOut.Remove(stockOut); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnLưu_Click(object sender, EventArgs e) { if (txtMaPX.Text == "" || txtTenNguoiNhan.Text == "" || txtCMND.Text == "") { MessageBox.Show("Vui lòng điền đủ thông tin phiên xuất kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //luu thong tin phien vao stockout, cap nhat trang thai barcode thanh false(da xuat kho), luu thong tin bang stockoutdetail //luu thong tin phien vao stockout StockOut so = new StockOut(); so.StockOutCode = txtMaPX.Text; so.UserID = txtUser.Text; so.DateOut = DateTime.Parse(dateNgayPX.EditValue.ToString()); so.RecipientName = txtTenNguoiNhan.Text; so.IDCard = txtCMND.Text; so.Company = txtCongTy.Text; so.TotalWeight = double.Parse(txtTongTrongLuong.Text); so.Quantity = Int32.Parse(txtSoLuong.Text); so.Note = txtGhiChu.Text; //Kiem tra trung stockoutcode StockOut var = (from s in dc.StockOuts where s.StockOutCode == so.StockOutCode select s).FirstOrDefault(); if (var == null) { dc.StockOuts.InsertOnSubmit(so); dc.SubmitChanges(); } else { MessageBox.Show("Mã phiên xuất kho bị trùng lặp", "Thông báo", MessageBoxButtons.OK); } //cập nhật trang thai barcode thanh false (da xuat kho) for (int i = 0; i < gridViewBarcode.RowCount; i++) { BarcodeDetail bd = (from c in dc.BarcodeDetails where c.Barcode == gridViewBarcode.GetRowCellValue(i, "Barcode").ToString() select c).FirstOrDefault(); if (bd != null) { bd.Status = false; dc.SubmitChanges(); } } //luu thong tin stockout detail for (int i = 0; i < gridViewBarcode.RowCount; i++) { StockOutDetail sod = new StockOutDetail(); sod.StockOutCode = txtMaPX.Text; sod.Barcode = gridViewBarcode.GetRowCellValue(i, "Barcode").ToString(); dc.StockOutDetails.InsertOnSubmit(sod); dc.SubmitChanges(); } MessageBox.Show("Lưu phiên xuất kho thành công", "Thông báo", MessageBoxButtons.OK); } }
//确定 private void okBtn_Click(object sender, EventArgs e) { if (!validateTextFields()) { return; } StockOut outStock = new StockOut(); outStock.name = name.Text; outStock.amount = Convert.ToInt32(amount.Text); outStock.stockId = db.Stock.FirstOrDefault(x => x.name == stock.Text).id; if (toStock.Text != "") { outStock.toStockId = db.Stock.FirstOrDefault(x => x.name == toStock.Text).id; } outStock.note = note.Text; outStock.date = BathClass.Now(LogIn.connectionString); outStock.receiver = receiver.Text; outStock.transactor = transactor.Text; outStock.checker = checker.Text; db.StockOut.InsertOnSubmit(outStock); //bool newSList = false; //var storage = db.StorageList.FirstOrDefault(x => x.name == name.Text && x.stockId == outStock.stockId); //var toStorage = db.StorageList.FirstOrDefault(x => x.name == name.Text && x.stockId == outStock.toStockId); //if (storage == null) //{ // newSList = true; // storage = new StorageList(); //} //bool newToSList = false; //if (toStorage == null) //{ // newToSList = true; // toStorage = new StorageList(); //} //storage.name = name.Text; //storage.amountThisMonth = MConvert<int>.ToTypeOrDefault(storage.amountThisMonth) - outStock.amount; //storage.stockId = outStock.stockId; //if (newSList) // db.StorageList.InsertOnSubmit(storage); //toStorage.name = name.Text; //toStorage.amountThisMonth = MConvert<int>.ToTypeOrDefault(toStorage.amountThisMonth) + outStock.amount; //toStorage.stockId = outStock.toStockId; //if (newToSList) // db.StorageList.InsertOnSubmit(toStorage); db.SubmitChanges(); this.DialogResult = DialogResult.OK; this.Close(); }
public ActionResult Edit([Bind(Include = "Id,Description,StockOutDate")] StockOut stockOut) { if (ModelState.IsValid) { db.Entry(stockOut).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stockOut)); }
public void SellStockOut(StockOut aStockOut) { aStockOutGateway.SellStockOut(aStockOut); //int rowAffected = aStockOutGateway.SellStockOut(aStockOut); //if (rowAffected > 0) //{ // return "Save Successfull."; //} //return "Save Failed."; }
public string AddStockOut(StockOut stockOut) { int rowAffected = stockOutGateway.AddStockOut(stockOut); if (rowAffected > 0) { return("StockOut successfully"); } return("StockOut failed"); }
//构造函数 public StockOutForm(BathDBDataContext dc, StockOut _stockout) { db = dc; if (_stockout != null) { newStockout = false; stockout = _stockout; } InitializeComponent(); }
// add data on a list for temporaray table public void AddStockListForTemporaryTable(Items item, int companyId, int itemId, int stockOutQuantity) { // add to a StockOutList (for temporary) if (ViewState["StockOutListVS"] == null) { StockOut stockOut = new StockOut(); List <StockOut> stockOutList = new List <StockOut>(); stockOut.CompanyId = companyId; stockOut.ItemId = itemId; stockOut.Date = DateTime.Today.ToString("yyyy/MM/dd"); stockOut.StockOutQuantity = stockOutQuantity; stockOut.Type = "No"; stockOutList.Add(stockOut); // update viewState ViewState["StockOutListVS"] = stockOutList; } else { StockOut stockOut = new StockOut(); List <StockOut> listStockOut = (List <StockOut>)ViewState["StockOutListVS"]; int previousQuantity = 0; int index = -1; for (int i = 0; i < listStockOut.Count; i++) { if (listStockOut[i].ItemId == itemId) { index = i; previousQuantity = listStockOut[i].StockOutQuantity + stockOutQuantity; } } if (index == -1) { stockOut.CompanyId = companyId; stockOut.ItemId = itemId; stockOut.Date = DateTime.Today.ToString("yyyy/MM/dd"); stockOut.StockOutQuantity = stockOutQuantity; stockOut.Type = "No"; listStockOut.Add(stockOut); } else { listStockOut[index].StockOutQuantity = previousQuantity; } // update viewState ViewState["StockOutListVS"] = listStockOut; } }
protected void addButton_Click(object sender, EventArgs e) { int flag = 0; if (Session["stockList"] != null) { stockOutList = (List <StockOut>)Session["stocklist"]; } int stockOutQuantity; if (int.TryParse(stockOutQuantityTextBox.Text, out stockOutQuantity)) { if (stockOutQuantity > 0) { foreach (var itemId in stockOutList) { if (itemId.ItemId == Convert.ToInt32(IdHiddenField.Value)) { itemId.StockOutQuantity += Convert.ToInt32(stockOutQuantityTextBox.Text); flag = 1; } } if (flag == 0) { StockOut stockOut = new StockOut(); stockOut.ItemName = itemDropDownList.SelectedItem.Text; stockOut.ItemId = Convert.ToInt32(IdHiddenField.Value); stockOut.CompanyName = companyDropDownList.SelectedItem.Text; int availableQty = Convert.ToInt32(availableQuantityTextBox.Text); stockOut.StockOutQuantity = Convert.ToInt32(stockOutQuantityTextBox.Text); stockOut.StockOutDate = System.DateTime.Today.ToString("yyyy-MM-dd"); stockOut.AvailableQuantity = availableQty - stockOut.StockOutQuantity; stockOutList.Add(stockOut); } Session["stockList"] = stockOutList; stockOutGridView.DataSource = stockOutList; stockOutGridView.DataBind(); sellButton.Enabled = true; damageButton.Enabled = true; lostButton.Enabled = true; } else { Response.Write("<script>alert('Invalid input');</script>"); } } else { Response.Write("<script>alert('Stock out quantity must be an integer');</script>"); } }