public void insertToTable(string typeLog, string message) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string password = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + "; password="******"INSERT INTO logs(typeLog,message) VALUES('" + typeLog + "','" + message + "')"; MySqlCommand cmd = new MySqlCommand(insert, CL); cmd.ExecuteNonQuery(); CL.Close(); }
public void registerUser(string nick, string firstName, string lastName, string password, string email) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string passwd = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + "; password="******"INSERT INTO users( nick, firstName, lastName, password, email) VALUES('" + nick + "','" + firstName + "','" + lastName + "','" + password + "','" + email + "')"; MySqlCommand cmd = new MySqlCommand(insert, CL); cmd.ExecuteNonQuery(); CL.Close(); }
public Boolean findEmail(string email) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string passwd = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + "; password="******"SELECT email FROM users WHERE email = '" + email + "'"; Boolean flag = true; MySqlCommand cmd = new MySqlCommand(insert, CL); try { var version = cmd.ExecuteScalar().ToString(); Console.WriteLine(version); flag = false; }catch (Exception err) { flag = true; } CL.Close(); return(flag); }
public Boolean loginToApp(string email, string passwd) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string password = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + "; password="******" " + passwd); string insert = "SELECT nick,firstName,lastName,email,access FROM users WHERE email = '" + email + "' AND password = '******'"; Boolean flag = true; MySqlCommand cmd = new MySqlCommand(insert, CL); try { var version = cmd.ExecuteScalar().ToString(); MySqlDataReader myDataReader; myDataReader = cmd.ExecuteReader(); while (myDataReader.Read()) { string nick = myDataReader.GetString(0); string firstName = myDataReader.GetString(1); string lastName = myDataReader.GetString(2); string ema = myDataReader.GetString(3); string access = myDataReader.GetString(4); Console.WriteLine(myDataReader.GetString(0) + " " + myDataReader.GetString(1) + " " + myDataReader.GetString(2) + " " + myDataReader.GetString(3) + " " + myDataReader.GetString(4)); } flag = true; } catch (Exception err) { flag = false; Console.WriteLine("error + " + err); } CL.Close(); return(flag); }
public string selectAllTask() { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string password = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + ";convert zero datetime=true; ; password="******"SELECT * FROM tasklist"; MySqlCommand cmd = new MySqlCommand(queryAll, CL); var version = cmd.ExecuteScalar().ToString(); MySqlDataReader myDataReader; myDataReader = cmd.ExecuteReader(); string x = ""; int i = 0; while (myDataReader.Read()) { string a = "\"" + myDataReader.GetString(0) + "\""; string b = "\"" + myDataReader.GetString(1) + "\""; string c = "\"" + myDataReader.GetString(2) + "\""; string d = "\"" + myDataReader.GetString(3) + "\""; var e = "\"" + myDataReader.GetValue(4) + "\""; var f = "\"" + myDataReader.GetValue(5) + "\""; var g = "\"" + myDataReader.GetValue(6) + "\""; string h = "\"" + myDataReader.GetValue(7) + "\""; x += " { id : " + "" + a + "" + ", resolver :" + "" + b + "" + ", titleTask : " + "" + c + "" + " , created : " + "" + d + "" + ", information : " + "" + e + "" + ", dateCreated: " + "" + f + "" + ", dateResolved : " + "" + g + "" + ", status : " + "" + h + " },"; i++; } return(x); }
public void test() { try { readFile getConfiguration = new readFile(); string options = getConfiguration.getInformationFromFile(); string data = options.ToString(); String pattern = @"\,"; String[] Information = System.Text.RegularExpressions.Regex.Split(data, pattern); textBox1.Text = Information[0]; textBox2.Text = Information[2]; textBox3.Text = Information[1]; } catch (System.IndexOutOfRangeException err) { textBox1.Text = null; textBox2.Text = null; textBox3.Text = null; label4.Text = "You don't have file for read value! \n "; } }
private void button1_Click_1(object sender, EventArgs e) { fileOptions fileOpen = new fileOptions(); bool checkFile = fileOpen.tryOpenFile(); if (checkFile == true) { readFile getConfiguration = new readFile(); string options = getConfiguration.getInformationFromFile(); string data = options.ToString(); String pattern = @"\,"; String[] elements = System.Text.RegularExpressions.Regex.Split(data, pattern); textBox1.Text = elements[0]; textBox2.Text = elements[2]; textBox3.Text = elements[1]; } first_connection create_connect = new first_connection(); string ip = textBox1.Text; string password = textBox2.Text; string user = textBox3.Text; if (checkFile == false) { fileCreate newFile = new fileCreate(); newFile.createNewFile(ip, password, user); Console.WriteLine("File created!"); } string informationFromConnector = create_connect.createConnection(ip, password, user); label4.Text = informationFromConnector; if (informationFromConnector == "you are have a connection") { Hide(); } }
public string insertTask(String email, String date, String resolver, String title, String information, String status) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string password = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + ";convert zero datetime=true; ; password="******"-" + dateArr[1] + "-" + dateArr[0]; nowDate = nowDate.Remove(4, 1); string queryAll = "INSERT INTO `users`.`tasklist` (`id`, `resolver`, `titleTask`, `created`, `information`, `dateCreated`, `dateResolved`, `status`) VALUES (NULL,'" + status + "', '" + information + "','" + email + "','" + title + "','" + nowDate + "',NULL,'" + resolver + "');"; MySqlCommand cmd = new MySqlCommand(queryAll, CL); var version = cmd.ExecuteScalar().ToString(); return(""); }
public void getAllTable(ListBox listbox) { readFile getData = new readFile(); string data = getData.getInformationFromFile(); char[] spearator = { ',' }; String[] strlist = data.Split(spearator); string ServerIp = strlist[0]; string uid = strlist[1]; string password = strlist[2]; string databaseName = "Users"; string connstring = string.Format("Server=" + ServerIp + "; database={0}; UID=" + uid + "; password="******"", databaseName); string quetyTable = string.Format(@"CREATE TABLE `{0}` ( `sid` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `nick` varchar(120) NOT NULL DEFAULT '', `firstName` varchar(120) NOT NULL DEFAULT '', `lastName` text NOT NULL, `password` text NOT NULL, `email` text NOT NULL, `access` text NOT NULL, PRIMARY KEY (`sid`)) ENGINE = MyISAM AUTO_INCREMENT = 1 ;", "Users"); string queryTableLogs = string.Format(@"CREATE TABLE `{0}` ( `id` smallint(10) unsigned NOT NULL AUTO_INCREMENT, `typeLog` text NOT NULL, `message` text NOT NULL, PRIMARY KEY (`id`)) ENGINE = MyISAM AUTO_INCREMENT = 1 ", "Logs"); string queryTableTask = string.Format(@"CREATE TABLE `{0}` ( `id` smallint(10) unsigned NOT NULL AUTO_INCREMENT, `resolver` text NOT NULL, `titleTask` text NOT NULL, `created` text NOT NULL, `information` text NOT NULL, `dateCreated` date NOT NULL, `dateResolved` date , `status` text NOT NULL, PRIMARy KEY (`id`)) ENGINE = MyISAM AUTO_INCREMENT = 1", "TaskList"); MySqlConnection CL = new MySqlConnection(connstring); CL.Open(); DateTime localDate = DateTime.Now; MySqlCommand createTableTaskList = new MySqlCommand(queryTableTask, CL); InsertValueDB DbInsert = new InsertValueDB(); MySqlCommand createTableForLog = new MySqlCommand(queryTableLogs, CL); try { createTableForLog.ExecuteNonQuery(); listbox.Items.Add(localDate + " Create Table : Table Logs is Created Correct"); DbInsert.insertToTable("info", localDate + "Create Table : Table Logs is Created Correct"); } catch (MySqlException e) { listbox.Items.Add(localDate + " Create Table : Table Logs Exist"); DbInsert.insertToTable("info", localDate + "Create Table : Table Logs Exist"); } try { createTableTaskList.ExecuteNonQuery(); listbox.Items.Add(localDate + " Create Table : Table TaskList is Created Correct"); DbInsert.insertToTable("info", localDate + "Create Table : Table TaskList is Created Correct"); } catch (MySqlException e) { listbox.Items.Add(localDate + " Create Table : Table Logs Exist"); DbInsert.insertToTable("info", localDate + "Create Table : Table Logs Exist"); } MySqlCommand createTable = new MySqlCommand(quetyTable, CL); try { createTable.ExecuteNonQuery(); listbox.Items.Add(localDate + " Create Table : Table user is Created Correct"); DbInsert.insertToTable("info", localDate + "Create Table : Table user is Created Correct"); } catch (MySql.Data.MySqlClient.MySqlException error) { Console.WriteLine(error); listbox.Items.Add(localDate + " Create Table : Table user exist"); DbInsert.insertToTable("info", localDate + "Create Table : Table user exist"); } }