private void GetTblData() { myData = sql.GetData(TPTbl, "*"); ExistingRiskTests = myData.Count; for (int i = 0; i < myData.Count; i++) { string[] data = new string[myData[i]._SubResults.Count]; string tmpStr = ""; for (int j = 0; j < data.Length; j++) { if (IsRiskTests) { if (j <= 1) { data[j] = myData[i]._SubResults[j].ToString(); } if (j == 2) { tmpStr = myData[i]._SubResults[j].ToString(); } if (j > 2) { data[j] = (GlobalFunc.ToDouble(myData[i]._SubResults[j].ToString()) * 100).ToString(); } } else { data[j] = myData[i]._SubResults[j].ToString(); if (IsCoinParams && j == 1) { data[j] = ToStrDate(data[j]); } } } dataGrid.Rows.Add(data); if (IsRiskTests) { List <SQLFunc.SubResults> DBdata = sql.GetData(SubSectorTbl, "ProjectSubType", "ProjectType='" + data[1] + "'"); DataGridViewComboBoxCell cellBox = new DataGridViewComboBoxCell(); for (int k = 0; k < DBdata.Count; k++) { cellBox.Items.Add(DBdata[k]._SubResults[0].ToString()); } dataGrid.Rows[i].Cells[2] = cellBox; dataGrid.Rows[i].Cells[2].Value = myData[i]._SubResults[2].ToString(); } } }
private void computeBtn_Click(object sender, EventArgs e) { double RateDuringCP = GlobalFunc.ToDouble(rateDuringCPBox.Text) / 100; double Conversion = GlobalFunc.ToDouble(conversionBox.Text) / 100; double EquityPayingInterest = GlobalFunc.ToDouble(equityPayingInterestBox.Text) / 100; double ExpectedFirstDiv = GlobalFunc.ToDouble(expectedFirstDivBox.Text) / 100; double tmp1 = Conversion / (1 - Conversion) * EquityPayingInterest * RateDuringCP; double tmp2 = Conversion / (1 - Conversion) * ExpectedFirstDiv; double result = Math.Round(RateDuringCP + tmp1 - tmp2, 4) * 100; rateAfterCPLbl.Text = result.ToString() + "%"; }
private void saveBtn_Click(object sender, EventArgs e) { TotalEquity = 0; for (int i = 0; i < equityScheduleGrid.Rows.Count; i++) { if (equityScheduleGrid.Rows[i].Cells[0].Value == null) { Schedule[i] = 0; } else { Schedule[i] = Math.Round(GlobalFunc.ToDouble(equityScheduleGrid.Rows[i].Cells[0].Value.ToString()), 2); } TotalEquity += Schedule[i]; } this.Hide(); }
private void updateBtn_Click(object sender, EventArgs e) { if (IsCoinParams) { int Res; int Div = Math.DivRem(Convert.ToInt32(dataGrid.Rows[0].Cells[0].Value), 3, out Res); if (Res != 0 || Div == 0) { MessageBox.Show("Dividend payment frequency has to be eithr 3, 6 or 12 months"); return; } string data = ""; data += "PaymentFrequency='" + dataGrid.Rows[0].Cells[0].Value.ToString() + "'"; data += ",FirstPaymentDate='" + dataGrid.Rows[0].Cells[1].Value.ToString() + "'"; sql.UpdateTable(TPTbl, data); } else if (IsRiskTests) { for (int i = 0; i < dataGrid.Rows.Count - 1; i++) { string Country = dataGrid.Rows[i].Cells[0].Value.ToString(); string Sector = dataGrid.Rows[i].Cells[1].Value.ToString(); string SubSector = dataGrid.Rows[i].Cells[2].Value.ToString(); if (Country.Equals("")) { MessageBox.Show("Country field is empty line " + i.ToString()); return; } if (Sector.Equals("")) { MessageBox.Show("Sector field is empty line " + i.ToString()); return; } if (SubSector.Equals("")) { MessageBox.Show("SubSector field is empty line " + i.ToString()); return; } SQLFunc.SubResults sqlData = sql.Get1Data(TPTbl, "Country", "Country='" + Country + "' AND Sector='" + Sector + "' AND Subsector='" + SubSector + "'"); if (sqlData._SubResults.Count == 0) { string data = ""; data += "'" + Country + "','" + Sector + "','" + SubSector + "'"; for (int k = 3; k < dataGrid.Columns.Count; k++) { data += ",'" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[k].Value.ToString()) / 100).ToString() + "'"; } sql.InsertData(TPTbl, data); } else { if (i > ExistingRiskTests - 1 && ExistingRiskTests != 0) { MessageBox.Show("The scheme line " + i.ToString() + " already exists"); return; } string data = ""; data += "EnergyProductionDecrease='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[3].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseFXRisk='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[4].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseDegradationRisk='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[5].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseClimateRisk='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[6].Value.ToString()) / 100).ToString() + "'"; data += ",DecreaseDepositRates='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[7].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseOM='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[8].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseSGA='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[9].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseRoyalties='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[10].Value.ToString()) / 100).ToString() + "'"; data += ",IncreaseTaxes='" + (GlobalFunc.ToDouble(dataGrid.Rows[i].Cells[11].Value.ToString()) / 100).ToString() + "'"; sql.UpdateTable(TPTbl, data, "Country='" + Country + "' AND Sector='" + Sector + "' AND Subsector='" + SubSector + "'"); } } } else { sql.ClearTable(TPTbl); for (int i = 0; i < dataGrid.Rows.Count - 1; i++) { string data = ""; for (int j = 0; j < dataGrid.Columns.Count - 1; j++) { data += "'" + dataGrid.Rows[i].Cells[j].Value.ToString() + "',"; } data += "'" + dataGrid.Rows[i].Cells[dataGrid.Columns.Count - 1].Value.ToString() + "'"; sql.InsertData(TPTbl, data); } } }