private static float GetMinValue(StockObject stock1, StockObject stock2, int quotes) { float res = int.MaxValue; if (stock1 != null) { for (int i = 0; i < quotes; i++) { Result r = stock1.results[i]; if (r.close < res) { res = (float)r.close; } } } if (stock2 != null) { for (int i = 0; i < quotes; i++) { Result r = stock2.results[i]; if (r.close < res) { res = (float)r.close; } } } return(res); }
//Load Stocks asynchronously and request request graph to be painted private async void ReloadStocks() { List <Company> selectedCompanies = GetSelectedCompaniesList(); switch (selectedCompanies.Count) { case 1: stock1 = await StocksHandler.GetStockDataAsync(selectedCompanies[0].ticker); stock2 = null; doubleGraphScale = false; break; case 2: stock1 = await StocksHandler.GetStockDataAsync(selectedCompanies[0].ticker); stock2 = await StocksHandler.GetStockDataAsync(selectedCompanies[1].ticker); break; default: stock1 = null; stock2 = null; doubleGraphScale = false; break; } Device.BeginInvokeOnMainThread(() => { canvasView.InvalidateSurface(); }); }
public ProductDTO(string productCode, int stock, double price) { id = new Guid(); ProductCode = new ProductCodeObject(productCode); Stock = new StockObject(stock); RealPrice = new PriceObject(price); SetPrice(price); }
private void PriceTicker(PledgeObject p) { StockObject FoundStock = StockList.FirstOrDefault(x => x.Cusip.ToUpper() == p.Cusip.ToUpper()); if (FoundStock != null) { p.Ticker = FoundStock.Ticker; p.LoanValue = p.Quantity * (double)FoundStock.Price; } }
public async Task <ActionResult <Stock> > PostStock(StockObject stockObject) { var stock = new Stock { LastTradedValue = 0, Name = stockObject.Name, ShareHolders = stockObject.Shares, StockOwner = stockObject.StockOwner }; await _context.Stocks.AddAsync(stock); await _context.SaveChangesAsync(); _logger.LogInformation("Added Stock {@Stock}", stock); return(stock); }
public static async Task AddStock(string ticker, int amount, string svid, VooperContext context) { StockObject stock = await context.StockObjects.AsQueryable().FirstOrDefaultAsync(s => s.Owner_Id == svid && s.Ticker == ticker); if (stock != null) { stock.Amount += amount; context.StockObjects.Update(stock); } else { stock = new StockObject() { Amount = amount, Ticker = ticker, Id = Guid.NewGuid().ToString(), Owner_Id = svid }; await context.StockObjects.AddAsync(stock); } await context.SaveChangesAsync(); }
public static void CanvasDraw(SKPaintSurfaceEventArgs e, StockObject stock1, StockObject stock2, bool extended, bool doubleGraphScale) { SKCanvas canvas = e.Surface.Canvas; int quotes = extended ? 30 : 7; int width = e.Info.Width; int height = e.Info.Height; int marginX = (int)(width * 0.1); int marginY = (int)(height * 0.1); float sideStep = (float)(width - marginX * 2) / (quotes - 1); float maxValue1 = -1; float maxValue2 = -1; float minValue1 = -1; float minValue2 = -1; if (!doubleGraphScale) { maxValue1 = GetMaxValue(stock1, stock2, quotes); minValue1 = GetMinValue(stock1, stock2, quotes); } else { maxValue1 = GetMaxValue(stock1, null, quotes); minValue1 = GetMinValue(stock1, null, quotes); maxValue2 = GetMaxValue(null, stock2, quotes); minValue2 = GetMinValue(null, stock2, quotes); } //Fill Background canvas.Clear(SKColors.WhiteSmoke); //Draw Axis #region Draw Axis SKPaint axisPaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Black, StrokeWidth = 5, }; SKPath axisLines = new SKPath(); axisLines.MoveTo(marginX, marginY); axisLines.LineTo(marginX, height - marginY); axisLines.LineTo(width - marginX, height - marginY); if (doubleGraphScale) { axisLines.LineTo(width - marginX, marginY); } canvas.DrawPath(axisLines, axisPaint); #endregion //Draw Labels #region Write Labels SKPoint maxValueYaxisLeftLabel = new SKPoint { X = (float)marginX / 4, Y = (float)marginY * (float)1.5, }; SKPoint minValueYaxisLeftLabel = new SKPoint { X = (float)marginX / 4, Y = (float)height - marginY }; SKPoint maxValueYaxisRightLabel = new SKPoint { X = width - (float)marginX / (float)1.1, Y = (float)marginY * (float)1.5, }; SKPoint minValueYaxisRightLabel = new SKPoint { X = width - (float)marginX / (float)1.1, Y = (float)height - marginY }; SKPoint startDateXaxisLabel = new SKPoint { X = marginX * (float)2.3, Y = height - marginY / 2, }; SKPoint endDateXaxisLabel = new SKPoint { X = width - marginX * 4, Y = height - marginY / 2, }; string startDateLabel = stock1 != null ? stock1.results[quotes - 1].timestamp.ToString().Split(' ')[0] : "dd/MM/yyyy"; string maxValueLeftLabel = maxValue1 == 0 ? "max" : ((int)maxValue1).ToString(); string minValueLeftLabel = minValue1 == int.MaxValue ? "0" : ((int)minValue1).ToString(); string maxValueRightLabel = ""; string minValueRightLabel = ""; if (doubleGraphScale) { maxValueRightLabel = maxValue2 == 0 ? "max" : ((int)maxValue2).ToString(); minValueRightLabel = minValue2 == int.MaxValue ? "0" : ((int)minValue2).ToString(); } SKPaint labelPaint = new SKPaint { Style = SKPaintStyle.Fill, Color = SKColors.Black, StrokeWidth = 5, }; labelPaint.TextSize = (float)(height / 25); canvas.DrawText(maxValueLeftLabel, maxValueYaxisLeftLabel, labelPaint); canvas.DrawText(minValueLeftLabel, minValueYaxisLeftLabel, labelPaint); string tickerAxis = (stock1 == null) ? "" : "(" + stock1.results[0].symbol + ")"; maxValueYaxisLeftLabel.Y -= 2 * labelPaint.TextSize; canvas.DrawText("USD " + tickerAxis, maxValueYaxisLeftLabel, labelPaint); if (doubleGraphScale) { canvas.DrawText(maxValueRightLabel, maxValueYaxisRightLabel, labelPaint); canvas.DrawText(minValueRightLabel, minValueYaxisRightLabel, labelPaint); tickerAxis = (stock2 == null) ? "" : "(" + stock2.results[0].symbol + ")"; maxValueYaxisRightLabel.Y -= 2 * labelPaint.TextSize; maxValueYaxisRightLabel.X *= 0.90f; canvas.DrawText("USD " + tickerAxis, maxValueYaxisRightLabel, labelPaint); } canvas.DrawText(startDateLabel, startDateXaxisLabel, labelPaint); canvas.DrawText(DateTime.Today.ToString("dd/MM/yyyy"), endDateXaxisLabel, labelPaint); #endregion //Draw graph1 DrawGraphs(canvas, quotes, true, stock1, sideStep, width, height, marginX, marginY, minValue1, maxValue1); //Draw graph2 DrawGraphs(canvas, quotes, false, stock2, sideStep, width, height, marginX, marginY, doubleGraphScale ? minValue2 : minValue1, doubleGraphScale ? maxValue2 : maxValue1); }
public static IntPtr GetStockObject(StockObject fnObject) { IntPtr retPtr = _GetStockObject(fnObject); if (retPtr == null) { HRESULT.ThrowLastError(); } return retPtr; }
internal extern static IntPtr Win32GetStockObject(StockObject fnObject);
public EnclosureObjectData(StockObject stockObject, int effectValue, EnclosureObjectType enclosureObjectType) { this.stockObject = stockObject; this.effectValue = effectValue; this.enclosureObjectType = enclosureObjectType; }
public static GdiObjectHandle GetStockObject(StockObject @object) { IntPtr handle = Imports.GetStockObject((int)@object); return(GdiObjectHandle.Create(handle, ownsHandle: false)); }
public static extern GdiObjectHandle GetStockObject( StockObject stockObject);
public async Task <IActionResult> ListNewStock(CreateStockModel model) { // Validate model if (!ModelState.IsValid) { return(View()); } // Additional validations Group group = await _context.Groups.FindAsync(model.Group_Id); if (group == null) { StatusMessage = $"Failed: Could not find group {model.Group_Id}"; return(View()); } // Check if group already has a stock if (_context.StockDefinitions.Any(s => s.Group_Id == model.Group_Id)) { StatusMessage = $"Failed: {group.Name} already has a stock!"; return(View()); } if (model.Amount < 0) { StatusMessage = $"Failed: Amount must be positive!"; return(View()); } if (model.Keep < 0) { StatusMessage = $"Failed: Keep must be positive!"; return(View()); } // Check if ticker is taken if (_context.StockDefinitions.Any(s => s.Ticker == model.Ticker)) { StatusMessage = $"Failed: A ticker {model.Ticker} already exists!"; return(View()); } if (model.Initial_Value < 1) { StatusMessage = $"Failed: Initial value must be greater or equal to 1!"; return(View()); } if (model.Keep > model.Amount) { StatusMessage = $"Failed: Keep must be less than Amount!"; return(View()); } // Create stock definition StockDefinition stockDef = new StockDefinition() { Ticker = model.Ticker, Group_Id = model.Group_Id, Current_Value = model.Initial_Value }; // Add stock definition to database await _context.StockDefinitions.AddAsync(stockDef); // Create stock object for keeping StockObject keepStock = new StockObject() { Id = Guid.NewGuid().ToString(), Amount = model.Keep, Owner_Id = model.Group_Id, Ticker = model.Ticker, }; // Add await _context.StockObjects.AddAsync(keepStock); // Create stock sale for issued part StockOffer sellOffer = new StockOffer() { Id = Guid.NewGuid().ToString(), Order_Type = "SELL", Target = model.Initial_Value, Ticker = model.Ticker, Amount = model.Amount - model.Keep, Owner_Id = model.Group_Id }; // Add await _context.StockOffers.AddAsync(sellOffer); // Save changes if successful await _context.SaveChangesAsync(); StatusMessage = $"Successfully issued {model.Amount} ${model.Ticker}"; await VoopAI.ecoChannel.SendMessageAsync($":new: Welcome {model.Amount} {model.Ticker}, from {group.Name} to the market at ¢{model.Initial_Value}, with an initial {sellOffer.Amount} on the market!"); return(RedirectToAction("Index")); }
/// <summary> /// Edits a stock in the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditButton_Click(object sender, RoutedEventArgs e) { try { if (currentStockIdInput.Text.Equals("") || currentLocationIdInput.Text.Equals("") || newAccountIdInput.Text.Equals("") || newProductIdInput.Text.Equals("") || newWarehouseIdInput.Text.Equals("") || newLocationIdInput.Equals("") || newQuantityInput.Text.Equals("") || newAllocatedQuantityInput.Text.Equals("") || newAvailabilityStatusInput.Text.Equals("")) { MessageBox.Show("Please input all text boxes."); currentStockIdInput.Focus(); return; } else if ((!Regex.IsMatch(currentStockIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(currentLocationIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newAccountIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newProductIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newWarehouseIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newLocationIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newQuantityInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(newAllocatedQuantityInput.Text, "^[0-9]*$"))) { MessageBox.Show("Please input only numerical characters into all text boxes apart from the current and new 'Availability Status Input'."); currentStockIdInput.Focus(); return; } else if (!(newAvailabilityStatusInput.Text.ToLower().Equals("true") || newAvailabilityStatusInput.Text.ToLower().Equals("false"))) { MessageBox.Show("Please input only 'True' or 'False' into the current and new Availability Status Input text boxes."); newAvailabilityStatusInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } StockObject stock; StockObject stockCurrentId = businessLogicLayer.CheckStockByID(int.Parse(currentStockIdInput.Text)); StockObject stockCurrentIdAndWarehouseAndLocation = businessLogicLayer.CheckStockByIDAndWarehouseAndLocation(int.Parse(currentStockIdInput.Text), int.Parse(currentWarehouseIdInput.Text), int.Parse(currentLocationIdInput.Text)); StockObject stockCurrentWarehouseAndLocation = businessLogicLayer.CheckStockByWarehouseAndLocation(int.Parse(currentWarehouseIdInput.Text), int.Parse(currentLocationIdInput.Text)); StockObject stockNewWarehouseAndLocation = businessLogicLayer.CheckStockByWarehouseAndLocation(int.Parse(newWarehouseIdInput.Text), int.Parse(newLocationIdInput.Text)); LocationObject locationNewLocationByWarehouse = businessLogicLayer.CheckLocationByIDAndWarehouse(int.Parse(newLocationIdInput.Text), int.Parse(newWarehouseIdInput.Text)); AccountObject accountId = businessLogicLayer.CheckAccountsByID(int.Parse(newAccountIdInput.Text)); ProductObject productId = businessLogicLayer.CheckProductsByID(int.Parse(newProductIdInput.Text)); WarehouseObject warehouseId = businessLogicLayer.CheckWarehousesByID(int.Parse(newWarehouseIdInput.Text)); LocationObject locationId = businessLogicLayer.CheckLocationsByID(int.Parse(newLocationIdInput.Text)); LocationObject locationUnallocated; LocationObject locationAllocated; try { if (!int.Parse(currentStockIdInput.Text).Equals(stockCurrentId.stock_id)) { MessageBox.Show("The current Stock ID provided does not exist."); currentStockIdInput.Focus(); return; } else if (!int.Parse(currentStockIdInput.Text).Equals(stockCurrentIdAndWarehouseAndLocation.stock_id) && !int.Parse(currentWarehouseIdInput.Text).Equals(stockCurrentIdAndWarehouseAndLocation.warehouse_id) && !int.Parse(currentLocationIdInput.Text).Equals(stockCurrentIdAndWarehouseAndLocation.location_id)) { MessageBox.Show("The current Stock provided does not exist in that Warehouse & Location."); currentStockIdInput.Focus(); return; } else if (!int.Parse(newAccountIdInput.Text).Equals(accountId.account_id)) { MessageBox.Show("The new Account ID provided does not exist."); newAccountIdInput.Focus(); return; } else if (!int.Parse(newProductIdInput.Text).Equals(productId.product_id)) { MessageBox.Show("The new product ID provided does not exist."); newProductIdInput.Focus(); return; } else if (!int.Parse(newWarehouseIdInput.Text).Equals(warehouseId.warehouse_id)) { MessageBox.Show("The new Warehouse ID provided does not exist."); newWarehouseIdInput.Focus(); return; } else if (!int.Parse(newLocationIdInput.Text).Equals(locationId.location_id)) { MessageBox.Show("The new Location ID provided does not exist."); newLocationIdInput.Focus(); return; } else if (int.Parse(newQuantityInput.Text) < int.Parse(newAllocatedQuantityInput.Text)) { MessageBox.Show("The new Allocated Quantity cannot be greater than the new Quantity."); newQuantityInput.Focus(); return; } else if (!int.Parse(newLocationIdInput.Text).Equals(locationNewLocationByWarehouse.location_id)) { MessageBox.Show("The new Location ID provided does not exist in that warehouse."); currentStockIdInput.Focus(); return; } else if (int.Parse(newWarehouseIdInput.Text).Equals(stockNewWarehouseAndLocation.warehouse_id) && !int.Parse(newWarehouseIdInput.Text).Equals(stockCurrentWarehouseAndLocation.warehouse_id) || int.Parse(newLocationIdInput.Text).Equals(stockNewWarehouseAndLocation.location_id) && !int.Parse(newLocationIdInput.Text).Equals(stockCurrentWarehouseAndLocation.location_id)) { MessageBox.Show("Stock already exists in that Warehouse and Location."); newWarehouseIdInput.Focus(); return; } else { stock = businessLogicLayer.EditCurrentStock(int.Parse(newAccountIdInput.Text), int.Parse(newProductIdInput.Text), int.Parse(newWarehouseIdInput.Text), int.Parse(newLocationIdInput.Text), int.Parse(newQuantityInput.Text), int.Parse(newAllocatedQuantityInput.Text), bool.Parse(newAvailabilityStatusInput.Text.ToLower()), int.Parse(currentStockIdInput.Text)); locationUnallocated = businessLogicLayer.MarkLocationUnallocated(int.Parse(currentLocationIdInput.Text)); locationAllocated = businessLogicLayer.MarkLocationAllocated(int.Parse(newLocationIdInput.Text)); MessageBox.Show("The Stock provided has been updated. \n\nThe current Location has been marked unallocated. \n\nThe new Location has been marked allocated"); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public static partial HGDIOBJ GetStockObject(StockObject nIndex);
/// <summary> /// Deletes a Stock from the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteButton_Click(object sender, RoutedEventArgs e) { try { if (stockIdInput.Text.Equals("") || locationIdInput.Text.Equals("")) { MessageBox.Show("Please input the text boxes."); stockIdInput.Focus(); return; } else if ((!Regex.IsMatch(stockIdInput.Text, "^[0-9]*$")) || (!Regex.IsMatch(locationIdInput.Text, "^[0-9]*$"))) { MessageBox.Show("Please input only numerical characters into the text boxes."); stockIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } StockObject stock; StockObject stockId = businessLogicLayer.CheckStockByID(int.Parse(stockIdInput.Text)); StockObject stockIdAndLocationId = businessLogicLayer.CheckStockByIDAndLocation(int.Parse(stockIdInput.Text), int.Parse(locationIdInput.Text)); StockObject stockAllocated = businessLogicLayer.CheckStockIsAllocated(int.Parse(stockIdInput.Text)); int stockAllocatedQuantity = stockAllocated.allocated_quantity; LocationObject locationId = businessLogicLayer.CheckLocationsByID(int.Parse(locationIdInput.Text)); LocationObject location; try { if (!int.Parse(stockIdInput.Text).Equals(stockId.stock_id)) { MessageBox.Show("The Stock ID provided does not exist."); stockIdInput.Focus(); return; } else if (!int.Parse(locationIdInput.Text).Equals(locationId.location_id)) { MessageBox.Show("The Location ID provided does not exist."); stockIdInput.Focus(); return; } else if (!int.Parse(stockIdInput.Text).Equals(stockIdAndLocationId.stock_id) && !int.Parse(locationIdInput.Text).Equals(stockIdAndLocationId.location_id)) { MessageBox.Show("The Stock ID and Location ID provided do not match."); stockIdInput.Focus(); return; } else if (stockAllocatedQuantity > 0) { MessageBox.Show("The Stock provided is currently allocated towards an order and so cannot be deleted. \n\nPlease contact an administrator if the stock still needs to be deleted."); stockIdInput.Focus(); return; } else { stock = businessLogicLayer.DeleteCurrentStock(int.Parse(stockIdInput.Text)); location = businessLogicLayer.MarkLocationUnallocated(int.Parse(locationIdInput.Text)); MessageBox.Show("The provided stock has been deleted from the system. \n\nThe location it occupied has now been unallocated."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public static IntPtr GetStockObject(StockObject fnObject) { return(Gdi32Methods.GetStockObject((int)fnObject)); }
public static extern IntPtr GetStockObject(StockObject nIndex);
private static extern IntPtr _GetStockObject(StockObject fnObject);
public static IntPtr GetStockObject(StockObject fnObject) { var retPtr = _GetStockObject(fnObject); return retPtr; }
private static void DrawGraphs(SKCanvas canvas, int quotes, bool isStock1, StockObject stock, float sideStep, int width, int height, int marginX, int marginY, float minValue, float maxValue) { SKPaint graphPaint; SKPaint textPaint; SKPath graphLines = new SKPath(); string ticker = (stock == null) ? " ": stock.results[0].symbol; if (isStock1) { graphPaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Red, StrokeWidth = 5, }; textPaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Red, StrokeWidth = 1.5f, TextSize = (float)(height / 20) }; } else { graphPaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Green, StrokeWidth = 5, }; textPaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Green, StrokeWidth = 1.5f, TextSize = (float)(height / 20) }; } if (stock != null) { float x = width - marginX; float y = GetYPos(stock.results[0].close, height, marginY, maxValue, minValue); graphLines.MoveTo(x, y); canvas.DrawCircle(x, y, 3, graphPaint); for (int i = 1; i < quotes; i++) { x = width - marginX - sideStep * i; y = GetYPos(stock.results[i].close, height, marginY, maxValue, minValue); graphLines.LineTo(x, y); canvas.DrawCircle(x, y, 3, graphPaint); } canvas.DrawPath(graphLines, graphPaint); DrawTickerLabel(canvas, textPaint, graphPaint, ticker, width, height, isStock1); } }
public static partial IntPtr GetStockObject(StockObject i);
internal static extern IntPtr GetStockObject(StockObject nIndex);
public static extern HGDIOBJ GetStockObject(StockObject nIndex);
/// <summary> /// POS download softpin /// ChungNN 03/2009 /// </summary> /// <param name="request">IsoMessage</param> /// <returns>IsoMessage</returns> public IsoMessage Download(IsoMessage request) { topupObj = new TopupInterface(); //create response message mfact = new MessageFactory(); mfact = ConfigParser.CreateFromFile(AppConfiguration.App_Path + AppConfiguration.POSConfig_ISOFile); IsoMessage response = mfact.CreateResponse(request); bool blnDownloadTemplate = !request.HasField(48); string strRequest = request.GetField(11).Value.ToString(); int nMerchant_ID = int.Parse(request.GetField(2).Value.ToString()); int nPos_ID = int.Parse(request.GetField(52).Value.ToString()); //if exist session if (!Common.ServiceSessionManager.GetSessionInstance().IsExistedSession(nPos_ID.ToString(), strRequest)) { mfact.Setfield(39, "01", ref response); transObj.WriteLog("->download fail, session not exist"); } else { //Download template if (blnDownloadTemplate) { try { //get request values topupObj = new TopupInterface(); BatchBuyObject buyObj = new BatchBuyObject(); //String[] arrRequestValues = request.GetField(48).Value.ToString().Split(AppConfiguration.POS_Seperator_Char); //string strCategoryName = arrRequestValues[0]; //string strServiceProviderName = arrRequestValues[1]; //int nProductValue = int.Parse(arrRequestValues[2]); //int nStockQuantity = int.Parse(arrRequestValues[3]); //int nDownloadQuantity = int.Parse(arrRequestValues[4]); object[] SoftpinStock = new object[1]; StockObject stockObj = new StockObject(); stockObj.ProductValue = 10000; stockObj.CategoryName = "Thẻ ĐTDĐ"; stockObj.ServiceProviderName = "Vinaphone"; stockObj.StockQuantity = 0; SoftpinStock[0] = stockObj; buyObj = topupObj.PosDownloadSoftpinTemplate(nPos_ID, nMerchant_ID, strRequest, SoftpinStock); if (buyObj.ErrorCode == 0) { mfact.Setfield(39, "00", ref response); transObj.WriteLog("->download template successfull"); } else { mfact.Setfield(39, "01", ref response); transObj.WriteLog("->download template fail"); } } catch (Exception ex) { transObj.WriteLog("->download template execption =" + ex.ToString()); throw (ex); } } //Download single else { try { //get request values topupObj = new TopupInterface(); BatchBuyObject buyObj = new BatchBuyObject(); String[] arrRequestValues = request.GetField(48).Value.ToString().Split(AppConfiguration.POS_Seperator_Char); string strCategoryName = arrRequestValues[0]; string strServiceProviderName = arrRequestValues[1]; int nProductValue = int.Parse(arrRequestValues[2]); int nStockQuantity = int.Parse(arrRequestValues[3]); int nDownloadQuantity = int.Parse(arrRequestValues[4]); buyObj = topupObj.PosDownloadSingleSoftpin(nPos_ID, nMerchant_ID, strRequest, strCategoryName, strServiceProviderName, nProductValue, nStockQuantity, nDownloadQuantity); if (buyObj.ErrorCode == 0) { mfact.Setfield(39, "00", ref response); transObj.WriteLog("->download single successfull"); } else { mfact.Setfield(39, "01", ref response); transObj.WriteLog("->download single fail"); } //create response message mfact = new MessageFactory(); mfact = ConfigParser.CreateFromFile(AppConfiguration.App_Path + AppConfiguration.POSConfig_ISOFile); response = mfact.CreateResponse(request); } catch (Exception ex) { transObj.WriteLog("->download single execption =" + ex.ToString()); throw (ex); } } } return(response); }
public static IntPtr GetStockObject(StockObject fnObject) { return(NativeMethods._GetStockObject(fnObject)); }
public static IntPtr GetStockObject(StockObject fnObject) { return(Standard.NativeMethods.GetStockObject_1(fnObject)); }
public static extern IntPtr GetStockObject(StockObject fnObject);
private static extern IntPtr GetStockObject_1(StockObject fnObject);
public static extern HGDIOBJ GetStockObject( StockObject stockObject);
/// <summary> /// Deletes a pick from the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteButton_Click(object sender, RoutedEventArgs e) { try { if (pickIdInput.Text.Equals("")) { MessageBox.Show("Please input the text box."); pickIdInput.Focus(); return; } else if (!Regex.IsMatch(pickIdInput.Text, "^[0-9]*$")) { MessageBox.Show("Please input only numerical characters into the text box."); pickIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } // Check Picks by Pick ID PickObject pick1 = businessLogicLayer.CheckPicksByPickID(int.Parse(pickIdInput.Text)); // Select Picks Order Line ID and Location ID And Quantity by Pick ID PickObject pick2 = businessLogicLayer.SelectPicksOrderLineLocationIDAndQuantityByPickID(int.Parse(pickIdInput.Text)); int pickOrderLineID = pick2.order_line_id; int pickLocationID = pick2.location_id; int pickQuantity = pick2.quantity; // Get Order Line Order ID OrderLineObject orderLine1 = businessLogicLayer.GetOrderLineOrderID(pickOrderLineID); int orderLineOrderID = orderLine1.order_id; // Select Stock ID by Picks Location ID StockObject stock1 = businessLogicLayer.SelectStockIDByPicksLocationID(pickLocationID); int stockID = stock1.stock_id; // Select Stock Location by Stock ID StockObject stock6 = businessLogicLayer.SelectStockLocationIDByID(stockID); int stockLocation = stock6.location_id; try { if (!int.Parse(pickIdInput.Text).Equals(pick1.pick_id)) { MessageBox.Show("The Pick ID provided does not exist."); pickIdInput.Focus(); return; } else { // Undo Stock Quantity StockObject stock2 = businessLogicLayer.UndoStockQuantity(pickQuantity, stockLocation); // Undo Stock Availability Status StockObject stock4 = businessLogicLayer.SelectStockQuantityByLocationID(stockLocation); int stockQuantity = stock4.quantity; if (stockQuantity > 0) { StockObject stockObject3 = businessLogicLayer.UndoStockAvailabilityStatus(stockLocation); } // Undo Location Allocation StockObject stock5 = businessLogicLayer.SelectStockAvailabilityStatusByStockLocation(stockLocation); bool stockAvailabilityStatus = stock5.availability_status; if (stockAvailabilityStatus.Equals(true)) { LocationObject location1 = businessLogicLayer.SetLocationAllocatedTrue(stockLocation); } // Undo Stock Allocated Quantity StockObject stock3 = businessLogicLayer.UndoStockAllocatedQuantity(pickQuantity, stockLocation); // Delete Current Pick PickObject pick = businessLogicLayer.DeleteCurrentPick(int.Parse(pickIdInput.Text)); // Undo Order Status OrderLineObject orderLine2 = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID); int orderLineQuantity = orderLine2.quantity; PickObject pick3 = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID); int pickQuantity2 = pick3.quantity; if (!pickQuantity2.Equals(orderLineQuantity)) { OrderObject order = businessLogicLayer.SetOrderStatusCreated(orderLineOrderID); } // Message Box MessageBox.Show("Pick: " + pickIdInput.Text + " has been deleted from the system. \n\nThe Pick Quantity has been unallocated in Stock. \n\nThe Stock Availability Status has been set back to True where relevant. \n\nThe Order Status has been set back to Created where relevant. \n\nThe Location Allocation has been set back to Allocated where relevant."); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }
public static extern IntPtr GetStockObject(StockObject i);
private void btnAddItem_Click(object sender, EventArgs e) { RepairObject objRepair = new RepairObject(); StockObject objStock = new StockObject(); objStock.inventoryID = cbInventID.Text; objRepair.ItemNo = txtItemNO.Text; if (objStock.inventoryID == "" || txtJobID2.Text == "" || txtItemNO.Text == "" || txtCost.Text == "") { MessageBox.Show("Please fill the all required feilds"); } else { objRepair.JobID = Convert.ToInt32(txtJobID2.Text); objStock.sellingPrice = Convert.ToDouble(txtCost.Text); DialogResult dr; dr = MessageBox.Show("Do you want to save the record", "Confirm", MessageBoxButtons.YesNo); if (dr.ToString() == "Yes") { try { MegaCoolMethods mcm = new MegaCoolMethods(); bool result = mcm.RepairInventory(objRepair, objStock); if (result) { MessageBox.Show("Successfully Saved", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); RepairFillGrid(); RepairInvFillGrid(); RepairInventoryFillGrid(); } else { MessageBox.Show("Unable to Save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (ApplicationException appEx) { MessageBox.Show(appEx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { throw ex; } } else { MessageBox.Show("Record is not saved", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Allocates an order line. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AllocateButton_Click(object sender, RoutedEventArgs e) { try { if (orderLineIdInput.Text.Equals("")) { MessageBox.Show("Please input the text box."); orderLineIdInput.Focus(); return; } else if (!Regex.IsMatch(orderLineIdInput.Text, "^[0-9]*$")) { MessageBox.Show("Please input only numerical characters into the text box."); orderLineIdInput.Focus(); return; } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } OrderLineObject orderLine = businessLogicLayer.CheckOrderLinesByID(int.Parse(orderLineIdInput.Text)); // Get Order Line Order ID OrderLineObject orderLine1 = businessLogicLayer.GetOrderLineOrderID(int.Parse(orderLineIdInput.Text)); int orderLineOrderID = orderLine1.order_id; // Get Order Line Product ID - Order Line Object OrderLineObject orderline2 = businessLogicLayer.GetOrderLineProductIDAndTitleOLObj(int.Parse(orderLineIdInput.Text)); int orderLineProductID = orderline2.product_id; // Get Order Line Product ID - Product Object ProductObject product1 = businessLogicLayer.GetOrderLineProductIDAndTitlePrObj(int.Parse(orderLineIdInput.Text)); string orderLineProductTitle = product1.title; // Get Product ID from Stock where Product ID = Order Line Product ID StockObject stockObject = businessLogicLayer.GetStockProductID(orderLineProductID); int stockProductID = stockObject.product_id; // Get Order Account ID OrderObject order1 = businessLogicLayer.GetOrderAccountID(orderLineOrderID); int orderAccountID = order1.account_id; // Get Order Warehouse ID OrderObject order2 = businessLogicLayer.GetOrderWarehouseID(orderLineOrderID); int orderWarehouseID = order2.warehouse_id; // Get Account, Product And Warehouse IDs from Stock By Order AID Order Line PID And Order WID StockObject stockObject987 = businessLogicLayer.GetStockAccountProductAndWarehouseID(orderAccountID, orderLineProductID, orderWarehouseID); int stockAccountID123 = stockObject987.account_id; int stockProductID123 = stockObject987.product_id; int stockWarehouseID123 = stockObject987.warehouse_id; // Get Nearest Available Stock - Stock Object StockObject stock1 = businessLogicLayer.GetAvailableStockStObj(orderLineProductID, orderAccountID, orderWarehouseID); int stockID = stock1.stock_id; int stockLocationID = stock1.location_id; // Get Nearest Available Stock - Location Object LocationObject location1 = businessLogicLayer.GetAvailableStockLoObj(orderLineProductID, orderAccountID, orderWarehouseID); string stockLocationCode = location1.location_code; // Get Order Line Quantity OrderLineObject orderLine3 = businessLogicLayer.GetOrderLineQuantity(int.Parse(orderLineIdInput.Text)); int orderLineQuantity = orderLine3.quantity; // Get Stock Quantity by Stock ID StockObject stock4 = businessLogicLayer.GetStockQuantityByID(stockID); int stockQuantity = stock4.quantity; // Get Stock Account ID, Product ID And Warehouse ID By Stock ID StockObject stockWhatever = businessLogicLayer.GetStockAccountProductAndWarehouseIDByStockID(stockID); int stockAccountID = stockWhatever.account_id; int stockProductID2 = stockWhatever.product_id; int stockWarehouseID = stockWhatever.warehouse_id; // Get Stock Sum By Product ID int stockSum = 0; if (!(stockAccountID.Equals(0) && stockProductID2.Equals(0) && stockWarehouseID.Equals(0))) { StockObject stock5 = businessLogicLayer.GetStockSumByProductID(stockAccountID, stockProductID2, stockWarehouseID); stockSum = stock5.quantity; } try { // Order Line Does not Exist if (!int.Parse(orderLineIdInput.Text).Equals(orderLine.order_line_id)) { MessageBox.Show("The Order Line ID provided does not exist."); orderLineIdInput.Focus(); return; } // Product Not in Stock else if (!orderLineProductID.Equals(stockProductID)) { MessageBox.Show("The Product pertaining to that Order Line ID is not in Stock."); orderLineIdInput.Focus(); return; } // Account, Product and Warehouse do not match in Stock else if (!(orderAccountID.Equals(stockAccountID123) && orderLineProductID.Equals(stockProductID123) && orderWarehouseID.Equals(stockWarehouseID123))) { MessageBox.Show("The Order Line Provided does not have a matching Account, Product and Warehouse in Stock."); orderLineIdInput.Focus(); return; } // Not Enough Stock else if (stockSum < orderLineQuantity) { MessageBox.Show("There is not enough Stock of the Product pertaining to that Order Line ID to fully allocate the Order Line."); orderLineIdInput.Focus(); return; } else { // Implement if time permits // If stock matches exact then go to that one (i.e. 50 to 50 or 25 to 25) instead of just nearest - Change query used and more if statements if (orderLineQuantity > stockQuantity) { int orderLineQuantityRemaining = 0; while (orderLineQuantityRemaining < orderLineQuantity) { // Get Nearest Available Stock - Stock ID & Location ID StockObject stock123 = businessLogicLayer.GetAvailableStockStObj(orderLineProductID, orderAccountID, orderWarehouseID); int stockID2 = stock123.stock_id; int stockLocationID123 = stock123.location_id; // Get Nearest Available Stock - Location Code LocationObject location123 = businessLogicLayer.GetAvailableStockLoObj(orderLineProductID, orderAccountID, orderWarehouseID); string stockLocationCode2 = location123.location_code; // Get Stock Quantity by Stock ID StockObject stock12345 = businessLogicLayer.GetStockQuantityByID(stockID2); int stockQuantityTest = stock12345.quantity; // Nearest Available Stock - Set Availability Status to False - Locking it in for this order StockObject stock1234 = businessLogicLayer.SetAvailabilityFalse(stockID2); if (stockQuantityTest < orderLineQuantity - orderLineQuantityRemaining) { // Generate Pick PickObject pickTest = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID123, stockLocationCode2, orderLineProductID, orderLineProductTitle, stockQuantityTest); // Update Stock Quantity - stockQuantity StockObject stockTest = businessLogicLayer.UpdateStockQuantity(stockQuantityTest, stockID2); } else { // Generate Pick PickObject pickTest123 = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID123, stockLocationCode2, orderLineProductID, orderLineProductTitle, orderLineQuantity - orderLineQuantityRemaining); // Update Stock Quantity - orderLineQuantity - orderLineQuantityRemaining StockObject stockTest2 = businessLogicLayer.UpdateStockQuantity(orderLineQuantity - orderLineQuantityRemaining, stockID2); } // Nearest Available Stock - Set Availability Status to True - Opening it up for future orders StockObject stock12345678 = businessLogicLayer.GetStockQuantityByID(stockID2); int stockQuantityTest2 = stock12345678.quantity; if (stockQuantityTest2 > 0) { StockObject stock6 = businessLogicLayer.SetAvailabilityTrue(stockID2); } // Update Location 'allocated' if Stock Availability Status equals 0 (By Stock ID) StockObject stockWhat = businessLogicLayer.GetStockAvailabilityStatus(stockID2); bool stockAvailabilityStatus = stockWhat.availability_status; if (stockAvailabilityStatus.Equals(false)) { LocationObject location2 = businessLogicLayer.SetLocationAllocatedFalse(stockLocationID123); MessageBox.Show("All Stock from Location ID: " + stockLocationID123 + " has been taken and as such, it has been set to Available again."); } // Get Pick Quantity by Order Line ID + Set orderLineQuantityRemaining = pickQuantity PickObject pickTest2 = businessLogicLayer.GetPickQuantityByOrderLineID(int.Parse(orderLineIdInput.Text)); int pickQuantity = pickTest2.quantity; orderLineQuantityRemaining = pickQuantity; } // Update Orders Status to Allocated (if Order Line Quantity matches that of Pick Quantity where Order Line Matches) OrderLineObject orderLine123 = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID); int orderLineQuantity2 = orderLine123.quantity; PickObject pickTest3 = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID); int pickQuantity2 = pickTest3.quantity; if (pickQuantity2.Equals(orderLineQuantity2)) { OrderObject order3 = businessLogicLayer.SetOrderStatusAllocated(orderLineOrderID); MessageBox.Show("All Order Lines belonging to Order: " + orderLineOrderID + " have now been Allocated."); } // Message Box MessageBox.Show("Order Line: " + orderLineIdInput.Text + " has been allocated. \n\nA pick has been created, please see the Picks table for more information."); return; } else { // Set Nearest Available Stock - Availability Status to false - Locking it in for this order StockObject stock2 = businessLogicLayer.SetAvailabilityFalse(stockID); // Generate Pick PickObject pick1 = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID, stockLocationCode, orderLineProductID, orderLineProductTitle, orderLineQuantity); // Update Stock Quantity - orderLineQuantity StockObject stock3 = businessLogicLayer.UpdateStockQuantity(orderLineQuantity, stockID); // Nearest Available Stock - Set Availability Status to True - Opening it up for future orders StockObject stock12345 = businessLogicLayer.GetStockQuantityByID(stockID); int stockQuantity2 = stock12345.quantity; if (stockQuantity2 != 0) { StockObject stock6 = businessLogicLayer.SetAvailabilityTrue(stockID); } // Update Location 'allocated' to false if Stock Availability Status equals 0 (empty) StockObject stockWhat = businessLogicLayer.GetStockAvailabilityStatus(stockID); bool stockAvailabilityStatus = stockWhat.availability_status; if (stockAvailabilityStatus.Equals(false)) { LocationObject location2 = businessLogicLayer.SetLocationAllocatedFalse(stockLocationID); MessageBox.Show("All Stock from Location ID: " + stockLocationID + " has been taken and as such, it has been set to Available again."); } // Update Orders Status to Allocated (if Order Line Quantity matches that of Pick Quantity where Order Line Matches) OrderLineObject orderLine123 = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID); int orderLineQuantity2 = orderLine123.quantity; PickObject pickTest3 = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID); int pickQuantity2 = pickTest3.quantity; if (pickQuantity2.Equals(orderLineQuantity2)) { OrderObject order3 = businessLogicLayer.SetOrderStatusAllocated(orderLineOrderID); MessageBox.Show("All Order Lines belonging to Order: " + orderLineOrderID + " have now been Allocated."); } // Message Box MessageBox.Show("Order Line: " + orderLineIdInput.Text + " has been allocated. \n\nA pick has been created, please see the Picks table for more information."); return; } } } catch (Exception ex) { MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString()); } }