private void openProjectMenuItem_Click(object sender, EventArgs e) { List <SQLFunc.SubResults> sqlData = mySQL.GetData(DBTables["Projects"].ToString(), "ProjectName,Country,Sector,SubSector,pCur,ProjectID"); OpenProjects ProjectOpen = new OpenProjects(sqlData); ProjectOpen.ShowDialog(); if (ProjectOpen == null || ProjectOpen.Data2LookFor == null) { return; } SQLFunc.SubResults sql1Data = mySQL.Get1Data(DBTables["Projects"].ToString(), "*", ProjectOpen.Data2LookFor); ProjectOpen.Close(); switch (ProjectOpen.Action) { case OpenProjects.ActionType.OpenProject: NewMDEProject OpenProject = new NewMDEProject(DBTables, mySQL, today, sql1Data, CoinParams); OpenProject.ShowDialog(); break; case OpenProjects.ActionType.ValidateProject: SQLFunc.SubResults checkData = mySQL.Get1Data(DBTables["ProjectInScope"].ToString(), "ProjectID", "ProjectID='" + sql1Data._SubResults[25].ToString() + "'"); bool Exists = false; if (checkData._SubResults.Count != 0) { Exists = true; } ProjectValidation ValidateProject = new ProjectValidation(DBTables, mySQL, sql1Data, today, Exists); ValidateProject.ShowDialog(); if (ValidateProject == null) { return; } if (ValidateProject.IsOpen) { OpenProject = new NewMDEProject(DBTables, mySQL, today, sql1Data, CoinParams); OpenProject.ShowDialog(); } if (ValidateProject.IsValidated) { string data2save = "'" + ValidateProject.Project_ID.ToString() + "','Validated','" + FormatDate(ValidateProject.StartDate) + "','" + FormatDate(ValidateProject.COD) + "','" + FormatDate(ValidateProject.EndDate) + "','','','','','','','','','','','','',''"; mySQL.InsertData(DBTables["ProjectInScope"].ToString(), data2save); UpdateProjectInScope(); } ValidateProject.Close(); break; } }
private void currencyBox_SelectedIndexChanged(object sender, EventArgs e) { decreaseBox.Text = ""; SQLFunc.SubResults data = sql.Get1Data(DecreaseRateTable, "Value", "pCur='" + currencyBox.Text + "'"); if (data._SubResults.Count == 0) { decreaseBox.Text = "0"; InfoExists = false; } else { decreaseBox.Text = (Convert.ToDouble(data._SubResults[0]) * 100).ToString(); InfoExists = true; } }
private void validateBtn_Click(object sender, EventArgs e) { SQLFunc mySql = new SQLFunc(ServerAddress, Database); mySql.Err += MySql_Err; mySql.Connect(); SQLFunc.SubResults myData = mySql.Get1Data("Login", "Password", "Login='******'"); if (myData == null || myData._SubResults.Count == 0) { MessageBox.Show("Wrong Login"); NbMissed++; if (NbMissed == 3) { Random _check = new Random(); Result = Result = (int)Math.Round((double)_check.Next(1000), 0); this.Hide(); } } else { string pwd = (string)myData._SubResults[0]; if (!pwd.Equals(passwordBox.Text)) { MessageBox.Show("Wrong Password"); NbMissed++; if (NbMissed == 3) { Random _check = new Random(); Result = (int)Math.Round((double)_check.Next(1000), 0); this.Hide(); } } else { Result = Thread.CurrentThread.ManagedThreadId; 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); } } }