Esempio n. 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();
    }
Esempio n. 2
0
    public int InsertNewWall()//returns new wall ID
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        TableValue value1 = new TableValue();

        value1.ValueName = "ID";
        int ID = oTable.GenerateNewID("ID", "Wall");

        value1.Value = ID;

        int returnValue = ID;

        TableValue value2 = new TableValue();

        value2.ValueName = "PublicationListID";
        ID           = oTable.GenerateNewID("ID", "PublicationList");
        value2.Value = ID;

        TableValue value3 = new TableValue();

        value3.ValueName = "DateTime";
        value3.Value     = DateTime.Now;

        List <TableValue> tableValueList = new List <TableValue>();

        tableValueList.Add(value1);
        tableValueList.Add(value2);
        tableValueList.Add(value3);

        oTable.InsertToTable(tableValueList, "Wall");//CreateNewWall

        return(returnValue);
    }
Esempio n. 3
0
    /// <summary>
    /// Это метод используется чаще всего
    /// </summary>
    /// <param name="ImageID"></param>
    /// <param name="CommentPeopleID"></param>
    /// <param name="text"></param>

    public void AddCommentToImage(int ImageID, int CommentPeopleID, string text)
    {
        if (text == null || text == "")
        {
            return;//если пустая строка то не добавляем
        }
        SQLConnectionClass oConnection  = new SQLConnectionClass();
        SQLCommandClass    oCommand     = new SQLCommandClass();
        TableOpreatorClass TablePerator = new TableOpreatorClass();

        int ID = this.GenerateNewID(ImageID);//Последовательность номеров для каждой картинки

        TableOpreatorClass oTable = new TableOpreatorClass();
        int ImgCommentID          = oTable.GenerateNewID("ImgCommentID", "ImageComment");//Уникальный номер для каждой картинки

        string sqlIns = "INSERT INTO ImageComment( ID, ImgCommentID, ImageID, CommentPeopleID, Text ) VALUES (@ID ,@ImgComID, @ImageID, @CommentPeopleID, @Text )";

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


        oCommand.AddInsertParameter("@ID", ID);                 //заносим новый айди
        oCommand.AddInsertParameter("@ImgComID", ImgCommentID); //заносим новый айди
        oCommand.AddInsertParameter("@ImageID", ImageID);
        oCommand.AddInsertParameter("@CommentPeopleID", CommentPeopleID);
        oCommand.AddInsertParameter("@Text", text);

        oCommand.ExecuteQuery();
        oConnection.closeConnection();
    }
Esempio n. 4
0
    public int GetPublicationListID(int WallID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        int returnValue = Convert.ToInt32(oTable.GetValueFromTable(WallID, "PublicationListID", "Wall"));

        return(returnValue);
    }
Esempio n. 5
0
    public DateTime GetDateTime(int WallID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        DateTime returnValue = Convert.ToDateTime(oTable.GetValueFromTable(WallID, "DateTime", "Wall"));

        return(returnValue);
    }
Esempio n. 6
0
    public object GetPeopleValue(int PeopleID, String ValueName)
    {
        TableOpreatorClass tempObj = new TableOpreatorClass();

        object returnValue = null;

        returnValue = tempObj.GetValueFromTable(PeopleID, ValueName, "Peoples");

        return(returnValue);
    }
Esempio n. 7
0
    public string GetTextOfPublication(int PublicationID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();
        object             oText  = oTable.GetValueFromTableByIDName(PublicationID, "UniqueID", "Text", "Publication");

        if (oText == null)
        {
            return("");
        }
        string text = oText.ToString();

        return(text);
    }
Esempio n. 8
0
    /// <summary>
    /// returns -1, if publication list of wall is not exist))
    /// </summary>
    /// <param name="WallID"></param>
    /// <returns></returns>
    public int GetPublicationList_ID_ofWall(int WallID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();
        object             ID     = oTable.GetValueFromTable(WallID, "PublicationListID", "Wall");

        if (ID == null)
        {
            return(-1);
        }
        int returnValue = Convert.ToInt32(ID);

        return(returnValue);
    }
Esempio n. 9
0
    public int GetAuthorID(int PublicationID)
    {
        TableOpreatorClass oTable  = new TableOpreatorClass();
        object             oAuthID = oTable.GetValueFromTableByIDName(PublicationID, "UniqueID", "AuthorID", "Publication");

        if (oAuthID == null)
        {
            return(-1);
        }

        int AuthID = Convert.ToInt32(oAuthID);

        return(AuthID);
    }
Esempio n. 10
0
/// <summary>
/// returns -1 if list of images is clear
/// </summary>
/// <param name="PublicationID"></param>
/// <returns></returns>
    public int GetImageListID(int PublicationID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();
        object             ListID = oTable.GetValueFromTableByIDName(PublicationID, "UniqueID", "ImageListID", "Publication");

        if (ListID == null)
        {
            return(-1);
        }

        int listID = Convert.ToInt32(ListID);

        return(listID);
    }
Esempio n. 11
0
    public string GetImageCommentsToListBox(int ImageID, ListBox listBox)
    {
        string returnValue = null;

        if (ImageID < 0)
        {
            return(returnValue);
        }

        listBox.Items.Clear();

        string comText;

        int  id   = 1;// может прерываться, возможны точки разрыва
        bool flag = true;

        TableOpreatorClass oTable = new TableOpreatorClass();

        int maxID = oTable.GetMaxID("ID", "ImageComment");

        while (flag)
        {
            comText = this.selectImageCommentText(ImageID, id);


            int imgCommentID = this.GetImgCommentID(id, ImageID);//???????
            if (id > maxID)
            {
                id++;
                flag = false;
            }

            if (comText == null)// Если ничего не прочитано
            {
                id++;
            }
            else
            {
                ListItem listItem = new ListItem();
                listItem.Text  = comText;
                listItem.Value = Convert.ToString(imgCommentID);
                listBox.Items.Add(listItem);
                id++;
            }
        }

        return(returnValue);
    }
Esempio n. 12
0
    public List <int> GetPublicationIDs(int publicationListID)
    {
        List <int> returnValue = new List <int>();

        TableOpreatorClass oTable = new TableOpreatorClass();
        bool flag = true;

        while (flag)
        {
            object id = oTable.GetValueFromTable(publicationListID, "PublicationID", "PublicationList");
            if (id == null)
            {
                flag = false;
                continue;
            }
            int ID = Convert.ToInt32(id);
            returnValue.Add(ID);
        }

        return(returnValue);
    }
Esempio n. 13
0
    public void AddNewLike(string groupTableName /*Images, Posts or other*/, int groupID /*ImageID, PostID*/, int PeopleID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        List <TableValue> insertValues = new List <TableValue>();

        TableValue tabValue = new TableValue();

        tabValue.ValueName = "GroupTableName";
        tabValue.Value     = groupTableName;
        insertValues.Add(tabValue);

        TableValue tabValue1 = new TableValue();

        tabValue1.ValueName = "GroupID";
        tabValue1.Value     = groupID;
        insertValues.Add(tabValue1);


        TableValue tabValue2 = new TableValue();

        tabValue2.ValueName = "PeopleID";
        tabValue2.Value     = PeopleID;
        insertValues.Add(tabValue2);

        TableValue tabValue3 = new TableValue();

        tabValue3.ValueName = "UniqueID";
        tabValue3.Value     = oTable.GetMaxID("UniqueID", "Like");
        insertValues.Add(tabValue3);

        TableValue tabValue4 = new TableValue();

        tabValue4.ValueName = "IDinGroup";
        tabValue4.Value     = oTable.GetMaxIDInGroup("IDinGroup", "Like", "GroupID", groupID);
        insertValues.Add(tabValue4);

        oTable.InsertToTable(insertValues, "Like");
    }
Esempio n. 14
0
    public void DeletePublicationList(int ID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        oTable.DeleteValueFromTable("ID", ID, "PublicationList");
    }
Esempio n. 15
0
    public void InsertNewPublication(int AuthorID /*PeopleID*/, int WallID, string Text, List <int> ImageIDList)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        TableValue value1 = new TableValue();

        value1.ValueName = "WallID";
        value1.Value     = WallID;


        TableValue value2 = new TableValue();

        value2.ValueName = "UniqueID";
        int PublicationID = oTable.GenerateNewID("UniqueID", "Publication");

        value2.Value = PublicationID;


        TableValue value3 = new TableValue();

        value3.ValueName = "IDinSequence";
        value3.Value     = oTable.GetMaxIDInGroup("IDinSequence", "Publication", "WallID", WallID);/*У стенки много публикаций
                                                                                                    * Каждая публикация имеет уникальный айди и айди (IDinSequence) в последовательности публикаций со сходным WallID                                                                                      */

        TableValue value4 = new TableValue();

        value4.ValueName = "DateTime";
        value4.Value     = DateTime.Now;

        TableValue value5 = new TableValue();

        value5.ValueName = "ImageListID";
        value5.Value     = oTable.GenerateNewID("ID", "ImageList");

        TableValue value6 = new TableValue();

        value6.ValueName = "AuthorID";
        value6.Value     = AuthorID;

        TableValue value7 = new TableValue();

        value7.ValueName = "Text";
        value7.Value     = Text;

        List <TableValue> tableValueList = new List <TableValue>();

        tableValueList.Add(value1);
        tableValueList.Add(value2);
        tableValueList.Add(value3);
        tableValueList.Add(value4);
        tableValueList.Add(value5);
        tableValueList.Add(value6);
        tableValueList.Add(value7);

        oTable.InsertToTable(tableValueList, "Wall");//CreateNewWall


        tableValueList.Clear();

        TableValue value8 = new TableValue();

        value8.ValueName = "ID";
        Wall oWall             = new Wall();
        int  PublicationListID = oWall.GetPublicationListID(WallID);//узнаем айди списка публикаций

        value8.Value = PublicationListID;

        TableValue value9 = new TableValue();

        value9.ValueName = "PublicationID";
        value9.Value     = PublicationID;


        oTable.InsertToTable(tableValueList, "PublicationList");//CreateNewWall
    }
Esempio n. 16
0
    public void DeleteWall(int WallID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        oTable.DeleteValueFromTable("ID", WallID, "Wall");
    }
Esempio n. 17
0
    public void DeletePublication(int UniqueID)
    {
        TableOpreatorClass oTable = new TableOpreatorClass();

        oTable.DeleteValueFromTable("UniqueID", UniqueID, "Publication");
    }