private static SingleStockEntryDto ToSingleStockEntryDto(StockEntry stockEntry) { var dto = new SingleStockEntryDto { StockItemId = stockEntry.ItemID, StableId = stockEntry.StableID, ItemName = stockEntry.Item.ItemName, Quantity = stockEntry.Quantity, Reservations = new List <SingleStockEntryDto.ReservationDto>() }; if (stockEntry.Reservations == null) { return(dto); } foreach (var reservation in stockEntry.Reservations) { dto.Reservations.Add(new SingleStockEntryDto.ReservationDto { ID = reservation.ID, Quantity = reservation.Quantity, StartDate = reservation.StartDate, EndDate = reservation.EndDate }); } return(dto); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (ItemToEdit == null) { //new element mode StockEntry item = new StockEntry(); item.Amount = Convert.ToInt32(tbAmount.Text); Software package = new Software(tbName.Text); package.PurchasePrice = Convert.ToDouble(tbPurchasePrice.Text); package.SalesPrice = Convert.ToDouble(tbSalesPrice.Text); package.Category = (Group)cbGorup.SelectedItem; item.SoftwarePackage = package; StockEntryViewModel model = new StockEntryViewModel(item); ((MainWindow)Application.Current.MainWindow).viewModel.Items.Add(model); } else { //edit item mode ItemToEdit.OnStock = Convert.ToInt32(tbAmount.Text); ItemToEdit.Name = tbName.Text; ItemToEdit.PurchasePrice = Convert.ToDouble(tbPurchasePrice.Text); ItemToEdit.SalesPrice = Convert.ToDouble(tbSalesPrice.Text); ItemToEdit.Category = ((Group)cbGorup.SelectedItem).Name; ((MainWindow)Application.Current.MainWindow).myDataGrid.Items.Refresh(); } this.Close(); }
public StockEntryViewModel() { this.stockEntry = new StockEntry(); this.stockEntry.SoftwarePackage = new Software(""); this.stockEntry.SoftwarePackage.Category = new Group(); this.stockEntry.SoftwarePackage.Category.Name = "New Category"; }
public DataTable UpdateInvoice(StockEntry ObjStockEntry) { DataTable dt = new DataTable(); try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_U_STOCKENTRY]"; cmd.Parameters.AddWithValue("@STOCKENTRYID", ObjStockEntry.STOCKENTRYID); cmd.Parameters.AddWithValue("@TCS", ObjStockEntry.TCS); cmd.Parameters.AddWithValue("@DISCOUNTPER", ObjStockEntry.DISCOUNTPER); cmd.Parameters.AddWithValue("@DISCOUNTFLAT", ObjStockEntry.DISCOUNTFLAT); cmd.Parameters.AddWithValue("@EXPENSES", ObjStockEntry.EXPENSES); cmd.Parameters.AddWithValue("@TRANSPORT", ObjStockEntry.TRANSPORT); cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw new Exception("Error While Updating Invoice"); } finally { SQLCon.Sqlconn().Close(); } return(dt); }
public async Task <IActionResult> Edit(string id, [Bind("StockId,ProductId,RemainingStock")] StockEntry stockEntry) { if (id != stockEntry.StockId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stockEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockEntryExists(stockEntry.StockId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "ProductName", stockEntry.ProductId); return(View(stockEntry)); }
private void btnStockEntryManual_Click(object sender, EventArgs e) { StockEntry frmStockEntry = new StockEntry(); frmStockEntry.OnClose += new Action(ShowDitails); frmStockEntry.ShowDialog(); }
public CustomerDetails(int i, string billno, decimal sumTotal, StockEntry stockentry) { _glStockEntry = stockentry; sellerEntry = i; _billnumber = billno; InitializeComponent(); }
public void GetStockEntryByIDTest() { //-- Arrange SQLStockRepository repository = new SQLStockRepository(); StockEntry actual = new StockEntry(); StockEntry expected = new StockEntry() { ID = uint.Parse(500.ToString()), Exchange = "NYSE", Symbol = "AEA", Date = DateTime.Parse("2008-02-14"), Volume = uint.Parse(892800.ToString()) }; expected.PriceOpen.Amount = 8.00m; expected.PriceClose.Amount = 7.75m; expected.PriceHigh.Amount = 8.06m; expected.PriceLow.Amount = 7.51m; expected.PriceCloseAdjusted.Amount = 6.33m; //-- Act actual = repository.GetStockEntry(500); //-- Assert Assert.AreEqual(expected.ID, actual.ID); Assert.AreEqual(expected.Exchange, actual.Exchange); Assert.AreEqual(expected.Symbol, actual.Symbol); Assert.AreEqual(expected.Date, actual.Date); Assert.AreEqual(expected.PriceOpen.Amount, actual.PriceOpen.Amount); Assert.AreEqual(expected.PriceClose.Amount, actual.PriceClose.Amount); Assert.AreEqual(expected.PriceCloseAdjusted.Amount, actual.PriceCloseAdjusted.Amount); Assert.AreEqual(expected.PriceHigh.Amount, actual.PriceHigh.Amount); Assert.AreEqual(expected.PriceLow.Amount, actual.PriceLow.Amount); Assert.AreEqual(expected.Volume, actual.Volume); }
/// <summary>Gets a stock entry from a server</summary> /// <exception cref="Exception">Thrown when failed to get stock entry from database</exception> public StockEntry GetStockEntry(uint id) { try { StockEntry stockEntry = new StockEntry(); SqlConnection conn = MbmSqlConnection.GetSqlConnection(); using (conn) { using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "NyseGetByID"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter stock_id = new SqlParameter("id", SqlDbType.BigInt); stock_id.Value = id; cmd.Parameters.Add(stock_id); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { stockEntry = new StockEntry(reader); } } } return(stockEntry); } catch (Exception ex) { throw new Exception("Failed to get stock entry from database", ex); } }
public void SaveInvoice() { try { if (ObjStockEntry == null) { ObjStockEntry = new StockEntry(); ObjStockEntry.STOCKENTRYID = 0; } ObjStockEntry.SUPPLIERID = cmbSupplier.EditValue; ObjStockEntry.SUPPLIERINVOICENO = txtInvoiceNumber.EditValue; ObjStockEntry.TAXINCLUSIVE = chkTaxInclusive.EditValue; ObjStockEntry.InvoiceDate = dtpInvoice.EditValue; ObjStockEntry.CATEGORYID = Utility.CategoryID; ObjStockEntry.TCS = txtTCS.EditValue; ObjStockEntry.DISCOUNTPER = txtDiscountPer.EditValue; ObjStockEntry.DISCOUNTFLAT = txtDiscountFlat.EditValue; ObjStockEntry.EXPENSES = txtExpenses.EditValue; ObjStockEntry.TRANSPORT = txtTransport.EditValue; ObjStockEntry.UserID = Utility.UserID; ObjStockRep.SaveInvoice(ObjStockEntry); cmbSupplier.Enabled = false; dtpInvoice.Enabled = false; txtInvoiceNumber.Enabled = false; chkTaxInclusive.Enabled = false; } catch (Exception ex) { throw ex; } }
/// <summary> /// Creates a stock entry /// </summary> /// <param name="entry">The entry</param> /// <returns>True if successful, false if not</returns> public bool CreateStockItemEntry(StockEntry entry) { string CREATE_STOCK_ENTRY_ENDPOINT = $"{_artsApiUrl}/{STOCK_ENTRY_ENDPOINT}"; JsonBodyParameter body = new JsonBodyParameter(); body.AddValue(STOCK_ITEM_ID_KEY, entry.StockItemId.ToString()); body.AddValue(ENTRY_DATE_KEY, entry.EntryDate.ToString()); body.AddValue(AVERAGE_PRICE_KEY, entry.StockItemId.ToString()); body.AddValue(LOWEST_PRICE_KEY, entry.StockItemId.ToString()); body.AddValue(HIGHEST_PRICE_KEY, entry.StockItemId.ToString()); body.AddValue(DATA_POINTS_KEY, entry.StockItemId.ToString()); HttpResponse createStockEntryResponse = _restClient.Put(CREATE_STOCK_ENTRY_ENDPOINT, body); _logger.LogInfo($"PUT {createStockEntryResponse.RequestUrl}", "CreateStockItemEntry"); _logger.LogInfo($"Body: {body.ToString()}"); _logger.LogInfo($"Status: {createStockEntryResponse.Status}", "CreateStockItemEntry"); _logger.LogInfo($"Response: {createStockEntryResponse.Response}", "CreateStockItemEntry"); if (!createStockEntryResponse.Success) { _logger.LogInfo("Create stock item entry failed.", "CreateStockItemEntry"); return(false); } int?status = ParseStatusResult(createStockEntryResponse.Response); return(status == SUCCESS_STATUS); }
public StockEntry ToStockEntry() { var stockEntry = new StockEntry { Id = Guid.NewGuid(), CreatedDate = DateTime.Now, ShiftId = this.ShiftId.GetValueOrDefault(), ProviderId = this.ProviderId.GetValueOrDefault(), Boxes = this.Boxes.GetValueOrDefault(), Maples = this.Maples.GetValueOrDefault(), Eggs = this.Eggs.GetValueOrDefault(), IsDeleted = false }; if (stockEntry.ProviderId == Guid.Empty) { stockEntry.ProviderId = null; } else { stockEntry.ProviderId = this.ProviderId.GetValueOrDefault(); } return(stockEntry); }
public frmAddStockRecord(StockEntry _ObjStockEntry, frmStockEntry _frmparent, StockEntryDetail _ObjStockEntryDetail) { InitializeComponent(); ObjStockEntry = _ObjStockEntry; frmparent = _frmparent; ObjStockEntryDetail = _ObjStockEntryDetail; }
public StockEntryViewModel() { stockEntry = new StockEntry(); stockEntry.SoftwarePackage = new Software(""); stockEntry.SoftwarePackage.Category = new Group(); stockEntry.SoftwarePackage.Category.Name = "dummy"; }
public void ToString_WithAnInvalidStockEntry_ReturnsFormattedString() { string expected = $"StockEntry: StockEntryId = 0, StockItemId = 0, EntryDate = {DateTime.MinValue.ToString(ArtsApi.DATE_FORMAT)}, " + $"AveragePrice = 0, HighestPrice = 0, LowestPrice = 0, DataPoints = 0, AvergaeChangeFromPreviousDay = null"; _stockEntry = JsonConvert.DeserializeObject <StockEntry>(StockEntryTestData.INVALID_STOCK_ENTRY_JSON); Assert.AreEqual(expected, _stockEntry.ToString()); }
public void CreateStockEntry_WithInvalidResponse_ReturnsFalse() { StockEntry entry = StockEntryTestData.Generate(); MockPutResponse(ArtsApiTestData.INVALID_RESPONSE); bool success = _artsApi.CreateStockItemEntry(entry); Assert.IsFalse(success); }
/// <summary>Gets a stock entry</summary> public StockEntry GetStockEntry(uint id) { StockEntry serverResponse = new StockEntry(); SQLStockRepository stockRepo = new SQLStockRepository(); serverResponse = stockRepo.GetStockEntry(id); return(serverResponse); }
/// <summary>Updates a stock entry</summary> public string UpdateStockEntry(StockEntry stock) { string serverResponse; SQLStockRepository stockRepo = new SQLStockRepository(); serverResponse = stockRepo.UpdateStockEntry(stock); return(serverResponse); }
public void CreateStockEntry_WithEmptyResponse_ReturnsFalse() { StockEntry entry = StockEntryTestData.Generate(); MockPutResponse(string.Empty); bool success = _artsApi.CreateStockItemEntry(entry); Assert.IsFalse(success); }
public void CreateStockEntry_WithUnsuccessfulResponse_ReturnsFalse() { StockEntry entry = StockEntryTestData.Generate(); MockPutResponse(ArtsApiTestData.CREATE_STOCK_ENTRY_UNSUCCESSFUL_RESPONSE); bool success = _artsApi.CreateStockItemEntry(entry); Assert.IsFalse(success); }
public StockEntryViewModel() { this.stockEntry = new StockEntry(); this.stockEntry.SoftwarePackage = new Software("dummy"); this.stockEntry.SoftwarePackage.Category = new Group(); this.stockEntry.SoftwarePackage.Category.Name = "dummy"; salesPriceInEuro = this.stockEntry.SoftwarePackage.SalesPrice; purchasePriceInEuro = this.stockEntry.SoftwarePackage.PurchasePrice; }
public StockEntryViewModel() { this.stockEntry = new StockEntry(); this.stockEntry.SoftwarePackage = new Software(""); this.stockEntry.SoftwarePackage.Category = new Group(); this.stockEntry.SoftwarePackage.Category.Name = ""; this.stockEntry.SoftwarePackage.SalesPrice = 0; this.stockEntry.SoftwarePackage.PurchasePrice = 0; }
public ActionResult ReceiveOrder(string OrderId, ICollection <long> BatchNumbers, ICollection <DateTime> ExpiryDates) { using (PharmAssistantContext db = new PharmAssistantContext()) { try { db.Database.BeginTransaction(); PurchaseOrder order = db.PurchaseOrders.Where(o => o.PurchaseOrderId == OrderId).FirstOrDefault(); ICollection <PurchaseOrderItem> OrderItems = db.PurchaseOrderItems.Where(i => i.PurchaseOrderId == OrderId).ToList(); StockEntry stockEntry; order.OrderStatus = true; long[] batchNumbers = BatchNumbers.ToArray(); DateTime[] expiryDates = ExpiryDates.ToArray(); int counter = 0; foreach (var OrderItem in OrderItems) { OrderItem.BatchNumber = batchNumbers[counter]; OrderItem.ExpiryDate = expiryDates[counter++]; db.PurchaseOrderItems.Attach(OrderItem); db.Entry(OrderItem).State = EntityState.Modified; stockEntry = new StockEntry { MedicineId = OrderItem.MedicineId, PurchaseOrderId = OrderItem.PurchaseOrderId, BatchNumber = OrderItem.BatchNumber.ToString(), Quantity = OrderItem.Quantity, CostPrice = OrderItem.CostPrice, SellingPrice = OrderItem.SellingPrice, ExpiryDate = OrderItem.ExpiryDate }; db.StockEntries.Add(stockEntry); } db.SaveChanges(); db.PurchaseOrders.Attach(order); db.Entry(order).State = EntityState.Modified; db.SaveChanges(); db.Database.CurrentTransaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.Message); db.Database.CurrentTransaction.Rollback(); } } return(RedirectToAction("PurchaseOrdersList")); }
private static StockEntryDto ToStockEntryDto(StockEntry stockEntry) { return(new StockEntryDto { StableId = stockEntry.StableID, StockItemId = stockEntry.ItemID, ItemName = stockEntry.Item.ItemName, Quantity = stockEntry.Quantity }); }
public void ToString_WithoutAverageChange_ReturnsFormattedString() { string expected = $"StockEntry: StockEntryId = {StockEntryTestData.STOCK_ENTRY_ID}, StockItemId = {StockItemTestData.STOCK_ITEM_ID}, " + $"EntryDate = {StockEntryTestData.ENTRY_DATE}, AveragePrice = {StockEntryTestData.AVERAGE_PRICE}, HighestPrice = " + $"{StockEntryTestData.HIGHEST_PRICE}, LowestPrice = {StockEntryTestData.LOWEST_PRICE}, DataPoints = {StockEntryTestData.DATA_POINTS}, " + $"AvergaeChangeFromPreviousDay = null"; _stockEntry = JsonConvert.DeserializeObject <StockEntry>(StockEntryTestData.VALID_STOCK_ENTRY_WITHOUT_AVERAGE_CHANGE_JSON); Assert.AreEqual(expected, _stockEntry.ToString()); }
public void ExchangeSetFourOrLess() { //-- Arrange StockEntry stock = new StockEntry(); string input = "ABCD"; //-- Act stock.Exchange = input; Assert.AreEqual("ABCD", stock.Exchange); }
public void SymbolSetThreeOrLess() { //-- Arrange StockEntry stock = new StockEntry(); string input = "ABC"; //-- Act stock.Symbol = input; Assert.AreEqual("ABC", stock.Symbol); }
private void addStockEntry() { if (client != null) { StockEntry se = getStockEntryFromForm(null); ERPObject obj = se.Object; client.InsertObject(obj); getPaymentEntryList(); } }
public void JsonConstructor_WithValidJsonWithoutAverageChange_ReturnsValidStockEntry() { _stockEntry = JsonConvert.DeserializeObject <StockEntry>(StockEntryTestData.VALID_STOCK_ENTRY_WITHOUT_AVERAGE_CHANGE_JSON); Assert.AreEqual(StockEntryTestData.STOCK_ENTRY_ID, _stockEntry.StockEntryId); Assert.AreEqual(StockItemTestData.STOCK_ITEM_ID, _stockEntry.StockItemId); Assert.AreEqual(StockEntryTestData.ENTRY_DATE, _stockEntry.EntryDate.ToString(ArtsApi.DATE_FORMAT)); Assert.AreEqual(StockEntryTestData.AVERAGE_PRICE, _stockEntry.AveragePrice); Assert.AreEqual(StockEntryTestData.HIGHEST_PRICE, _stockEntry.HighestPrice); Assert.AreEqual(StockEntryTestData.LOWEST_PRICE, _stockEntry.LowestPrice); Assert.AreEqual(StockEntryTestData.DATA_POINTS, _stockEntry.DataPoints); Assert.IsNull(_stockEntry.AverageChangeFromPreviousDay); }
public void JsonConstructor_WithInvalidJson_ReturnsValidStockEntry() { _stockEntry = JsonConvert.DeserializeObject <StockEntry>(StockEntryTestData.INVALID_STOCK_ENTRY_JSON); Assert.AreEqual(0, _stockEntry.StockEntryId); Assert.AreEqual(0, _stockEntry.StockItemId); Assert.AreEqual(DateTime.MinValue, _stockEntry.EntryDate); Assert.AreEqual(0, _stockEntry.AveragePrice); Assert.AreEqual(0, _stockEntry.HighestPrice); Assert.AreEqual(0, _stockEntry.LowestPrice); Assert.AreEqual(0, _stockEntry.DataPoints); Assert.IsNull(_stockEntry.AverageChangeFromPreviousDay); }