Пример #1
0
        /// <summary>
        /// 发表看法按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PublishBtn_Click(object sender, EventArgs e)
        {
            var sendmsg = this.sendMsgRichTextBox.Text;

            if (sendmsg == "")
            {
                label2.Visible = true;
                label2.Text    = "信息不能为空";
            }
            else
            {
                label2.Visible = false;
                using (var db = new TestDemoWinFormEntities())
                {
                    var datalist    = db.Log_UserMsg.AsQueryable();
                    int a           = int.Parse(LogUserMsg.GetTransId(UserId));
                    var dataMsgList = new Bus_SendMsg();
                    dataMsgList.SendUserId = a;
                    dataMsgList.SendMsg    = UserId + ":" + this.sendMsgRichTextBox.Text;
                    dataMsgList.SendTime   = DateTime.Now;
                    db.Bus_SendMsg.Add(dataMsgList);
                    db.SaveChanges();
                }
                this.MainMsgRichTextBox.Text += "***********" + DateTime.Now + "***********" + "\n";
                this.MainMsgRichTextBox.Text += UserId + ":" + this.sendMsgRichTextBox.Text + "\n";
                this.sendMsgRichTextBox.Text  = "";
            }
        }
Пример #2
0
        /// <summary>
        /// 根据搜索条件去找人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchBtn_Click(object sender, EventArgs e)
        {
            dataGridView1.ReadOnly = true;
            var searchtxt = this.SearchUserIdtxt.Text.Trim();

            if (!string.IsNullOrEmpty(searchtxt))
            {
                using (var db = new TestDemoWinFormEntities())
                {
                    ErrorProvider erp    = new ErrorProvider();
                    var           dbData = db.ViewFriendRelation.AsQueryable();
                    dbData = dbData.Where(c => c.UserId == UserId && c.FriendUserId == searchtxt);
                    if (dbData.Count() != 0)
                    {
                        erp.SetError(SearchUserIdtxt, null);
                        var dbDatalist = db.Log_UserMsg.AsQueryable();
                        dbDatalist = dbDatalist.Where(c => c.UserId == searchtxt);
                        dataGridView1.DataSource = dbDatalist.ToList();
                    }
                    else
                    {
                        erp.SetError(SearchUserIdtxt, "该用户还不是你的好友");
                    }
                }
            }
        }
Пример #3
0
 public static string GetTransId(string UserId)
 {
     using (var db = new TestDemoWinFormEntities())
     {
         var transId = db.Proc_GetTransId(UserId).First().ToString();
         return(transId);
     }
 }
Пример #4
0
        private void CheckRegisterBtn_Click(object sender, EventArgs e)
        {
            var UserIdString     = this.UserIdtxt.Text.Trim();
            var PassWordString   = this.PassWordtxt.Text.Trim();
            var PassWordStringRe = this.PassWordtxt2.Text.Trim();
            var MobileNumString  = this.MobileNumtxt.Text.Trim();

            if (!string.IsNullOrEmpty(UserIdString) && !string.IsNullOrEmpty(PassWordString) && !string.IsNullOrEmpty(PassWordStringRe) && !string.IsNullOrEmpty(MobileNumString))
            {
                if (!PassWordString.Equals(PassWordStringRe))
                {
                    MessageBox.Show("密码输入不相同,请重新输入", "温馨提示");
                }
                else
                {
                    using (var db = new TestDemoWinFormEntities())
                    {
                        var dbData = db.Log_UserMsg.AsQueryable();
                        dbData = dbData.Where(c => c.UserId == UserIdString && c.MobileNum == MobileNumString);
                        if (dbData.Count() == 0)
                        {
                            var datalist = new Log_UserMsg();
                            datalist.UserId     = UserIdString;
                            datalist.PassWord   = PassWordString;
                            datalist.MobileNum  = MobileNumString;
                            datalist.CreateTime = DateTime.Now;
                            db.Log_UserMsg.Add(datalist);
                            db.SaveChanges();
                            MessageBox.Show("恭喜你注册成功!", "成功提示");
                            this.UserIdtxt.Text    = "";
                            this.PassWordtxt.Text  = "";
                            this.PassWordtxt2.Text = "";
                            this.MobileNumtxt.Text = "";
                        }
                        else if (dbData.Count() != 0)
                        {
                            MessageBox.Show("该账号已被注册!", "错误提示");
                        }
                        else
                        {
                            MessageBox.Show("该手机号已被注册!", "错误提示");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("请填写完整!", "温馨提示");
            }
        }
Пример #5
0
        /// <summary>
        /// 添加
        /// 先进行查询是否存在该用户
        /// 然后再判断是否已经添加该用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddNewFriendBtn_Click(object sender, EventArgs e)
        {
            ErrorProvider erp = new ErrorProvider();

            dataGridView1.ReadOnly = true;
            var searchtxt = this.SearchUserIdtxt.Text.Trim();

            using (var db = new TestDemoWinFormEntities())
            {
                //检查用户是否存在
                var checkUserId = db.Log_UserMsg.AsQueryable();
                checkUserId = checkUserId.Where(c => c.UserId == searchtxt);
                if (checkUserId.Count() == 0)
                {
                    erp.SetError(SearchUserIdtxt, "该用户不存在,请重新输入");
                }
                else
                {
                    erp.SetError(SearchUserIdtxt, null);
                    //检查是否已经是我的好友
                    var transId             = db.Proc_GetTransId(UserId).First().ToString();
                    int temp                = int.Parse(transId);
                    var checkfriendRelation = db.Rla_FriendRelation.AsQueryable();
                    checkfriendRelation = checkfriendRelation.Where(c => c.UserId == searchtxt && c.ParentUserTransId == temp);
                    if (checkfriendRelation.Count() == 0)
                    {
                        erp.SetError(SearchUserIdtxt, null);
                        var datalist = new Rla_FriendRelation();
                        datalist.UserId            = searchtxt;
                        datalist.ParentUserTransId = int.Parse(transId);
                        datalist.Deleted           = 0;
                        db.Rla_FriendRelation.Add(datalist);
                        db.SaveChanges();
                        MessageBox.Show("添加成功", "温馨提示");
                        var dbData = db.ViewFriendRelation.AsQueryable();
                        dbData = dbData.Where(c => c.UserId == UserId && c.Deleted != 1);
                        dataGridView1.DataSource = dbData.ToList();
                        SearchUserIdtxt.Text     = "";
                        erp.SetError(SearchUserIdtxt, "");
                    }
                    else
                    {
                        erp.SetError(SearchUserIdtxt, "该用户您已经添加为好友,请勿重复添加");
                    }
                }
            }
        }
Пример #6
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     dataGridView1.ReadOnly = true;
     if (!string.IsNullOrEmpty(UserId))
     {
         this.label1.Text = "欢迎您:" + UserId;
         a = 2;
         using (var db = new TestDemoWinFormEntities())
         {
             var dbData = db.ViewFriendRelation.AsQueryable();
             dbData = dbData.Where(c => c.UserId == UserId && c.Deleted != 1);
             dataGridView1.DataSource = dbData.ToList();
         }
     }
     else
     {
         this.label1.Text = "请登录!";
         a = 1;
     }
 }
Пример #7
0
        private void SignInBtn_Click(object sender, EventArgs e)
        {
            var UserIdString   = this.UserIdtxt.Text.Trim();
            var PassWordString = this.PassWordtxt.Text.Trim();

            if (!string.IsNullOrEmpty(UserIdString) && !string.IsNullOrEmpty(PassWordString))
            {
                using (var db = new TestDemoWinFormEntities())
                {
                    var dbData = db.Log_UserMsg.AsQueryable();
                    dbData = dbData.Where(c => c.UserId == UserIdString);
                    a++;
                    if (dbData.Count() != 0)
                    {
                        dbData = dbData.Where(c => c.PassWord == PassWordString);
                        if (dbData.Count() != 0)
                        {
                            this.Hide();
                            MainForm mf = new MainForm();
                            mf.UserId = UserIdString;
                            mf.Show();
                        }
                        else if (dbData.Count() == 0 && a < 3)
                        {
                            MessageBox.Show("密码错误!请重新输入", "登录失败");
                            this.PassWordtxt.Text = "";
                        }
                    }
                    if (a >= 3)
                    {
                        MessageBox.Show("密码错误!请联系管理员找回密码", "登录失败");
                        this.PassWordtxt.Text = "";
                    }
                }
            }
            else
            {
                MessageBox.Show("请填写完整", "登录失败");
            }
        }