/** * * 根据username查询管理员 * */ public User selectUserByUserName(String userName) { String sql = "select * from admin where username='******'"; //Console.WriteLine(sql); connection.Open(); cmd = new MySqlCommand(sql, connection); MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.Read()) { User user = new User(); user.UserName = dataReader["username"].ToString(); user.PassWord = dataReader["password"].ToString(); Console.WriteLine(user.ToString()); //关闭连接 dataReader.Close(); closeConnection(); return user; } //关闭连接 dataReader.Close(); closeConnection(); return null; }
private bool verifyUserExists(User user) { if (listOfUsers.Contains(user)) return true; else return false; }
public String save(String firstName, String lastName, String emailAddress, String password) { if (!System.IO.File.Exists(filePath)) System.IO.File.Create(filePath); loadUsers(); //create the user User user = new User(); user.FirstName = firstName; user.LastName = lastName; user.EmailAddress = emailAddress; user.Password = password; //first verify that this user does not exist if (verifyUserExists(user)) return "User already exists!"; //make sure this temp directory exists or change the location. StreamWriter fileWriter = new StreamWriter(filePath, true); //fileWriter.WriteLine(firstName + " " + lastName + " " + emailAddress + " " + password); fileWriter.WriteLine(user.ToString()); fileWriter.Close(); return "User saved successfully!"; }
private void main_but_OK_Click(object sender, EventArgs e) { User current_usr = new User(); SqlCommand command = new SqlCommand(); command.Connection = con; command.CommandType = CommandType.Text; command.CommandText = "Select * from NHANVIEN where (username=@user) and (pass=@pass)"; command.Parameters.Add("@user", SqlDbType.NVarChar, 50).Value = main_box_uname.Text; command.Parameters.Add("@pass", SqlDbType.NVarChar, 50).Value = main_box_pword.Text; da.SelectCommand = command; da.Fill(dt); if (dt.Rows.Count > 0) { QuanLy ql = new QuanLy(); delPassData del = new delPassData(ql.funData); del(this.main_box_uname); ql.Show(); Hide(); } else { MessageBox.Show("Đăng nhập thất bại. Sai mật khẩu hoặc tên tài khoản"); } }
private void main_but_OK_Click(object sender, EventArgs e) { //truy van csdl xem co nguoi dung ko //Nếu có khai báo biến người dùng , mở form quản lí User current_usr = new User(); //đẩy thông tin người dùng vào curren_user QuanLy formQL = new QuanLy(current_usr); formQL.Show(); this.Hide(); }
/** * * 插入管理员用户 * */ public int insert(User user) { String sql = "insert into admin values('" + user.UserName + "','" + user.PassWord + "')"; connection.Open(); cmd = new MySqlCommand(sql, connection); int n = cmd.ExecuteNonQuery(); //关闭连接 closeConnection(); return n; }
private void button1_Click(object sender, EventArgs e) { if ("".Equals(textBox1.Text)) { MessageBox.Show("用户名不能为空!","警告!"); textBox1.Select(); return; } if ("".Equals(textBox2.Text)) { MessageBox.Show("密码不能为空!", "警告!"); textBox2.Select(); return; } if ("".Equals(textBox3.Text)) { MessageBox.Show("请确认密码!", "警告!"); textBox3.Select(); return; } if (!textBox2.Text.ToString().Equals(textBox3.Text.ToString())) { MessageBox.Show("两次密码输入不一致!", "警告!"); textBox3.Select(); return; } String username = textBox1.Text; String password = textBox2.Text; if (userDB.selectUserByUserName(username) != null) { MessageBox.Show("用户名已存在!", "消息!"); textBox1.Select(); return; } User user = new User(); user.UserName = username; user.PassWord = password; if (userDB.insert(user) == 1) { MessageBox.Show("注册成功!", "消息!"); Login.f.Show(); this.Close(); } else { MessageBox.Show("注册失败!未知错误!", "消息!"); } }
public QuanLy(User _curUser) { InitializeComponent(); currenUser = _curUser; if (currenUser.ID_quanly > 0) { tab_QL_KH.Hide(); tab_TKHH.Hide(); tab_QL_kho.Hide(); tab_QL_NV.Hide(); } }
private void loadUsers() { StreamReader fileLoader = new StreamReader(filePath); String line; while (!fileLoader.EndOfStream) { line = fileLoader.ReadLine(); String[] splitString = line.Split(new Char[] { ' ' }); //here i assume that we got back four strings User user = new User(); user.FirstName = splitString[0]; user.LastName = splitString[1]; user.EmailAddress = splitString[2]; user.Password = splitString[3]; listOfUsers.Add(user); } }
private string GetAnswer(string msg) { AddMessage("Qst: " + msg); string result = "failed"; string[] part = msg.Split(new Char[] { ' ' }); if (part.Length >= 1) { if (part[0].Equals("createuser", StringComparison.CurrentCultureIgnoreCase) && part.Length == 4){ int pwdhash; if(part[1].Length<32 && int.TryParse(part[2], out pwdhash)){ User u = new User { Username = part[1], PasswordHash = pwdhash, Group = GetGroup(part[3]), ID = UserCnt++ }; UserList.Add(u); AddMessage("New User: "******"succ"; } } } AddMessage("Ans: " + result); return result; }
partial void InsertUser(User instance);
public IList<Issue> GetTotalIssue() { user = manager.GetCurrentUser(); var par = new NameValueCollection { { "assigned_to_id", user.Id.ToString() } };//set filter for Issues var total = manager.GetTotalObjectList<Issue>(par); return total; }
public IList<Issue> GetIssueByProject(int idProject) { user = manager.GetCurrentUser(); var par = new NameValueCollection { { "project_id", String.Format("{0}",idProject) } };//set filter for Issues par.Add("assigned_to_id",user.Id.ToString()); var total = manager.GetTotalObjectList<Issue>(par); return total; }
public void ircthread() { int port; string buf, nick, pw, server, chan, user, uname, msg, queueList; bool flag = false; System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient(); System.IO.TextReader input; System.IO.TextWriter output; nick = "queueupchat"; pw = "oauth:mwhpwsgzsohz1ltvj9wtwnkwn0aqzq"; //oauth is password for IRC, Dont touch it server = "irc.twitch.tv"; port = 6667; chan = "#" + textBox1.Text.ToLower(); sock.Connect(server, port); input = new System.IO.StreamReader(sock.GetStream()); output = new System.IO.StreamWriter(sock.GetStream()); //Starting USER and NICK login commands output.Write( "PASS " + pw + "\r\n" + "NICK " + nick + "\r\n" + "USER " + nick + " 8 * :" + nick + "\r\n" + //this is "CAP REQ :twitch.tv/membership" + "\r\n " + //the new magic "JOIN " + chan + "\r\n" //dont touch it //EVER! ); output.Flush(); textBox2.Invoke((Action)delegate { textBox2.AppendText(DateTime.Now.ToShortTimeString() + "Connection Established \r\n\r\n"); //this should probably be in a try catch or something... }); //Process each line received from irc server for (buf = input.ReadLine(); ; buf = input.ReadLine()) { if (buf.Contains("PRIVMSG")) { string[] split = buf.Split(new Char[] { ':' }); //all the shit for cutting up the raw IRC string into easily readable text user = split[1]; //we need to edit this so if someone types sends a message with colons it doesnt split it again string[] unamesplit = user.Split(new Char[] { '!' }); uname = unamesplit[0]; msg = split[2]; if (msg.Equals("!join", StringComparison.Ordinal)) //cleaned up { flag = false; queueGrid.Invoke((Action)delegate { for (int i = 0; i < count; i++) { if(nameList[i].twitchname.Equals(uname, StringComparison.Ordinal)) { output.Write("PRIVMSG " + chan + " :@" + uname + " You are already in queue\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY flag = true; break; } } if (!flag) { User newusr = new User(); newusr.twitchname = uname; nameList.Add(newusr); queueGrid.DataSource = nameList; count++; output.Write("PRIVMSG " + chan + " :@" + uname + " Has successfully joined the queue!\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY } }); flag = false; } if (msg.Equals("!leave", StringComparison.Ordinal)) //cleaned up { queueGrid.Invoke((Action)delegate { for (int i = 0; i < count; i++) { if (nameList[i].twitchname.Equals(uname, StringComparison.Ordinal)) { nameList.RemoveAt(i); count--; output.Write("PRIVMSG " + chan + " :@" + uname + " You have successfully left the queue!\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY } } }); } // actually functioning now string[] steamnamesplit = msg.Split(new Char[] { ' ' }); if (steamnamesplit[0].Equals("!steam", StringComparison.Ordinal)) { flag = false; queueGrid.Invoke((Action)delegate // checks if in the queue { for (int i = 0; i < count; i++) { if (nameList[i].twitchname.Equals(uname, StringComparison.Ordinal)) { try { nameList[i].steamname = steamnamesplit[1]; } catch { } queueGrid.DataSource = blank; // used to fix problem of names not appearing until another action occurs queueGrid.DataSource = nameList; // rebound to display all info output.Write("PRIVMSG " + chan + " :@" + uname + " Your steam name has been successfully updated!\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY flag = true; } } }); currGrid.Invoke((Action)delegate { for (int i = 0; i < groupcount; i++) { if (currentgroup[i].twitchname.Equals(uname, StringComparison.Ordinal)) { try { currentgroup[i].steamname = steamnamesplit[1]; } catch { } queueGrid.DataSource = blank; // used to fix problem of names not appearing until another action occurs queueGrid.DataSource = nameList; // rebound to display all info output.Write("PRIVMSG " + chan + " :@" + uname + " Your steam name has been successfully updated!\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY flag = true; } } }); if (!flag) { output.Write("PRIVMSG " + chan + " :@" + uname + " You can't add your steam name if you're not in the queue!\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY } flag = false; } if (msg.Equals("!queue",StringComparison.Ordinal)) { queueList = ""; foreach (User u in nameList) { queueList += " @" + u.twitchname + ","; } output.Write("PRIVMSG " + chan + " :CURRENT QUEUE: " + queueList + "\r\n"); output.Flush(); } if (msg.Equals("!qhelp", StringComparison.Ordinal)) { output.Write("PRIVMSG " + chan + " :@" + uname + " Command List: !join to join the queue, !leave to leave the queue, !steam 'steamname' to add your steam name, !queue to list the current queue of players\r\n"); output.Flush(); //does not work everytime, works 1st instance or if !queue is called but not others. LOW PRIORITY } // actually functioning now textBox2.Invoke((Action)delegate //puts the chat into the ircbox { //int s = textBox2.Text.Length - textBox2.Height; //if (s < 0) s = 0; //textBox2.Text = textBox2.Text.Substring(s); //textBox2.Text += DateTime.Now.ToShortTimeString() + " " + uname + ": " + msg + "\r\n"; textBox2.AppendText(DateTime.Now.ToShortTimeString() + " " + uname + ": " + msg + "\r\n\r\n"); textBox2.Enabled = false; textBox2.WordWrap = true; textBox2.AcceptsReturn = true; }); /*this.Invoke((Action)delegate { this.TopMost = true; });*/ } //Send pong reply to any ping messages to prevent timeouts (#JustIrcThings) if (buf.StartsWith("PING ")) { output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush(); } if (buf[0] != ':') continue; /* IRC commands come in one of these formats: * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n * :SERVER COMAND ARGS ... :DATA\r\n */ } }
private void QuanLy_Load(object sender, EventArgs e) { User nv = new User(); nv = connect.LoadNV(user); labNhanVien.Text = labNhanVien.Text + nv.HoTen; }
partial void UpdateUser(User instance);
partial void DeleteUser(User instance);
public static User LoadNV(string username) { User nv = new User(); DataTable table = null; if (isConnect()) { SqlCommand com = new SqlCommand(); //com.CommandText = "select from NHANVIEN"; com.CommandText = "select * from NhanVien where username='******'"; com.CommandType = CommandType.Text; com.Connection = con; SqlDataAdapter adap = new SqlDataAdapter(com); table = new DataTable(); adap.Fill(table); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { nv.HoTen = dr[1].ToString(); nv.ID_quanly = Convert.ToInt16(dr[0].ToString()); nv.ID = dr[2].ToString(); nv.Luong = Convert.ToInt32(dr[7].ToString()); nv.NamSinh = Convert.ToDateTime(dr[4].ToString()); nv.gt = dr[6].ToString(); nv.BoPhan = dr[5].ToString(); nv.que = dr[8].ToString(); } } return nv; }