private void CB_Moeda_SelectedIndexChanged(object sender, EventArgs e) { if (CB_Moeda.ValueMember.Length > 0) { Group_Detalhes.Visible = true; DataTable dados_moeda = SQLFunctions.GetInfos("SELECT * FROM MOEDAS WHERE IDMOEDA = " + Convert.ToString(CB_Moeda.SelectedValue)); Edt_ValorAtual.Text = dados_moeda.Rows[0]["VALORMERCADO"].ToString(); DataTable dados_detalhes_total = SQLFunctions.GetInfos("SELECT top(1) NroCarteira, IDMoeda, Quantidade, IDUsuario FROM CARTEIRA " + "WHERE IDUSUARIO = " + Session.Instance.UserID + " and IDMOEDA = " + Convert.ToString(CB_Moeda.SelectedValue)); DataTable dados_detalhes_ult = SQLFunctions.GetInfos("SELECT top(1) QUANTOPERADA, VALOROPERACAO, OPERACAO FROM OPERACAO " + "WHERE IDUSUARIO = " + Session.Instance.UserID + " AND IDMOEDA = " + Convert.ToString(CB_Moeda.SelectedValue) + " ORDER BY DATAHORA DESC "); if (dados_detalhes_total.Rows.Count <= 0 || dados_detalhes_ult.Rows.Count <= 0) { Edt_QtdObtida.Text = "Nenhuma operação localizada"; Edt_VlrObtido.Text = "Nenhuma operação localizada"; Edt_QtdUltCompra.Text = "Nenhuma operação localizada"; Edt_VlrUltCompra.Text = "Nenhuma operação localizada"; Edt_UltTransacao.Text = "Nenhuma"; } else { Edt_QtdObtida.Text = dados_detalhes_total.Rows[0]["QUANTIDADE"].ToString(); double valor_mercado = (Convert.ToDouble(Edt_ValorAtual.Text) * Convert.ToDouble(dados_detalhes_total.Rows[0]["QUANTIDADE"].ToString())); Edt_VlrObtido.Text = valor_mercado.ToString(); Edt_QtdUltCompra.Text = dados_detalhes_ult.Rows[0]["QUANTOPERADA"].ToString(); Edt_VlrUltCompra.Text = dados_detalhes_ult.Rows[0]["VALOROPERACAO"].ToString(); Edt_UltTransacao.Text = dados_detalhes_ult.Rows[0]["OPERACAO"].ToString(); } } }
public ActionResult DisplayGas(string AutoID) { mvc_MilesTracker.Models.SQLFunctions HelperSQL = new SQLFunctions(); //Should be a better way in passing values??? ViewData.Model = HelperSQL.GetMilesForAuto(Request.QueryString["AutoID"]); return View(); }
public ActionResult DisplayAuto() { mvc_MilesTracker.Models.SQLFunctions HelperSQL = new SQLFunctions(); //Should be a better way in passing values??? ViewData.Model = HelperSQL.GetAllAutos(); return View(); }
private void Btn_ExcluiCargo_Click(object sender, EventArgs e) { if (MessageBox.Show("Deseja realmente excluir ? Essa operação não pode ser desfeita!!", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string comando = "delete from setor where idcargo = " + Convert.ToString(this.Grid_Setor.CurrentRow.Cells["idcargo"].Value);; SQLFunctions.ExecutaComando(comando); Grid_Cargo.DataSource = SQLFunctions.GetInfos(Consultas.consultaCargo + Edt_IDSetor.Text); } }
public void GetListAllPeople_NoValuesGiveListOfPeople() { //arrange int expectedCount = 1; SQLFunctions functions = new SQLFunctions(); //act List <CustomersDAO> actualCount = functions.GetAllPeople(); //result(Assert) Assert.True(expectedCount <= actualCount.Count); }
private void Frm_CompraVendaMoeda_Shown(object sender, EventArgs e) { CB_Moeda.DropDownStyle = ComboBoxStyle.DropDownList; CB_Moeda.DataSource = SQLFunctions.GetInfos("SELECT * FROM MOEDAS"); CB_Moeda.ValueMember = "IDMOEDA"; CB_Moeda.DisplayMember = "NOMEMOEDA"; CB_Moeda.Update(); Group_Detalhes.Visible = false; System.Data.SqlClient.SqlConnection SqlCon = new System.Data.SqlClient.SqlConnection(Variaveis.conexao); historicoTableAdapter.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand("SELECT DATAHORA, VALOR FROM HISTORICO where idmoeda = " + Convert.ToString(CB_Moeda.SelectedValue), SqlCon); }
public string ExecuteSqlScript(string script) { if (UserConnection.DBSecurityEngine.GetCanExecuteOperation("CanManageSolution")) { return(SQLFunctions.ExecuteSQL(script, UserConnection)); } else { throw new Exception("You don`n have permission for operation CanManageSolution"); } }
private static void ProcessStreamline() { SQLFunctions sql = new SQLFunctions(Secrets.CRMConnectionString()); SQLFunctions sql1 = new SQLFunctions(Secrets.ReportingConnectionString()); List <Dictionary <string, object> > slproperties = sql.ListDictionarySQLQuery("select PMC as companyname, credential1, credential2 from VacationCredentials" + " where gatewayname = 'streamline'"); List <string> badones = new List <string>(); foreach (Dictionary <string, object> slproperty in slproperties) { string company = slproperty["companyname"].ToString(); LogMessage($"Pulling data for {company}"); for (int dategrouppoll = 0; dategrouppoll < numberofpulls; dategrouppoll++) { string result = StreamLineResult(slproperty["credential1"].ToString(), slproperty["credential2"].ToString(), dategrouppoll); dynamic jsonresults = JsonConvert.DeserializeObject(result); try { string test = $"{jsonresults.data.reservations.Count}"; LogMessage($"Pushing {test} results into SQL Server for {company}"); string sqlstatement = ""; int counter = 0; foreach (var reservation in jsonresults.data.reservations) { reservation.propertyname = slproperty["companyname"].ToString(); reservation.Source = "Streamline"; sqlstatement += BuildSLUpsert(reservation, 17167, "Streamline", company); if (counter++ % batchsize == 0) { RunTransaction(sql1, sqlstatement); sqlstatement = ""; } } RunTransaction(sql1, sqlstatement); } catch (Exception) { badones.Add(slproperty["companyname"].ToString()); } } } if (badones.Count > 0) { LogMessage($"Had issues with {badones.ToArray()}"); } else { LogMessage("Processed all Streamline properties"); } }
public void SQLTests() { //Assert.IsTrue(SQLFunctions.); //sql unit test Assert.AreEqual("Student", SQLFunctions.checkRole(308038405)); Assert.AreEqual("Hedva1", SQLFunctions.covertCourseIDtoCourseName(2)); Assert.AreEqual(2, SQLFunctions.covertCourseNametoCourseID("Hedva1")); Assert.AreEqual(12, SQLFunctions.covertLectureNametoLectureID("Hedva2")); Assert.AreEqual("Computer Architecture 1 ", SQLFunctions.covertLectureIDtoLectureName(40)); }
private void Btn_Vender_Click(object sender, EventArgs e) { if (CB_Moeda.Text == "") { MessageBox.Show("Seleciona a moeda que deseja operar!"); } else if (Edt_VlrNegociar.Text == "") { MessageBox.Show("Selecione o valor que deseja operar!"); } double quant_obtida = (Convert.ToDouble(Edt_VlrNegociar.Text) / (Convert.ToDouble(Edt_ValorAtual.Text))); if (MessageBox.Show("Deseja vender " + Convert.ToString(quant_obtida) + " " + CB_Moeda.Text + " para obter R$ " + Edt_VlrNegociar.Text, "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Operacao: DataTable pega_carteira = SQLFunctions.GetInfos("SELECT NROCARTEIRA, QUANTIDADE FROM CARTEIRA WHERE IDUSUARIO = " + Session.Instance.UserID + " AND IDMOEDA = " + Convert.ToString(CB_Moeda.SelectedValue)); if (pega_carteira.Rows.Count < 1) { SQLFunctions.ExecutaComando("INSERT INTO CARTEIRA (IDMOEDA,IDUSUARIO,QUANTIDADE) " + "VALUES(" + Convert.ToString(CB_Moeda.SelectedValue) + ", " + Session.Instance.UserID + ", 0)"); goto Operacao; } string carteira = pega_carteira.Rows[0]["NROCARTEIRA"].ToString(); double quantidade = Convert.ToDouble(pega_carteira.Rows[0]["QUANTIDADE"].ToString()); if (quantidade < quant_obtida) { MessageBox.Show("Não é possivel vender! \n Valor a ser negociado maior que saldo disponivel"); } else { string comando = "INSERT INTO Operacao(ValorOperacao, DataHora, IDMoeda, NroCarteira, IDUsuario, Operacao, QuantOperada)" + "VALUES (" + Edt_VlrNegociar.Text + ",'" + Funcoes.FormataDataAmericana(DateTime.Now) + "'," + Convert.ToString(CB_Moeda.SelectedValue) + ", " + carteira + ", " + Session.Instance.UserID + ", 'VENDA'," + Convert.ToString(quant_obtida) + ")"; int i = SQLFunctions.ExecutaComando(comando); if (i == 1) { MessageBox.Show("Ocorreu um erro ao processar a requisição!! \n Aguarde e tente novamente!!"); } else { quant_obtida = quantidade - quant_obtida; SQLFunctions.ExecutaComando("UPDATE CARTEIRA SET QUANTIDADE = " + quant_obtida.ToString() + "WHERE NROCARTEIRA = " + carteira); MessageBox.Show("Transação realizada!"); CB_Moeda.Text = ""; Edt_VlrNegociar.Text = ""; Group_Detalhes.Visible = false; } } } }
public void StudentUnitTest() { Assert.AreEqual("Shusterman", SQLFunctions.covertStudentIDtoStudentLastName(308038405)); Assert.AreEqual("Lior", SQLFunctions.covertStudentIDtoStudentFirstName(308038405)); Assert.IsTrue(SQLFunctions.addLecturesToStudent(308038405, new List <int> { 12, 19, 18 }, 30, 23)); Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 12)); Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 19)); Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 18)); Assert.IsTrue(SQLFunctions.ChangeStudentNotificationState(new List <int> { 308038405 }, "False")); }
public void AdmintUnitTest() { Assert.IsTrue(SQLFunctions.addClassroom("test", 20, "class")); Assert.IsTrue(SQLFunctions.deleteClassroom("test")); Assert.IsTrue(SQLFunctions.insertUser("*****@*****.**", 333333333, "3", "3", "3", "3", "3")); Assert.IsTrue(SQLFunctions.updateStudentYearAndSemester(333333333, 2, 'B')); Assert.IsTrue(SQLFunctions.updateUserRole(333333333, "3", "4")); Assert.IsTrue(SQLFunctions.deleteUser(333333333)); Assert.IsTrue(SQLFunctions.checkExistsStudents(308038405)); Assert.IsTrue(SQLFunctions.deleteStudent(308038405)); Assert.IsTrue(SQLFunctions.addStudent(308038405, 2, 'A')); Assert.IsTrue(SQLFunctions.updateErrorsStatus(new List <int> { 45 })); }
public void LoginUnitTest() { Assert.IsTrue(SQLFunctions.checkLogIn(222222222, "2")); Assert.IsTrue(SQLFunctions.checkExistsUsers(308038405)); Assert.AreEqual("", SQLFunctions.getUsersDepartment(222222222)); Assert.IsTrue(SQLFunctions.linkFbAccount("*****@*****.**", "*****@*****.**")); Assert.AreEqual(SQLFunctions.convertFbMailToMail("*****@*****.**"), "*****@*****.**"); Assert.IsTrue(SQLFunctions.checkExistsEmail("*****@*****.**")); Assert.AreEqual(SQLFunctions.getIDbyEmail("*****@*****.**"), 308038405); DataRow dataRow = SQLFunctions.checkFbLogIn("*****@*****.**"); Assert.AreEqual(Convert.ToInt32(dataRow[0]), 308038405); Assert.AreEqual((dataRow[1]), "654321"); }
public ActionResult AddAuto() { if (Request.Form.Keys.Count.Equals(0)) { return View(); } else { mvc_MilesTracker.Models.SQLFunctions HelperSQL = new SQLFunctions(); HelperSQL.AddAuto(Request.Form["txtAutoName"]); ViewBag.Model = "Auto " + Request.Form["txtAutoName"] + " Added"; return View(); } }
private void Btn_SalvaCargo_Click(object sender, EventArgs e) { if (Edt_Setor.Text == "") { MessageBox.Show("Preencha todos os dados!"); } else { string Comando = "INSERT INTO CARGOS(CARGO, IDSETOR) VALUES('" + Edt_Cargo.Text + "','" + Edt_IDSetor.Text + "')"; int i = SQLFunctions.ExecutaComando(Comando); if (i > 0) { MessageBox.Show("Ocorreu um erro ao salvar!"); } Grid_Cargo.DataSource = SQLFunctions.GetInfos(Consultas.consultaCargo + Edt_IDSetor.Text); } }
public ActionResult AddGas() { if (Request.Form.Keys.Count.Equals(0)) { return View(); } else { mvc_MilesTracker.Models.SQLFunctions HelperSQL = new SQLFunctions(); HelperSQL.AddGas(Request.Form["txtAutoNumber"], Request.Form["txtMiles"], Request.Form["txtPrice"], Request.Form["txtGallons"]); ViewBag.Model = "Miles Added."; return View(); } }
private void button2_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 2"); if (textBox1.Text == "" || textBox1.Text == "") { MessageBox.Show("You must enter first email and password"); } else { if (!SQLFunctions.checkLogIn(SQLFunctions.getIDbyEmail(textBox1.Text), textBox2.Text)) { MessageBox.Show("Facebook link failure: unknown ID or invalid password"); } else { FormFacebookLogin fbLogin = new FormFacebookLogin(true, textBox1.Text); fbLogin.Show(); } } }
public void ExamDepartmentUnitTest() { Assert.IsTrue(SQLFunctions.addGradeToStudent(308038405, 2, 90)); Assert.IsTrue(SQLFunctions.isStudentGraded(308038405, 2)); Assert.IsTrue(SQLFunctions.updateGradeToStudent(308038405, 2, 95)); Assert.IsTrue(SQLFunctions.checkExistsClassroom("F104")); // adds lectures to student for unit test Assert.IsTrue(SQLFunctions.addLecturesToStudent(308038405, new List <int> { 12, 19, 18 }, 30, 23)); //returns the student lectures test the findStudentLecturesIDs method CollectionAssert.AreEqual(SQLFunctions.findStudentLecturesIDs(308038405), new List <int> { 12, 19, 18 }); //deletes the lectures for the test Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 12)); Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 19)); Assert.IsTrue(SQLFunctions.deleteLectureFromStudent(308038405, 18)); CollectionAssert.AreEqual(SQLFunctions.getLectureIDByCourseID(6), new List <int> { 17, 22, 39, 44 }); }
private void Btn_Salvar_Click(object sender, EventArgs e) { if (Edt_Abrevicao.Text == "") { MessageBox.Show("Preencha a abreviação!"); } else if (Edt_Descricao.Text == "") { MessageBox.Show("Preencha a Descrição!"); } else { string comando = "Insert into Moedas (NomeMoeda, Abreviacao, ValorMercado) " + "Values ('" + Edt_Descricao.Text + "', '" + Edt_Abrevicao.Text + "', 0)"; int i = SQLFunctions.ExecutaComando(comando); if (i > 0) { MessageBox.Show("Ocorreu um erro ao salvar!"); } Grd_Moedas.DataSource = SQLFunctions.GetInfos("select * from moedas"); } }
private void Btn_Salvar_Click(object sender, EventArgs e) { if (Edt_Login.Text == "") { MessageBox.Show("Preencha todos os dados!"); } else if (Edt_Senha.Text == "") { MessageBox.Show("Preencha todos os dados!"); } else if (Edt_Nivel.Text == "") { MessageBox.Show("Preencha todos os dados!"); } else { if (Edt_IDLogin.Text == "") { string val_ativo; if (Edt_Ativo.Checked == true) { val_ativo = "S"; } else { val_ativo = "N"; } string Comando = "INSERT INTO Usuarios (Login, Senha, NivelDeAcesso, Ativo) " + "values ('" + Edt_Login.Text + "','" + Edt_Senha.Text + "','" + Edt_Nivel.Text + "','" + val_ativo + "')"; int i = SQLFunctions.ExecutaComando(Comando); if (i > 0) { MessageBox.Show("Ocorreu um erro ao salvar!"); } try { SqlConnection con = new SqlConnection(Variaveis.conexao); //Cria a variavel de conexão con.Open(); //Abre a conexão { Habilita(VF: false); Btn_Novo.Enabled = true; Btn_Alterar.Enabled = false; Btn_Salvar.Enabled = false; Btn_Cancelar.Enabled = false; Btn_Novo.Focus(); } } catch (Exception ex) //Caso retorne algum erro { MessageBox.Show("Erro: " + ex.ToString()); //Exibe o erro retornado } finally { SqlConnection con = new SqlConnection(Variaveis.conexao); //Cria a variavel de conexão con.Close(); //Fecha a conexão } } else { string val_ativo; if (Edt_Ativo.Checked == true) { val_ativo = "S"; } else { val_ativo = "N"; } string comando = "UPDATE Usuarios SET IDFuncionario = '" + Edt_IDFuncionario.Text + "', Login = '******', Senha = '" + Edt_Senha.Text + "', NivelDeAcesso = '" + Edt_Nivel.Text + "', Ativo = '" + val_ativo + "' WHERE Login = '******'"; int i = SQLFunctions.ExecutaComando(comando); if (i > 0) { MessageBox.Show("Ocorreu um erro ao salvar!"); } Habilita(VF: false); Btn_Novo.Enabled = true; Btn_Alterar.Enabled = false; Btn_Salvar.Enabled = false; Btn_Cancelar.Enabled = false; Btn_Novo.Focus(); } } }
private void Frm_Moedas_Shown(object sender, EventArgs e) { Grd_Moedas.DataSource = SQLFunctions.GetInfos("select * from moedas"); }
public PeopleController() { sQL = new SQLFunctions(); }
private void Frm_SetorCargo_Shown(object sender, EventArgs e) { Grid_Setor.DataSource = SQLFunctions.GetInfos(Consultas.consultaSetor); }
private void button1_Click(object sender, EventArgs e) { DateTime end_of_exams_semester_a = new DateTime(DateTime.Today.Year, 3, 5); DateTime end_of_semester_b = new DateTime(DateTime.Today.Year, 6, 15); DateTime end_of_exams_semester_b = new DateTime(DateTime.Today.Year, 7, 15); SqlDataReader read = db.Select("*", "NewUsers"); try { if (textBox1.Text == "") { MessageBox.Show("Logon Failure: unknown ID or invalid password"); return; } if (SQLFunctions.checkExistsEmail(textBox1.Text)) { if (SQLFunctions.checkLogIn(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text)), textBox2.Text)) { this.Hide(); if (SQLFunctions.checkRole(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString()))) == "Student") { FormMenuStudent mainForm = new FormMenuStudent(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString())), textBox2.Text); mainForm.Show(); } else if (SQLFunctions.checkRole(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString()))) == "SecretaryA") { FormMenuSecretary mainForm = new FormMenuSecretary(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString())), textBox2.Text); mainForm.Show(); } else if (SQLFunctions.checkRole(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString()))) == "Exam Department") { FormMenuExamDepartment mainForm = new FormMenuExamDepartment(); mainForm.Show(); } else if (SQLFunctions.checkRole(Convert.ToInt32(SQLFunctions.getIDbyEmail(textBox1.Text.ToString()))) == "Admin") { FormMenuAdmin mainForm = new FormMenuAdmin(); mainForm.Show(); } else { while (read.Read()) { if (textBox1.Text == read["Email"].ToString().Trim() && textBox2.Text == read["Password"].ToString().Trim()) { ID = read["ID"].ToString(); // GlobalVariables h;.ID = read["ID"].ToString().Trim(); GlobalVariables.User_ID = read["ID"].ToString().Trim(); GlobalVariables.Full_Name = read["FirstName"].ToString().Trim() + " " + read["LastName"].ToString().Trim(); GlobalVariables.User_Permission = read["Role"].ToString().Trim(); GlobalVariables.User_Department = read["Department"].ToString().Trim(); GlobalVariables.User_Email = read["Email"].ToString().Trim(); if (monthCalendar1.MaxDate >= DateTime.Today && monthCalendar1.MinDate <= DateTime.Today) { GlobalVariables.Semester = "A"; } else if (monthCalendar1.MaxDate < DateTime.Today && DateTime.Today <= end_of_exams_semester_a) { GlobalVariables.Semester = "Exam Period semester A"; } else if (end_of_exams_semester_a < DateTime.Today && DateTime.Today <= end_of_semester_b) { GlobalVariables.Semester = "B"; } else if (end_of_exams_semester_b >= DateTime.Today && DateTime.Today > end_of_semester_b) { GlobalVariables.Semester = "Exam Period semester B"; } else { GlobalVariables.Semester = "Summer Semester"; } IsFound = true; GlobalVariables.maxDate = monthCalendar1.MaxDate; GlobalVariables.minDate = monthCalendar1.MinDate; break; } GlobalVariables.maxDate = monthCalendar1.MaxDate; GlobalVariables.minDate = monthCalendar1.MinDate; } read.Close(); if (!IsFound) { MessageBox.Show("You have to sign up before"); textBox1.Text = ""; textBox2.Text = ""; return; } this.Hide(); main m = new main(); m.Show(); } } else { MessageBox.Show("Logon Failure: unknown ID or invalid password"); } } else { MessageBox.Show("Logon Failure: unknown ID or invalid password"); } } catch (SqlException exception) { MessageBox.Show(exception.ToString()); } finally { if (db.isconnected == true) { db.CloseConnection(); } } }