// PUT api/stockin/5 public int Put(int id, StockInModel model) { model.StockInId = id; int i = StockInProvider.insertStockInDetails(model); return(i); }
public async Task <ActionResult> Create() { StockInModel model = new StockInModel() { ShopPrice = "0.00", Quantity = 0 }; Guid business_working = Guid.Parse(Session["BusinessWorking"].ToString()); ViewBag.Categories = await applicationDbContext.Categories.Where(x => x.Business_Id == business_working).OrderBy(x => x.Name).ToListAsync(); List <Provider> providers = new List <Provider>(); providers.Add(new Provider() { Id = Guid.Empty, Name = "Ninguno" }); providers.AddRange(await applicationDbContext.Providers.Where(x => x.Business_Id == business_working).OrderBy(x => x.Name).ToListAsync()); ViewBag.Providers = providers; return(View(model)); }
public int ReOrderLavel(StockInModel stockinModel) { connection = new ConnectionClass(); string query = @"SELECT * FROM Items where Id='" + stockinModel.ItemId + "'"; cmd = new SqlCommand(query, connection.GetConnection()); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); int reQty = 0; foreach (DataRow row in dataTable.Rows) { reQty = Convert.ToInt32(row["ReOrderLevel"]); } int reOrderLavel; if (dataTable.Rows.Count > 0) { reOrderLavel = reQty; } else { reOrderLavel = 0; } connection.GetClose(); return(reOrderLavel); }
public static int insertStockInDetails(StockInModel s) { try { SqlHandler sql = new SqlHandler(); List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >(); parameter.Add(new KeyValuePair <string, object>("@StockId", s.StockId)); parameter.Add(new KeyValuePair <string, object>("@StockInGrossWt", s.StockInGrossWt)); parameter.Add(new KeyValuePair <string, object>("@StockInNetWt", s.StockInNetWt)); parameter.Add(new KeyValuePair <string, object>("@FinancialYearId", s.FinancialYearId)); parameter.Add(new KeyValuePair <string, object>("@CompanyId", s.CompanyId)); parameter.Add(new KeyValuePair <string, object>("@InsertBy", s.InsertBy)); parameter.Add(new KeyValuePair <string, object>("@insertDate", s.InsertDate)); int i = sql.ExecuteNonQueryI("Usp_AddStockInDetails", parameter); return(i); } catch (Exception ex) { throw ex; } }
public int Save(StockInModel stockInModel) { stockInModel.Type = "Buy"; string query = "INSERT INTO StockInOut(ItemSl, Quantity, Type, InTime) VALUES('" + stockInModel.ItemSl + "','" + stockInModel.Quantity + "','" + stockInModel.Type + "','" + stockInModel.InTime + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public string StockIn(StockInModel aStockIn) { int rowAffect = stockIn.StockIn(aStockIn); if (rowAffect == 1) { return("Stock In Successfull"); } else { return("Stock In Failed"); } }
public int StockIn(StockInModel stockIn) { string query = "UPDATE Item SET Quantity=@quantity WHERE Id=@itemId"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@quantity", stockIn.Quantity); command.Parameters.AddWithValue("@itemId", stockIn.ItemId); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public string Save(StockInModel stockInModel) { int rowAfftet = stockInGateway.Save(stockInModel); if (rowAfftet > 0) { return("Save Successful"); } else { return("Save failed"); } }
/// <summary> /// 保存 /// </summary> /// <param name="theData">保存的数据</param> public ActionResult SaveData(StockInModel theData) { if (theData.Id.IsNullOrEmpty()) { _sto_StockInBusiness.AddData(theData); } else { _sto_StockInBusiness.UpdateData(theData); } return(Success()); }
protected void stockInButton_Click(object sender, EventArgs e) { if (companyDropDownList.SelectedIndex > 0 && itemNameDropDownList.SelectedIndex > 0 && stockInQuantityTextBox.Text != "") { if (System.Text.RegularExpressions.Regex.IsMatch(stockInQuantityTextBox.Text, "^[0-9]+$") && Convert.ToInt32(stockInQuantityTextBox.Text) != 0) { int availableQuantity, stockInQuantity; StockInModel aStockIn = new StockInModel(); aStockIn.ItemId = Convert.ToInt32(itemNameDropDownList.SelectedValue); availableQuantity = Convert.ToInt32(availableQuantityTextBox.Text); stockInQuantity = Convert.ToInt32(stockInQuantityTextBox.Text); aStockIn.Quantity = availableQuantity + stockInQuantity; string message = stockInManager.StockIn(aStockIn); //outputLabel.Text = stockInQuantity + " Quantity " + " " + message + " " + " in " + // itemNameDropDownList.SelectedItem + " Item"; ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "SuccessMsg()", true); if (message == "Stock In Successfull") { companyDropDownList.SelectedIndex = 0; itemNameDropDownList.Items.Clear(); itemNameDropDownList.Items.Insert(0, new ListItem("Select an Item")); itemNameDropDownList.Items[0].Attributes["Disabled"] = "Disabled"; recorderLevelTextBox.Text = ""; availableQuantityTextBox.Text = ""; stockInQuantityTextBox.Text = ""; } outputLabel.ForeColor = Color.Red; } else { ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "VaidationMsg()", true); } } else { ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "VaidationMsg1()", true); //outputLabel.Text = "Please Select a Company, an Item and Input Stock Out Quanity"; } }
public int AvaiLavelQty(StockInModel stockinModel) { connection = new ConnectionClass(); string query = @"SELECT sum(StockIn.Quantity) AS totalStockInQty, sum(StockOut.Quantity) AS totalStockOutQty FROM StockIn LEFT OUTER JOIN StockOut ON StockIn.ItemId = StockOut.ItemId WHERE StockIn.ItemId = '" + stockinModel.ItemId + "' GROUP BY StockIn.ItemId"; cmd = new SqlCommand(query, connection.GetConnection()); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); //int avaiLavelQty = 0; int totalInStock = 0; int totalOutStock = 0; foreach (DataRow row in dataTable.Rows) { if (!row.IsNull("totalStockInQty")) { totalInStock = Convert.ToInt32(row["totalStockInQty"]); } if (!row.IsNull("totalStockOutQty")) { totalOutStock = Convert.ToInt32(row["totalStockOutQty"]); } } int avilavelStock; if (dataTable.Rows.Count > 0) { avilavelStock = totalInStock - totalOutStock; } else { avilavelStock = 0; } connection.GetClose(); return(avilavelStock); }
public int InsertStock(StockInModel stockinModel) { connection = new ConnectionClass(); if (!string.IsNullOrEmpty(stockinModel.Id)) { string query = @"Update StockIn set ItemId = '" + stockinModel.ItemId + "', Quantity = '" + stockinModel.StockInQty + "' WHERE Id='" + stockinModel.Id + "'"; cmd = new SqlCommand(query, connection.GetConnection()); } else { string query = @"INSERT INTO StockIn (ItemId, Quantity, CreatedDate) VALUES ( " + stockinModel.ItemId + ", '" + stockinModel.StockInQty + "', '" + stockinModel.CreatedDate + "')"; cmd = new SqlCommand(query, connection.GetConnection()); } int isExecuted; isExecuted = cmd.ExecuteNonQuery(); connection.GetClose(); return(isExecuted); }
public DataTable CatWiseItems(StockInModel stockInModel) { connection = new ConnectionClass(); string query = @"SELECT * FROM Items where CategoryId = '" + stockInModel.CatId + "' AND CompanyId='" + stockInModel.ComId + "'"; cmd = new SqlCommand(query, connection.GetConnection()); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0) { DataRow row = dataTable.NewRow(); row["Id"] = 0; row["Name"] = "Please Select Item"; dataTable.Rows.InsertAt(row, 0); } connection.GetClose(); return(dataTable); }
//public PrintInvoiceStockIn(string stockincode):this() //{ // code = stockincode; //} public void PrintInvoice(string code, List <StockInReportModel> data) { StockInInvoicePara report = new StockInInvoicePara(); foreach (DevExpress.XtraReports.Parameters.Parameter p in report.Parameters) { p.Visible = false; } // var model = (from sid in dc.StockIns join e in dc.Employees on sid.EmployeeCode equals e.EmployeeCode where (sid.StockInCode == code) select new { sid.StockInCode, sid.DateIn, sid.EmployeeCode, e.Name, e.Dept, sid.UserID, sid.Note }); StockInModel sim = new StockInModel(); foreach (var item1 in model) { sim.StockInCode = item1.StockInCode; sim.DateIn = item1.DateIn; sim.EmployeeCode = item1.EmployeeCode; sim.Name = item1.Name; sim.Dept = item1.Dept; sim.User = item1.UserID; sim.Note = item1.Note; } report.InitData(sim.StockInCode, sim.DateIn, sim.EmployeeCode, sim.Name, sim.Dept, sim.User, sim.Note, data); documentViewer1.DocumentSource = report; report.CreateDocument(); }
public DataTable ComWiseCat(StockInModel stockInModel) { connection = new ConnectionClass(); string query = @"select c.Id, c.Name from Items as i left join Categories as c on c.Id = i.CategoryId where i.CompanyId = '" + stockInModel.ComId + "' group by c.Id, c.Name"; cmd = new SqlCommand(query, connection.GetConnection()); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0) { DataRow row = dataTable.NewRow(); row["Id"] = 0; row["Name"] = "Please Select Cartegory"; dataTable.Rows.InsertAt(row, 0); } connection.GetClose(); return(dataTable); }
public int AvaiLavelQty(StockInModel stockinModel) { return(_stockInRepository.AvaiLavelQty(stockinModel)); }
public int ReOrderLavel(StockInModel stockinModel) { return(_stockInRepository.ReOrderLavel(stockinModel)); }
public int InsertStock(StockInModel stockinModel) { return(_stockInRepository.InsertStock(stockinModel)); }
public DataTable ComWiseCat(StockInModel stockInModel) { return(_stockInRepository.ComWiseCat(stockInModel)); }
public DataTable CatWiseItems(StockInModel stockInModel) { return(_stockInRepository.CatWiseItems(stockInModel)); }
public async Task <ActionResult> Create(StockInModel model) { Guid business_working = Guid.Parse(Session["BusinessWorking"].ToString()); if (ModelState.IsValid) { Guid productId = Guid.Parse(model.ProductName); StockIn stockIn = new StockIn() { Id = Guid.NewGuid(), Product_Id = productId, Date = DateTime.Now, Quantity = model.Quantity, ShopPrice = decimal.Parse(model.ShopPrice.Replace(".", ",")), User_Id = User.Identity.GetUserId(), Description = model.Description }; if (Guid.Parse(model.Provider) != Guid.Empty) { stockIn.Provider_Id = Guid.Parse(model.Provider); } applicationDbContext.StockIns.Add(stockIn); Product product = await applicationDbContext.Products.Include("Category").FirstOrDefaultAsync(x => x.Id == productId); product.CurrentPrice = ((product.CurrentPrice * product.Stock) + (stockIn.ShopPrice * stockIn.Quantity)) / (product.Stock + stockIn.Quantity); product.Stock += stockIn.Quantity; product.LastUpdated = DateTime.Now; if (RoleManager.IsInRole(RoleManager.Editor) || RoleManager.IsInRole(RoleManager.Administrator)) { BusinessUser businessUser = await applicationDbContext.BusinessUsers.FirstOrDefaultAsync(x => x.User_Id == stockIn.User_Id && x.Business_Id == business_working); if (product.Category.ActionIn == ActionConstants.Sum) { businessUser.Cash += stockIn.ShopPrice * stockIn.Quantity; } else if (product.Category.ActionIn == ActionConstants.Rest) { businessUser.Cash -= stockIn.ShopPrice * stockIn.Quantity; } applicationDbContext.Entry(businessUser).State = System.Data.Entity.EntityState.Modified; } applicationDbContext.Entry(product).State = System.Data.Entity.EntityState.Modified; await applicationDbContext.SaveChangesAsync(); await ActivityPublisher.Publish(User.Identity.GetUserId(), ActivityTypeConstants.Stock_In_Create, stockIn.Id, product.Name, business_working); return(RedirectToAction("Index")); } ViewBag.Categories = await applicationDbContext.Categories.Where(x => x.Business_Id == business_working).OrderBy(x => x.Name).ToListAsync(); ViewBag.Providers = await applicationDbContext.Providers.Where(x => x.Business_Id == business_working).OrderBy(x => x.Name).ToListAsync(); return(View(model)); }
public StockInForm() { InitializeComponent(); stockinModel = new StockInModel(); }
// POST api/stockin public void Post(StockInModel model) { int i = StockInProvider.insertStockInDetails(model); }