public bool userAuthentication(string username, string password) { ConnectionManager.DataBaseConn con = new ConnectionManager.DataBaseConn(1); SqlConnection sql=con.DBConnect(); DatabaseAccess.Query query = new DatabaseAccess.Query(); bool status= query.checkAuthentication(username, password,sql); return status; }
private void threadStartFun(Socket soc, string req) { Program.ServerForm.addtoConsole("Service SignUpReq Thread Started"); //parse msg received //System.Windows.Forms.MessageBox.Show("Signup service started:"+ req, "Server"); Message.MessageParser parser = new Message.MessageParser(); MessageClasses.MsgSignUp.req reqobj = new MessageClasses.MsgSignUp.req(); reqobj = parser.signUpParseReq(req); //create connection with sql ConnectionManager.DataBaseConn con = new ConnectionManager.DataBaseConn(1); SqlConnection conn = con.DBConnect(); //check if user already exits DatabaseAccess.Query q = new DatabaseAccess.Query(); if (true == q.checkIfUserExists(reqobj.userName, conn)) { con.DBClose(); //System.Windows.Forms.MessageBox.Show("Signup service if user exists", "Server"); MessageClasses.MsgSignUp.resp resp = new MessageClasses.MsgSignUp.resp(); resp.ack = "ERRORS"; resp.addiMsg = "AlreadyExist"; Message.CreateMsg msg = new Message.CreateMsg(); string res= msg.signUpResp(resp); SocketCommunication.ReaderWriter rw = new SocketCommunication.ReaderWriter(); rw.writetoSocket(soc, res); Program.ServerForm.addtoConsole("Writing response to Socket"); Program.ServerForm.addtoConsole("Exiting"); Thread.CurrentThread.Abort(); } else { ConnectionManager.DataBaseConn con1 = new ConnectionManager.DataBaseConn(1); SqlConnection conn1 = con.DBConnect(); if (true == q.insertNewUser(reqobj.userName, reqobj.psw, conn1)) { Program.ServerForm.addtoConsole("New User Added"); conn1.Close(); //System.Windows.Forms.MessageBox.Show("Signup service insert user", "Server"); MessageClasses.MsgSignUp.resp resp = new MessageClasses.MsgSignUp.resp(); resp.ack = "OK"; resp.addiMsg = "Added"; Message.CreateMsg msg = new Message.CreateMsg(); string res = msg.signUpResp(resp); SocketCommunication.ReaderWriter rw = new SocketCommunication.ReaderWriter(); rw.writetoSocket(soc, res); Program.ServerForm.addtoConsole("Wrote response to Socket"); //conn.Close(); } else { conn1.Close(); Program.ServerForm.addtoConsole("Sign Up Error while inserting to Database"); //System.Windows.Forms.MessageBox.Show("Signup service could insert", "Server"); MessageClasses.MsgSignUp.resp resp = new MessageClasses.MsgSignUp.resp(); resp.ack = "ERRORS"; resp.addiMsg = "ERRORWHILEINSERTING"; Message.CreateMsg msg = new Message.CreateMsg(); string res = msg.signUpResp(resp); SocketCommunication.ReaderWriter rw = new SocketCommunication.ReaderWriter(); rw.writetoSocket(soc, res); Program.ServerForm.addtoConsole("Wrote Respose to Socket"); //conn.Close(); } //conn.Close(); Program.ServerForm.addtoConsole("Exiting"); Thread.CurrentThread.Abort(); } //TBD }
private void button1_Click(object sender, EventArgs e) { button1.Visible = false; if(button1.Text.Equals(GetLabel(DictionaryFileName,"StopButton"))) { // Clean panel Close_panel(); // Back comboBox1.Enabled = true; comboBox2.Enabled = true; maskedTextBox1.Enabled = true; radioButton1.Enabled = true; radioButton2.Enabled = true; panel4.Visible = true; radioButton3.Enabled = true; radioButton4.Enabled = true; button1.Text = GetLabel(DictionaryFileName, "RunButton"); } else if (button1.Text.Equals(GetLabel(DictionaryFileName,"RunButton"))) { List<bool> validation = new List<bool>(); validation.Add(ValidateAsSelectedfromCombobox(comboBox2, label3)); if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false && radioButton4.Checked == false) { validation.Add(false); ShowError(989, label2.Text.Split(':')[0]); } else { validation.Add(true); } validation.Add(ValidateAsSelectedfromCombobox(comboBox1, label1)); if (CompleteValidation(validation) == true) { bool noerror = false; // Testar conexão DatabaseAccess.Query databaseAccess = new DatabaseAccess.Query(); List<string[]> matrix = new List<string[]>(); bool errorShown = false; try { matrix = databaseAccess.query(GetLabel("config.ini", "Host"), GetLabel("config.ini", "UserID"), GetLabel("config.ini", "DatabaseName"), maskedTextBox1.Text, "SELECT * FROM `case`"); if (matrix[0][0].ToLower().Contains("*error*") && matrix[0][0].ToLower().Contains("access denied for user")) { ShowError(997, label4.Text.Split(':')[0]); errorShown = true; } else if (matrix[0][0].ToLower().Contains("*error*")) { ShowError(984, GetLabel(DictionaryFileName,"InternetConnection")); errorShown = true; } else { noerror = true; } } catch { if (matrix.Count == 0) { // Means that read ok but there isn't anything on the database noerror = true; } } if (noerror == false) { if ( errorShown == false) { ShowError(997, label4.Text.Split(':')[0]); } } else { comboBox1.Enabled = false; comboBox2.Enabled = false; label5.Text = GetLabel(DictionaryFileName, "NoError.OK"); maskedTextBox1.Enabled = false; radioButton1.Enabled = false; int operationSelectedValue = -1; if (radioButton1.Checked == true) { operationSelectedValue = 0; } radioButton2.Enabled = false; if (radioButton2.Checked == true) { operationSelectedValue = 1; } radioButton3.Enabled = false; if (radioButton3.Checked == true) { operationSelectedValue = 2; } radioButton4.Enabled = false; if (radioButton4.Checked == true) { operationSelectedValue = 3; } GenerateNewForm(maskedTextBox1.Text, comboBox1.SelectedIndex, comboBox2.SelectedIndex, operationSelectedValue); button1.Text = GetLabel(DictionaryFileName, "StopButton"); } } else { } } else { ShowError(992, "dictionary.dat"); } button1.Visible = true; }
private List<string[]> Query(string msgQuery) { List<string[]> matrix = new List<string[]>(); DatabaseAccess.Query databaseAccess = new DatabaseAccess.Query(); matrix = databaseAccess.query(GetLabel("config.ini", "Host"), GetLabel("config.ini", "UserID"), GetLabel("config.ini", "DatabaseName"), maskedTextBox1.Text, msgQuery); return matrix; }
private List<string[]> GetTransmissionMatrix() { DatabaseAccess.Query databaseAccess = new DatabaseAccess.Query(); List<string[]> matrix = new List<string[]>(); matrix = databaseAccess.query(GetLabel("config.ini", "Host"), GetLabel("config.ini", "UserID"), GetLabel("config.ini", "DatabaseName"), maskedTextBox1.Text,"SELECT * FROM `case`"); matrix = CaseTransmissionFiltering(matrix); return matrix; }
private int GetAreaID(int selectedIndex) { if (selectedIndex >= 0) { List<string[]> matrix = new List<string[]>(); DatabaseAccess.Query databaseAccess = new DatabaseAccess.Query(); matrix = databaseAccess.query(GetLabel("config.ini", "Host"), GetLabel("config.ini", "UserID"), GetLabel("config.ini", "DatabaseName"), maskedTextBox1.Text, "SELECT * FROM `area`"); try { return Convert.ToInt32(matrix[selectedIndex][0]); } catch { return -1; } } else { return -1; } }