private void updateBtn_Click(object sender, EventArgs e) { if (currencyBox.Text.Equals("")) { return; } double value; try { value = Convert.ToDouble(decreaseBox.Text) / 100; } catch { value = 0.0; } if (InfoExists) { sql.UpdateTable(DecreaseRateTable, "Value='" + value + "'", "pCur='" + currencyBox.Text + "'"); } else { sql.InsertData(DecreaseRateTable, "'" + currencyBox.Text + "','" + value + "'"); } }
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); } } }