private financial PopulateFinancial() { financial fin = new financial(); fin.stock_id = int.Parse(TickerComboBox.SelectedValue.ToString()); fin.financial_date = FinancialDateTimePicker.Value; fin.asset = decimal.Parse(AssetTextBox.Text.Trim()); fin.liabilities = decimal.Parse(LiabilitiesTextBox.Text.Trim()); fin.sales = decimal.Parse(SalesTextBox.Text.Trim()); fin.equity = decimal.Parse(EquityTextBox.Text.Trim()); fin.gross_profit = decimal.Parse(GrossProfitTextBox.Text.Trim()); fin.net_income = decimal.Parse(NetIncomeTextBox.Text.Trim()); fin.cash_flow = decimal.Parse(CashFlowTextBox.Text.Trim()); return(fin); }
// The set(string[]) method sets values for the struct object based on line values passed as a parameter public static financial set(string[] values) { financial a = new financial(); a.field1 = values[0]; a.field2 = values[1]; a.field3 = Convert.ToUInt16(values[2]); a.field4 = Convert.ToUInt16(values[3]); a.field5 = Convert.ToUInt16(values[4]); a.field6 = Convert.ToUInt16(values[5]); a.field7 = Convert.ToUInt64(values[6]); a.field8 = Convert.ToDouble(values[7]); a.field9 = Convert.ToDouble(values[8]); a.field10 = Convert.ToChar(values[9]); return(a); }
public bool SaveFinancialReport(financial financial, out string errorMessage) { bool success = true; errorMessage = String.Empty; try { entities.financials.Add(financial); entities.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.InnerException.Message.ToString()); errorMessage = e.InnerException.InnerException.Message; success = false; } return(success); }
private void SaveFinancialReport() { string message = String.Empty; financial financial = this.PopulateFinancial(); bool recorded = this.CheckFinancialDate((int)TickerComboBox.SelectedValue, FinancialDateTimePicker.Value.Date); if (!recorded) { bool success = this.financialRepo.SaveFinancialReport(financial, out message); if (success) { MessageBox.Show("Financial Report Data has been saved"); } } else { MessageBox.Show("Financial Report for " + TickerComboBox.Text + " at the date of " + FinancialDateTimePicker.Value.Date + " already recorded in database"); this.ClearFields(); } }
static void Main(string[] args) { // compile the path to the sample file // this program gets the file name from the command line arguments // Click Project > CVSParser Properties > Debug > Start Options > Command Line Arguments List <string[]> csvData = new List <string[]>(); string[] header = new string[11]; List <financial> finData = new List <financial>(); for (int run = 0; run < 5; run++) { csvData = new List <string[]>(); string fullPath = fileBasePath + args[run]; // initialise the data structures required for the solution StreamReader reader = new StreamReader(fullPath); string line = null; line = reader.ReadLine(); header = line.Split(','); reader.Close(); // call the main parse method parseData(fullPath, header, csvData); for (int i = 0; i < csvData.Count; i++) { financial a = new financial(); //Make sure the headers aren't read into the fields moving from 1 csv file to the next if (formatData(csvData[i][0]) == "ALPHA_CODE") { i++; } //csvData[col][row] //temp is used to check values in error testing //string temp = ""; //temp = formatData(csvData[i][*]); a.field1 = csvData[i][0]; a.field2 = csvData[i][1]; a.field3 = Convert.ToUInt16(formatData(csvData[i][2])); a.field4 = Convert.ToUInt16(formatData(csvData[i][3])); a.field5 = Convert.ToUInt16(formatData(csvData[i][4])); a.field6 = Convert.ToUInt32(formatData(csvData[i][5])); a.field7 = Convert.ToUInt64(formatData(csvData[i][6])); a.field8 = Convert.ToDouble(formatData(csvData[i][7])); a.field9 = Convert.ToDouble(formatData(csvData[i][8])); a.field10 = Convert.ToChar(formatData(csvData[i][9])); // There are not 53 weeks in a year, if so add 1 to year and set the week to 1 (the first week of a new year) if (a.field4 == 53 || a.field6 == 01) { i++; } else { finData.Add(a); } } // make the console read a character followed by ENTER from the keyboard // this so that it does not close abruptly before we see the output } writeData(fileBasePath + "filedata.csv", header, finData); Console.WriteLine("Finished."); Console.WriteLine("YRK Stock Close: " + stockClose("YRK", 2014, finData, fileBasePath)); Console.WriteLine("YRK Total Share Sales for final week: " + totalShareSales("YRK", 2014, finData, fileBasePath)); top5shares(2012, finData, fileBasePath); Console.WriteLine(marketCap(2013, finData, fileBasePath)); Console.Read(); }
static string getFinCSV(financial a) { return(a.field1 + ',' + a.field2 + ',' + a.field3 + ',' + a.field4 + ',' + a.field5 + ',' + a.field6 + ',' + a.field7 + ',' + a.field8 + ',' + a.field9 + ',' + a.field10); }