예제 #1
0
    public void AddFriend(int ID_1, int ID_2)
    {
        SQLConnectionClass oConnection = new SQLConnectionClass();

        SQLCommandClass oCommand = new SQLCommandClass();

        TableOpreatorClass TablePerator = new TableOpreatorClass();

        if (isFriendsExist(ID_1, ID_2))
        {
            return;// они уже друзья. Не надо заново добавлять  друзей
        }
        int ID = TablePerator.GenerateNewID("ID", "FriendTable");

        string sqlIns = "INSERT INTO FriendTable( ID, Friend_1_ID, Friend_2_ID ) VALUES (@ID, @Friend_1, @Friend_2 )";

        //использовать только в такой последовательности
        oCommand.PrepareInsertQuery(sqlIns, oConnection.connection);


        int newIDPeoples = ID_OPerator.createNewTableID("ID", "Peoples");

        if (newIDPeoples == -2)
        {
            //некорректные параметры
        }

        oCommand.AddInsertParameter("@ID", ID);//заносим новый айди
        oCommand.AddInsertParameter("@Friend_1", ID_1);
        oCommand.AddInsertParameter("@Friend_2", ID_2);

        oCommand.ExecuteQuery();
        oConnection.closeConnection();
    }
예제 #2
0
    public void createNewUserIDCounter(int userID, string counterName, int value)//работает строго с таблицей UserCounters
    {
        SQLConnectionClass oConnection = new SQLConnectionClass();

        SQLCommandClass oCommand = new SQLCommandClass();

        string sqlIns = "INSERT INTO UserCounters( UserID, " + counterName + " ) " + " VALUES(@UserID, @Value )";

        //использовать только в такой последовательности
        oCommand.PrepareInsertQuery(sqlIns, oConnection.connection);


        int newIDPeoples = ID_OPerator.createNewTableID("ID", "Peoples");

        if (newIDPeoples == -2)
        {
            //некорректные параметры
        }
        oCommand.AddInsertParameter("@UserID", userID);//заносим новый айди
        oCommand.AddInsertParameter("@Name", value);

        oCommand.ExecuteQuery();

        oConnection.closeConnection();
    }
예제 #3
0
    protected void ButtonRegistration_Click(object sender, EventArgs e)
    {
        PeoplesClass oPeople = new PeoplesClass();

        bool loginExist = false;

        if (oPeople.isLoginExist(this.TextBoxPhone.Text))
        {
            this.LabelMessage.Text = " логин уже привязан к другой странице. Укажите другой логин.";
            loginExist             = true;
        }

        if (this.TextBoxPassw.Text.Length < 5)
        {
            this.LabelMessage.Text = " пароль слишком короткий. введите пароль не менее 5 символов";
            loginExist             = true;
        }

        if (!loginExist)
        {
            SQLConnectionClass oConnection = new SQLConnectionClass();

            SQLCommandClass oCommand = new SQLCommandClass();

            string sqlIns = "INSERT INTO Peoples( ID, Name, Surname, Phone, Password) VALUES (@ID, @Name, @Surname, @Phone, @Password)";

            //использовать только в такой последовательности
            oCommand.PrepareInsertQuery(sqlIns, oConnection.connection);


            int newIDPeoples = ID_OPerator.createNewTableID("ID", "Peoples");
            if (newIDPeoples == -2)
            {
                //некорректные параметры
            }

            oCommand.AddInsertParameter("@ID", Convert.ToString(newIDPeoples));//заносим новый айди
            oCommand.AddInsertParameter("@Name", this.TextBoxName.Text);
            oCommand.AddInsertParameter("@Surname", this.TextBoxSurname.Text);
            oCommand.AddInsertParameter("@Phone", this.TextBoxPhone.Text);
            oCommand.AddInsertParameter("@Password", this.TextBoxPassw.Text);

            oCommand.ExecuteQuery();

            oConnection.closeConnection();


            Response.Cookies[ConstantNames.UserID].Value   = Convert.ToString(newIDPeoples);//UserID to cookie
            Response.Cookies[ConstantNames.UserID].Expires = DateTime.Now.AddDays(1);

            Response.Redirect("Login.aspx");
        }
    }