Esempio n. 1
0
        /// <summary>
        /// 检查登录
        /// </summary>
        /// <returns></returns>
        private bool CheckUser()
        {
            string   id       = txtUserName.Text.Trim();
            string   pwd      = txtPwd.Text.Trim();
            string   sql      = string.Format(@"select COUNT(*) from Users
                where id={0} and pwd='{1}'", id, pwd);
            DBHelper dbHelper = new DBHelper();

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                int        result  = Convert.ToInt32(command.ExecuteScalar());
                if (result == 1)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, this);
                return(false);
            }
            finally
            {
                dbHelper.Connection.Close();
            }
            return(false);
        }
Esempio n. 2
0
        private void RegistUser()
        {
            string   sql      = string.Format(@"insert into Users (nickName,face,pwd)
            values('{0}','{1}','{2}');
            select @@IDENTITY", txtNickName.Text.Trim(), faceList.picid, txtPwd2.Text.Trim());
            DBHelper dbHelper = new DBHelper();

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                int        id      = Convert.ToInt32(command.ExecuteScalar());
                if (id > 0)
                {
                    MessageBox.Show(string.Format("注册的QQ号码为:{0}\r\n请牢记!", id));
                }
                else
                {
                    UCMessageBox.Show("服务器繁忙,请稍后重试!", this);
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, this);
            }
            finally
            {
                dbHelper.Connection.Close();
            }
            this.Close();
        }
Esempio n. 3
0
        /// <summary>
        /// 检查房间的状态为未开始
        /// </summary>
        /// <returns></returns>
        public bool CheckRoomState()
        {
            DBHelper dbHelper = new DBHelper();
            string   sql      = string.Format("select state from Rooms where rid={0}", roomId);

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                int        state   = Convert.ToInt32(command.ExecuteScalar());
                if (state == 2)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, this);
            }
            finally
            {
                dbHelper.Connection.Close();
            }
            return(true);
        }
Esempio n. 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (faceList.picid.Length == 0)
     {
         UCMessageBox.Show("请选择一个头像!", this);
         return;
     }
     else if (txtNickName.Text.Trim().Length == 0)
     {
         UCMessageBox.Show("昵称不能为空!", this);
         return;
     }
     else if (txtPwd.Text.Trim().Length == 0)
     {
         UCMessageBox.Show("密码不能为空!", this);
         return;
     }
     else if (txtPwd.Text.Trim().Length < 6 || txtPwd.Text.Trim().Length > 16)
     {
         UCMessageBox.Show("密码长度为6~16位!", this);
         return;
     }
     else if (txtPwd2.Text.Trim().Length == 0)
     {
         UCMessageBox.Show("确认密码不能为空!", this);
         return;
     }
     else if (txtPwd2.Text.Trim() != txtPwd.Text.Trim())
     {
         UCMessageBox.Show("两次密码需一致!", this);
         return;
     }
     RegistUser();
 }
Esempio n. 5
0
 /// <summary>
 /// 更新房间状态及信息
 /// </summary>
 private void UpdateRoomInfo()
 {
     //为了安全,先检查后更新数据
     if (CheckRoomState() && GetRoomPlayerCount() < 4)
     {
         //占座
         if (IsNowRoom())
         {
             if (SaveSeat())
             {
                 UCMessageBox.Show("占座成功!", this);
             }
         }
         else
         {
             UCMessageBox.Show("占座失败!别处游戏中", this);
             this.Close();
         }
     }
     else
     {
         UCMessageBox.Show("人数已满或已经开始,不能加入房间!", this);
         //this.Close();
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 设计器支持所需的方法 - 不要
 /// 使用代码编辑器修改此方法的内容。
 /// </summary>
 private void InitializeComponent()
 {
     this.ucMessageBox = new SCM.RF.Client.Tool.Controls.Common.UCMessageBox();
     this.SuspendLayout();
     //
     // ucMessageBox
     //
     this.ucMessageBox.Location = new System.Drawing.Point(0, 0);
     this.ucMessageBox.Name     = "ucMessageBox";
     this.ucMessageBox.Size     = new System.Drawing.Size(300, 260);
     this.ucMessageBox.TabIndex = 1;
     this.ucMessageBox.TabStop  = false;
     this.ucMessageBox.Visible  = false;
     //
     // UCBasicControl
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Dpi;
     this.BackColor           = System.Drawing.Color.Black;
     this.Controls.Add(this.ucMessageBox);
     this.ForeColor = System.Drawing.Color.White;
     this.Name      = "UCBasicControl";
     this.Size      = new System.Drawing.Size(300, 260);
     this.ResumeLayout(false);
 }
Esempio n. 7
0
 public bool CheckInput()
 {
     if (txtUserName.Text.Length == 0)
     {
         UCMessageBox.Show("输入用户名!", this);
         return(false);
     }
     else if (txtPwd.Text.Length == 0)
     {
         UCMessageBox.Show("输入用户名!", this);
         return(false);
     }
     return(true);
 }
Esempio n. 8
0
 //登录按钮的点击事件
 private void pbLoginBtn_Click(object sender, EventArgs e)
 {
     if (CheckInput())
     {
         if (CheckUser())
         {
             FrmRooms rooms = FrmRooms.GetFrmRooms(txtUserName.Text.Trim());
             rooms.Show();
             this.Visible = false;
         }
         else
         {
             UCMessageBox.Show("账号或密码有误!", this);
         }
     }
 }
Esempio n. 9
0
 private void button1_Click(object sender, EventArgs e)
 {
     UCMessageBox.Show("获得 媳妇儿 一个", this);
 }
Esempio n. 10
0
        /// <summary>
        /// 获取玩家数据-头像和昵称,同时切换鼠标悬浮样式
        /// </summary>
        private void GetPlayerData(string uid, int seat)
        {
            DBHelper      dbHelper = new DBHelper();
            string        sql      = string.Format("select nickName,face from users where id={0}", uid);
            SqlDataReader reader   = null;

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    string name = reader["nickName"].ToString();
                    string face = reader["face"].ToString();
                    switch (seat)
                    {
                    case 1:
                        lblPlay1Name.Text    = name;
                        lblPlay1Name.Visible = true;
                        //通过头像名字获取对应的资源
                        pbPlay1.Image = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        //头像变圆
                        ControlUtils.ChangeToCircle(pbPlay1);
                        pbPlay1.Tag    = string.Format(pbPlay1.Tag.ToString(), uid);
                        pbPlay1.Cursor = Cursors.Hand;
                        break;

                    case 2:
                        lblPlay2Name.Text    = name;
                        lblPlay2Name.Visible = true;
                        pbPlay2.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay2);
                        pbPlay2.Tag    = string.Format(pbPlay2.Tag.ToString(), uid);
                        pbPlay2.Cursor = Cursors.Hand;
                        break;

                    case 3:
                        lblPlay3Name.Text    = name;
                        lblPlay3Name.Visible = true;
                        pbPlay3.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay3);
                        pbPlay3.Tag    = string.Format(pbPlay3.Tag.ToString(), uid);
                        pbPlay3.Cursor = Cursors.Hand;
                        break;

                    case 4:
                        lblPlay4Name.Text    = name;
                        lblPlay4Name.Visible = true;
                        pbPlay4.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay4);
                        pbPlay4.Tag    = string.Format(pbPlay4.Tag.ToString(), uid);
                        pbPlay4.Cursor = Cursors.Hand;
                        break;
                    }
                }
                else
                {
                    switch (seat)
                    {
                    case 1:
                        lblPlay1Name.Text    = "";
                        lblPlay1Name.Visible = false;
                        //通过头像名字获取对应的资源
                        pbPlay1.Image = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        //头像变方
                        ControlUtils.ChangeToRect(pbPlay1);
                        pbPlay1.Tag = "1,{0}";
                        if (roomState == 1)
                        {
                            pbPlay1.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay1.Cursor = Cursors.Hand;
                        }
                        break;

                    case 2:
                        lblPlay2Name.Text    = "";
                        lblPlay2Name.Visible = false;
                        pbPlay2.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay2);
                        pbPlay2.Tag = "2,{0}";
                        if (roomState == 1)
                        {
                            pbPlay2.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay2.Cursor = Cursors.Hand;
                        }
                        break;

                    case 3:
                        lblPlay3Name.Text    = "";
                        lblPlay3Name.Visible = false;
                        pbPlay3.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay3);
                        pbPlay3.Tag = "3,{0}";
                        if (roomState == 1)
                        {
                            pbPlay3.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay3.Cursor = Cursors.Hand;
                        }
                        break;

                    case 4:
                        lblPlay4Name.Text    = "";
                        lblPlay4Name.Visible = false;
                        pbPlay4.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay4);
                        pbPlay4.Tag = "4,{0}";
                        if (roomState == 1)
                        {
                            pbPlay4.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay4.Cursor = Cursors.Hand;
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, FrmRooms.GetFrmRooms(id));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 11
0
        //获取房间数据
        private void GetRoomData()
        {
            //重置座位数据,用于标记
            pbPlay1.Tag = "1,{0}";
            pbPlay2.Tag = "2,{0}";
            pbPlay3.Tag = "3,{0}";
            pbPlay4.Tag = "4,{0}";
            string        sql      = string.Format(@"select Rooms.state as rstate,id,seat,
            RoomPlayer.state ustate
            from Rooms
            inner join RoomPlayer on Rooms.rid=RoomPlayer.rid
            where Rooms.rid={0}", roomId);
            DBHelper      dbHelper = new DBHelper();
            SqlDataReader reader   = null;

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                for (int i = 1; i <= 4; i++)
                {
                    if (reader.Read())
                    {
                        //将四个头像设置信息
                        roomState = Convert.ToInt32(reader["rstate"]);
                        int id     = Convert.ToInt32(reader["id"]);
                        int seat   = Convert.ToInt32(reader["seat"]);
                        int ustate = Convert.ToInt32(reader["ustate"]);
                        GetPlayerData(id.ToString(), seat);
                    }
                    //GetPlayerData(0.ToString(), tempNum);
                }
                //遍历所有座位,得到没有上座的座位
                for (int i = 1; i <= 4; i++)
                {
                    Control item = this.Controls.Find("pbPlay" + i, true)[0];
                    //座位信息
                    string[] info = item.Tag.ToString().Split(',');
                    if (info[1] == "{0}")
                    {
                        GetPlayerData(0.ToString(), Convert.ToInt32(info[0]));
                    }
                }

                //0为可用,1为已经开始游戏
                if (roomState == 0)
                {
                    pbRoomState.Image = Properties.Resources.tablen;
                }
                else if (roomState == 1)
                {
                    //更换图标
                    pbRoomState.Image = Properties.Resources.tables;
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, FrmRooms.GetFrmRooms(id));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            UCMessageBox boc = new UCMessageBox(this);

            boc.Show("DENEME", "DENEME 2", MsgButtons.OK, DisplayState.Normal, 30);
        }
Esempio n. 13
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ucMessageBox1 = new UCMessageBox(panel3);
 }