using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace MyQQ
{
    public partial class GroupForm : Form
    {
        int friendId = SearchFriendForm.friendId;

        public GroupForm()
        {
            InitializeComponent();
        }
        DataBase mydatabase = new DataBase();

        private void btnOk_Click(object sender, EventArgs e)
        {
            string sql2 = string.Format("insert into Friends(HostId,FriendId,FriendGroup) values({0},{1},{2})", UserHelper.Loginld, friendId, Convert.ToInt32(cboGroups.SelectedIndex));

            try
            {
                int result = mydatabase.ExecuteSQL(sql2);

                if (result == 1)
                {
                    string sql3 = string.Format("insert into Messages (FromUserId,ToUserId,MessageTypeId,MessageState) values({0},{1},2,0)", UserHelper.Loginld, friendId);

                    int result2 = mydatabase.ExecuteSQL(sql3);

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
           
        }
        //关闭窗体
        private void btnClose_Click(object sender, EventArgs e)
        {
           
            this.Close();
        }
    }
}