//插入学生数据 public void insertStuInfo(StuInfo stu) { String sql = "insert into students values('" + stu.getsno() + "','" + stu.getsname() + "','" + stu.getssex() + "','" + stu.getsclass() + "')"; SQLiteCommand command = new SQLiteCommand(sql, dbConnection); command.ExecuteNonQuery(); }
//插入学生信息 private void insertStu(string msg) { //判断是否登录 if (!isLegal(mSocket.RemoteEndPoint.ToString())) { mSocket.Send(Encoding.UTF8.GetBytes(MyProtocol.head_unlogin)); return; } string[] args = msg.Split('#'); StuInfo stu = new StuInfo(resumeSpecStr(args[0]), resumeSpecStr(args[1]), resumeSpecStr(args[2]), resumeSpecStr(args[3])); if (mDataManager.isSnoExists(stu.getsno())) { mSocket.Send(Encoding.UTF8.GetBytes(MyProtocol.head_insertStu + MyProtocol.body_exists)); Console.WriteLine("insert denied(exist):" + stu.getsname()); return; } //添加 mDataManager.insertStuInfo(stu); //发送成功消息 mSocket.Send(Encoding.UTF8.GetBytes(MyProtocol.head_insertStu + MyProtocol.body_success)); Console.WriteLine("insert a student:" + stu.getsname()); }