public List <StockStats> Gainers() { string IEXTrading_API_PATH = BASE_URL + "stock/market/list/gainers"; string _stocklist = ""; List <StockStats> _list = null; StockDetails sd = new StockDetails(); httpClient.BaseAddress = new Uri(IEXTrading_API_PATH); HttpResponseMessage response = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { _stocklist = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!_stocklist.Equals("")) { _list = JsonConvert.DeserializeObject <List <StockStats> >(_stocklist, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } return(_list); }
public async Task <IActionResult> SellStock(StockDetails stockdetails) { try { if (CheckValid()) { int portfolioid = Convert.ToInt32(HttpContext.Session.GetString("Id")); _log4net.Info("Selling the stocks of user with id = " + portfolioid); AssetSaleResponse assetSaleResponse = await _customerRepository.SellStocks(portfolioid, stockdetails); _log4net.Info("sale of stock of user with id" + portfolioid + "done"); Sale _sale = new Sale(); _sale.PortFolioID = portfolioid; _sale.NetWorth = assetSaleResponse.Networth; _sale.status = assetSaleResponse.SaleStatus; _saleRepository.Add(_sale); return(View("Reciept", assetSaleResponse)); } else { return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { _log4net.Error("An exception occured in the" + nameof(SellStock) + " while selling mutualFund. The message is:" + ex.Message); return(RedirectToAction("Index", "Home")); } }
public void Add(StockDetails stockDetails) { _insertParameters = new stock_DetailInsertDALDataParameters(stockDetails); DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName); dbHelper.Run(base.ConnectionString, _insertParameters.Parameters); }
private void LoadRecord() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["stockid"], Session.SessionID)); Stock clsStock = new Stock(); StockDetails clsDetails = clsStock.Details(iID); Branch clsBranch = new Branch(clsStock.Connection, clsStock.Transaction); cboBranch.DataTextField = "BranchCode"; cboBranch.DataValueField = "BranchID"; cboBranch.DataSource = clsBranch.ListAsDataTable().DefaultView; cboBranch.DataBind(); clsStock.CommitAndDispose(); lblStockID.Text = clsDetails.StockID.ToString(); cboBranch.SelectedIndex = cboBranch.Items.IndexOf(cboBranch.Items.FindByValue(clsDetails.BranchID.ToString())); lblTransactionNo.Text = clsDetails.TransactionNo; lblStockDate.Text = clsDetails.StockDate.ToString("MMM. dd, yyy HH:mm:ss"); txtSupplier.Text = clsDetails.SupplierName; lblSupplierID.Text = clsDetails.SupplierID.ToString(); txtStockTypeCode.Text = clsDetails.StockTypeCode; txtStockTypeCode.ToolTip = clsDetails.StockTypeID.ToString(); txtStockDescription.Text = clsDetails.StockTypeDescription; txtStockDirection.Text = clsDetails.StockDirection.ToString("G"); txtStockRemarks.Text = clsDetails.Remarks; LoadItems(); }
public void Delete(StockDetails val) { _insertParameters = new stockDetailsDeleteDALDataParameters(val); DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName); dbHelper.Run(base.ConnectionString, _insertParameters.Parameters); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockDetails vendorList = (from a in db.StockMasters join b in db.StoreMasters on a.StoreId equals b.RecordId join c in db.ClassMasters on a.ClassId equals c.RecordId join d in db.ItemMasters on a.ItemId equals d.RecordId join e in db.UomMasters on a.UomId equals e.RecordId join f in db.VendorMasters on a.VendorId equals f.RecordId join g in db.PurchaseOrders on a.PInvoiceNo equals g.OrderNo join u in db.UserMasters on a.EmployeeID equals u.EmployeeCode where a.RecordId == id select new StockDetails() { stock = a, store = b, classMas = c, item = d, uom = e, vendor = f, po = g, empName = u.UserName }).Single(); if (vendorList == null) { return(HttpNotFound()); } return(View(vendorList)); }
public IActionResult AddStock(StockDetailsVm stockdetailsvm) { var stck = _context.StockDetails.AsNoTracking().Where(s => s.IngredientId == stockdetailsvm.IngredientId).LastOrDefault(); if (stck != null) { stockdetailsvm.AvailableStock = stockdetailsvm.Quantity * 1000 + stck.AvailableStock; } else { stockdetailsvm.AvailableStock = stockdetailsvm.Quantity * 1000; } var ingredientlist = _context.Ingredient.ToList(); ingredientlist.Insert(0, new Ingredient { IngredientId = 0, IngredientName = "Select Raw Ingredient" }); ViewBag.IngredientList = ingredientlist; StockDetails stockdetails = new StockDetails() { IngredientId = stockdetailsvm.IngredientId, Quantity = stockdetailsvm.Quantity, StockInDate = DateTime.Now, AvailableStock = stockdetailsvm.AvailableStock, }; _context.StockDetails.Add(stockdetails); _context.SaveChanges(); ModelState.Clear(); ViewBag.Success = "You have succesfully added."; return(View()); }
public YahooStockModel GetStockDetails() { try { StockDetails[] stocks = new StockDetails[2]; Task <IReadOnlyDictionary <string, Security> > task = Yahoo.Symbols("FOLD", "GOOG").Fields(Field.Symbol, Field.LongName, Field.RegularMarketPrice, Field.RegularMarketChangePercent).QueryAsync(); IReadOnlyDictionary <string, Security> results = task.Result; int index = 0; foreach (Security security in results.Values) { StockDetails stock = new StockDetails() { StockCode = security[Field.Symbol], Description = security[Field.LongName], CurrentPrice = security[Field.RegularMarketPrice], MarketChanges = security[Field.RegularMarketChangePercent] }; stocks[index] = stock; index++; } return(new YahooStockModel() { Stocks = stocks }); } catch { throw new WebException(@"There is an ERROR using Yahoo Finance API."); } }
public async Task <IActionResult> Edit(string id, [Bind("ProductID,Name,Qty,Price")] StockDetails stockDetails) { if (id != stockDetails.ProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stockDetails); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockDetailsExists(stockDetails.ProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(stockDetails)); }
private void Transfer() { if (isChkListSingle() == true) { string stID = GetFirstID(); if (stID != null) { Int64 iID = Convert.ToInt64(stID); Stock clsStock = new Stock(); StockDetails clsDetails = clsStock.Details(iID); clsStock.CommitAndDispose(); if (clsDetails.StockTypeID.ToString() == Constants.STOCK_TYPE_TRANSFER_TO_BRANCH_ID) { string stParam = "?task=" + Common.Encrypt("transfer", Session.SessionID) + "&stockid=" + Common.Encrypt(stID, Session.SessionID); Response.Redirect("Default.aspx" + stParam); } else { string stScript = "<Script>"; stScript += "window.alert('Sorry you cannot transfer this transaction. Please select a TRANSFER TO BRANCH transaction.')"; stScript += "</Script>"; Response.Write(stScript); } } } else { string stScript = "<Script>"; stScript += "window.alert('Cannot transfer more than one record. Please select at least one record to transfer.')"; stScript += "</Script>"; Response.Write(stScript); } }
public JsonResult GetQueueDetails() { IList <StockDetails> queuedata = new List <StockDetails>(); var queuelist = GetQueueDetails("racequeue"); StockDetails queustock = new StockDetails(); if (queuelist != null) { foreach (var lst in queuelist) { queustock = new StockDetails(); queustock = CommonMethods.JsonDeserialize <StockDetails>(lst.Message); queustock.tempDate = Convert.ToString(queustock.CreateDateTime); queuedata.Add(queustock); } } queuelist = GetQueueDetails("raceoutqueue"); if (queuelist != null) { foreach (var lst in queuelist) { queustock = new StockDetails(); queustock = CommonMethods.JsonDeserialize <StockDetails>(lst.Message); queustock.tempDate = Convert.ToString(queustock.CreateDateTime); queuedata.Add(queustock); } } queuedata = queuedata.OrderByDescending(a => a.CreatedDateTime).Take <StockDetails>(5).ToList(); return(Json(new { queueData = queuedata }, JsonRequestBehavior.AllowGet)); }
internal static async Task <StockDetails> AStockDetailsdbAsync(int id) { var sDetails = new StockDetails(); try { string stm = SISDBQueryCollection.qGetAStockDetails; using (SQLiteConnection conn = SISDBContext.GetdbConnection()) { using (SQLiteCommand cmd = new SQLiteCommand(stm, conn)) { cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@varStockID", id); using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow)) { while (await reader.ReadAsync()) { sDetails.Load((SQLiteDataReader)reader); } } } return(sDetails); } } catch (SQLiteException ex) { System.Diagnostics.Debug.WriteLine("SQLiteException:" + ex.Message); throw ex; } catch (Exception ex) { throw ex; } }
public StockDetails GetLatestStockDetails(string stockCode) { if (String.IsNullOrEmpty(stockCode)) { throw new ArgumentException("Argument cannot be null or empty."); } StockDetails latestStockDetailsForStockCode = _db.StockValue .AsNoTracking() .Where(x => x.Stock.Code.ToLower().Equals(stockCode.ToLower())) .OrderByDescending(x => x.PublicationDate) .Take(1) .Select(x => new StockDetails { Code = x.Stock.Code, Name = x.Stock.Name, Price = x.Price, Unit = x.Unit, AvailableAmount = x.Stock.AvailableAmount, PublicationDate = x.PublicationDate }) .FirstOrDefault(); return(latestStockDetailsForStockCode); }
private void btnSace_Click(object sender, EventArgs e) { BookDetails bd = new BookDetails(); StockDetails sd = new StockDetails(); bd.BookName = txtBookName.Text; bd.Author = txtAuthorName.Text; bd.ISBN = txtISBN.Text; sd.Quantity = Convert.ToInt32(txtQuantity.Text); bd.AddedDate = DateTime.Today.ToShortDateString(); bd.IsReference = (chkIsReference.Checked ? true : false).ToString(); //image convertion from jpg to byte ms = new MemoryStream(); pictureBox1.Image.Save(ms, ImageFormat.Jpeg); byte[] photo_aray = new byte[ms.Length]; ms.Position = 0; ms.Read(photo_aray, 0, photo_aray.Length); bd.Photo = photo_aray; int i = blb.addBook(bd, sd); if (i > 0) { MessageBox.Show("Book/s Added Succesfully"); } else { MessageBox.Show("Operation Failed"); } loadGrid(); }
/// <summary> /// Insert Stocks /// </summary> /// <param name="entity"></param> /// <returns>Message</returns> public async Task <string> InsertStocks(Stocks entity) { var result = string.Empty; try { StockDetails stockdetail = new StockDetails(); var dataProduct = new StocksRepository(logger).GetAll().Result.FirstOrDefault(c => c.ProductId.Equals(entity.ProductId)); stockdetail.StockQuantity = dataProduct.Quantity; stockdetail.TransQuantity = decimal.Subtract(dataProduct.Quantity, entity.Quantity); stockdetail.TotalQuantity = entity.Quantity; stockdetail.Date = entity.Date; stockdetail.PurcheaseId = entity.PurcheaseId; stockdetail.SalesId = entity.SalesId; stockdetail.PurcheaseReturnId = entity.PurcheaseReturnId; stockdetail.SalesReturnId = entity.SalesReturnId; stockdetail.StockStutes = entity.StockStutes; result = await new StockDetailsBL(logger).InsertStockDetails(stockdetail); result = await new StocksRepository(logger).Insert(entity); return(result); } catch (Exception ex) { logger.Error(ex.Message); throw ex; } }
public int UpdateStockDetails(ref StockDetails Entity_Call, out string strError) { int iInsert = 0; strError = string.Empty; try { SqlParameter pAction = new SqlParameter(StockDetails._Action, SqlDbType.BigInt); SqlParameter pStockID = new SqlParameter(StockDetails._StockID, SqlDbType.BigInt); SqlParameter pStockTypeID = new SqlParameter(StockDetails._StockTypeID, SqlDbType.BigInt); SqlParameter pStockDate = new SqlParameter(StockDetails._StockDate, SqlDbType.DateTime); SqlParameter pProductID = new SqlParameter(StockDetails._ProductID, SqlDbType.BigInt); SqlParameter pStockLocationID = new SqlParameter(StockDetails._StockLocationID, SqlDbType.BigInt); SqlParameter pStockQty = new SqlParameter(StockDetails._StockQty, SqlDbType.Decimal); SqlParameter pProductMRP = new SqlParameter(StockDetails._ProductMRP, SqlDbType.Decimal); SqlParameter pStockUnitID = new SqlParameter(StockDetails._StockUnitID, SqlDbType.BigInt); SqlParameter pTransID = new SqlParameter(StockDetails._TransID, SqlDbType.BigInt); pAction.Value = 2; pStockID.Value = Entity_Call.StockID; pStockTypeID.Value = Entity_Call.StockTypeID; pStockDate.Value = Entity_Call.StockDate; pProductID.Value = Entity_Call.ProductID; pStockLocationID.Value = Entity_Call.StockLocationID; pStockQty.Value = Entity_Call.StockQty; pProductMRP.Value = Entity_Call.ProductMRP; pStockUnitID.Value = Entity_Call.StockUnitID; pTransID.Value = Entity_Call.TransID; SqlParameter[] Param = new SqlParameter[] { pAction, pStockID, pStockTypeID, pStockDate, pProductID, pStockLocationID, pStockQty, pProductMRP, pStockUnitID, pTransID }; Open(CONNECTION_STRING); BeginTransaction(); iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, StockDetails.SP_Stock_Details, Param); if (iInsert > 0) { CommitTransaction(); } else { RollBackTransaction(); } } catch (Exception ex) { RollBackTransaction(); strError = ex.Message; } finally { Close(); } return(iInsert); }
public static DataSet GetStockDetailSearchExpiry(StockDetails val) { DataSet resultSet = new DataSet(); StockExpiryDetailsDal instance = new StockExpiryDetailsDal(); resultSet = instance.View(val); return(resultSet); }
public static DataSet GetStockDetailSearch(StockDetails val) { DataSet resultSet = new DataSet(); StockDetailSearchDAL instance = new StockDetailSearchDAL(); resultSet = instance.View(val); return(resultSet); }
public IActionResult BuyStock(string name) { //SellingViewModel sell = new SellingViewModel(); StockDetails sd = new StockDetails(); sd.StockName = name; return(View(sd)); }
private void UpdateGrid(StockDetails data, int count) { dataGridView1.Rows[data.StockId].Cells[0].Value = data.StockName; dataGridView1.Rows[data.StockId].Cells[1].Value = data.StockPrice; dataGridView1.Rows[data.StockId].Cells[2].Value = data.StockChange; lblCount.Invoke(new Action(() => lblCount.Text = count.ToString())); lblTime.Invoke(new Action(() => lblTime.Text = data.Time.ToString())); }
/// <summary> /// Starts the processing on shares. /// </summary> public void ShareProcessingStart() { StockDetails stocdetails = new StockDetails(); while (true) { Console.WriteLine("Choose an option"); Console.WriteLine("1) To buy Share"); Console.WriteLine("2) To Sell a Share"); Console.WriteLine("3) To view Existing Shares"); Console.WriteLine("4) View Stock Symobol Purchased"); string stringOption = Console.ReadLine(); if (InventoryManagementProgram.Utility.IsNumber(stringOption) == false) { Console.WriteLine("Invalid input"); continue; } int option = Convert.ToInt32(stringOption); //// Calls the method based on choosen option by the user. switch (option) { case 1: { InputData.TakeUserInput(option); break; } case 2: { InputData.TakeUserInput(option); break; } case 3: { stocdetails.PrintReport(); break; } case 4: { StockDetails stockDetails = new StockDetails(); stockDetails.PrintSymbols(); break; } default: { return; } } } }
/// <summary> /// Takes as input the stock you want to sell and sends a sale response object back /// </summary> /// <param name="portfolioid"></param> /// <param name="stockdetails"></param> /// <returns></returns> public async Task <AssetSaleResponse> SellStocks(int portfolioid, StockDetails stockdetails) { try { var fetchPortFolio = _configuration["FetchingPortFolioById"]; var fetchNetWorth = _configuration["FetchingNetWorthByPortFolio"]; var fetchResponse = _configuration["FetchingSellDetails"]; PortFolioDetails current = new PortFolioDetails(); PortFolioDetails toSell = new PortFolioDetails(); _log4net.Info("Selling Stock " + stockdetails.StockName + " of user with id = " + portfolioid); using (var client = new HttpClient()) { using (var response = await client.GetAsync(fetchPortFolio + portfolioid)) { _log4net.Info("Fetching his portFolio"); string apiResponse = await response.Content.ReadAsStringAsync(); current = JsonConvert.DeserializeObject <PortFolioDetails>(apiResponse); _log4net.Info("The portfolio " + JsonConvert.SerializeObject(current)); } } toSell.PortFolioId = portfolioid; toSell.StockList = new List <StockDetails> { stockdetails }; toSell.MutualFundList = new List <MutualFundDetails>() { }; List <PortFolioDetails> list = new List <PortFolioDetails> { current, toSell }; AssetSaleResponse assetSaleResponse = new AssetSaleResponse(); StringContent content = new StringContent(JsonConvert.SerializeObject(list), Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { using (var response = await client.PostAsync(fetchResponse, content)) { _log4net.Info("Fetching the response of sale of stock " + stockdetails.StockName + " of user with id " + portfolioid); string apiResponse = await response.Content.ReadAsStringAsync(); assetSaleResponse = JsonConvert.DeserializeObject <AssetSaleResponse>(apiResponse); _log4net.Info("The response is " + JsonConvert.SerializeObject(assetSaleResponse)); } } return(assetSaleResponse); } catch (Exception ex) { _log4net.Info("An exception occured:" + ex.Message); return(null); } }
private void btnAddNewStock_Click(object sender, EventArgs e) { if (cboProductName.SelectedIndex == 0) { MessageBox.Show("Please Select Product Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); cboProductName.Focus(); return; } if (cboSupplierName.SelectedIndex == 0) { MessageBox.Show("Please Select Supplier Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); cboSupplierName.Focus(); return; } if (txtQuantity.Text == "") { MessageBox.Show("Please Enter Product Quantity!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); txtQuantity.Focus(); return; } StockDetails sd = new StockDetails(); sd.StockNo = txtStockNo.Text; sd.ProductID = Convert.ToInt32(cboProductName.SelectedValue); sd.SupplierID = Convert.ToInt32(cboSupplierName.SelectedValue); sd.Quantity = Convert.ToInt32(txtQuantity.Text); sd.Date = dateTimePicker1.MinDate; bool isexists = bts.CheckExistingProductStockById(Convert.ToInt32(cboProductName.SelectedValue.ToString())); if (isexists) { TempStockDetails tsd = new TempStockDetails(); tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString()); tsd.Quantity = tsd.Quantity + Convert.ToInt32(txtQuantity.Text); int j = bts.UpdateExistingTempStock(tsd); } else { TempStockDetails tsd = new TempStockDetails(); tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString()); tsd.Quantity = Convert.ToInt32(txtQuantity.Text); int k = bts.AddNewTempStock(tsd); } int i = blst.AddNewStock(sd); if (i > 0) { MessageBox.Show("Stock Added Successfully", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information); Clear(); LoadStockID(); } }
public DataSet View(StockDetails val) { DataSet ds; _insertParameters = new StockExpiryDetailsDalDataParameters(val); DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName); ds = dbHelper.Run(ConnectionString, _insertParameters.Parameters); return(ds); }
private void ShowSalesReportForm() { StockDetails Itm = new StockDetails(); Itm.TopLevel = false; this.Controls.Add(Itm); Itm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; Itm.Dock = DockStyle.Fill; Itm.BringToFront(); Itm.Show(); }
public async Task <IActionResult> Create([Bind("ProductID,Name,Qty,Price")] StockDetails stockDetails) { if (ModelState.IsValid) { _context.Add(stockDetails); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stockDetails)); }
public int AddNewStock(StockDetails sd) { tblStock ts = new tblStock(); ts.StockNo = sd.StockNo; ts.ProductID = sd.ProductID; ts.SupplierID = sd.SupplierID; ts.Quantity = sd.Quantity; ts.Date = DateTime.Now; _db.tblStocks.Add(ts); return(_db.SaveChanges()); }
public int UpdateStock(StockDetails sd) { tblStock ts = _db.tblStocks.Where(s => s.StockID == sd.StockID).FirstOrDefault(); ts.StockID = sd.StockID; ts.StockNo = sd.StockNo; ts.ProductID = sd.ProductID; ts.SupplierID = sd.SupplierID; ts.Quantity = sd.Quantity; ts.Date = DateTime.Now; return(_db.SaveChanges()); }
private void BtnSave_Click(object sender, EventArgs e) { InvoiceDetails ind = new InvoiceDetails(); ind.InvoiceNo = txtInvoiceNumber.Text; ind.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); ind.CustomerId = customerid; ind.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); int k = blin.CreateInvoice(ind); for (int i = 0; i < dataGridView.Rows.Count; i++) { PurchaseDetails pd = new PurchaseDetails(); pd.InvoiceId = k; pd.ProductId = Convert.ToInt32(dataGridView.Rows[i].Cells["colProductId"].Value.ToString()); pd.CategoryId = Convert.ToInt32(dataGridView.Rows[i].Cells["colCategoryId"].Value.ToString()); pd.UnitPrice = Convert.ToDecimal(dataGridView.Rows[i].Cells["colUnitPrice"].Value.ToString()); pd.Quantity = Convert.ToInt32(dataGridView.Rows[i].Cells["colQuantity"].Value.ToString()); pd.Total = Convert.ToDecimal(dataGridView.Rows[i].Cells["colTotal"].Value.ToString()); pd.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); StockDetails sd = bls.GetStockByProductId(pd.ProductId); if (sd.Quantity > 0) { sd.ProductId = pd.ProductId; sd.Quantity = sd.Quantity + pd.Quantity; int m = bls.UpdateStock(sd); } else if (sd.ProductId == pd.ProductId) { sd.ProductId = pd.ProductId; sd.Quantity = sd.Quantity + pd.Quantity; int m = bls.UpdateStock(sd); } else { StockDetails sds = new StockDetails(); sds.StockId = sd.StockId; sds.ProductId = pd.ProductId; sds.Quantity = pd.Quantity; int l = bls.InsertStock(sds); } bp.CreatePurchase(pd); } MessageBox.Show("Purchase Done"); dataGridView.Rows.Clear(); i = 0; }
/// <summary> /// Update StockDetails /// </summary> /// <param name="entity"></param> /// <returns>Message</returns> public async Task <string> UpdateStockDetails(StockDetails entity) { try { var result = await new StockDetailsRepository(logger).Update(entity); return(result); } catch (Exception ex) { logger.Error(ex.Message); throw ex; } }