Exemplo n.º 1
0
        public void userForm()
        {
            List <List <string> > arr = new List <List <string> >();
            List <string>         str = new List <string>();

            while (true)
            {
                Thread.Sleep(75);
                str = objSQL.getInfoUser(localId.ToString());
                post.sendMes(str[0]);
                Thread.Sleep(40);
                post.sendMes(objSQL.getUserInformationAboutYourself("0")[0]);
                Thread.Sleep(40);
                post.sendMes(objSQL.getUserInformationAboutYourself(localId.ToString())[0]);


                message = post.recvMes();
                if (message == "end" && localId != -1)
                {
                    post.deliteLocalId(localId);
                    localId = -1;
                    break;
                }
                else if (message == "redaction")
                {
                    //Редактирование от лица пользователя
                    str = objSQL.getInfoUser(localId.ToString());
                    post.sendMes(str[0]);
                    message = post.recvMes();
                    if (message == "end")
                    {
                        continue;
                    }
                    else
                    {
                        string[] buffer      = message.Split(',');
                        string   login       = "******" + buffer[0] + "'";
                        string   pass        = "******" + buffer[1] + "'";
                        string   name        = "Фио = '" + buffer[2] + "'";
                        string   zp          = "ЗП = '" + buffer[5] + "'";
                        string   position    = "Должность = '" + buffer[4] + "'";
                        string   phoneNumber = "Телефон = '" + buffer[3] + "'";
                        objSQL.redactionInfoUser(login, localId.ToString());
                        objSQL.redactionInfoUser(pass, localId.ToString());
                        objSQL.redactionInfoUser(name, localId.ToString());
                        objSQL.redactionInfoUser(zp, localId.ToString());
                        objSQL.redactionInfoUser(position, localId.ToString());
                        objSQL.redactionInfoUser(phoneNumber, localId.ToString());
                    }
                    continue;
                }
                else if (message == "aboutYou")
                {
                    message = post.recvMes();
                    objSQL.updateInformationAboutYourself(message, localId.ToString());
                    continue;
                }
            }
        }
Exemplo n.º 2
0
        public void sort(TcpClient tcpClient)
        {
            Posts    post = new Posts(tcpClient);
            SQLclass sql  = new SQLclass();

            List <string> str2  = sql.getLoginsAndId();
            List <string> ready = new List <string>();
            List <string> name  = new List <string>();
            int           i     = 0;

            while (i != str2.Count())
            {
                string[] words = str2[i].Split('|');
                name.Add(words[1]);
                i++;
            }
            string mes;

            name.Sort();
            Thread.Sleep(50);
            post.sendMes(str2.Count().ToString());
            Thread.Sleep(40);
            post.sendMes("|id|Логин                    |Пароль                   |ФИО                      |Зарплата                 |Должность                |Телефон                  |\n");
            for (i = 0; i < str2.Count(); i++)
            {
                Thread.Sleep(40);
                mes = sql.getInfoUserWhereLogin(name[i]) + "|" + sql.getInfoUser(sql.getInfoUserWhereLogin(name[i]))[0];
                ready.Add(mes);
                post.sendMes(this.makeTable(ready, 1)[0] + "\n");
                ready.Clear();
            }
        }
Exemplo n.º 3
0
        public List <string> serchForm()
        {
            List <List <string> > arr = new List <List <string> >();
            List <string>         str = new List <string>();

            List <List <string> > arr1 = new List <List <string> >();
            List <string>         str1 = new List <string>();

            str = objSQL.getLoginsAndId();
            int size = objSQL.returnSizeBD();

            int i = 0, j = 0, k = 0, bilLiSovpod = 0, maxSchet = 0;

            int[] schet = new int[size];

            for (i = 0; i < size; i++)
            {
                schet[i] = 0;
                str[i]  += '\n';
                while (true)
                {
                    if (str[i][j] == '\n')
                    {
                        if (maxSchet < schet[i])
                        {
                            maxSchet = schet[i];
                        }

                        j = 0; break;
                    }

                    if (str[i][j] >= 'А' && str[i][j] <= 'я')
                    {
                        if (str[i][j] == message[k] || str[i][j] == message[k] - 32 || str[i][j] == message[k] + 32)
                        {
                            schet[i]++;
                            k++;
                            bilLiSovpod = 1;
                        }
                        else
                        if (maxSchet < schet[i])
                        {
                            maxSchet = schet[i];
                            schet[i] = 0;

                            k = 0;
                        }
                    }
                    else
                    if (str[i][j] >= 'A' && str[i][j] <= 'Z' || str[i][j] >= 'a' && str[i][j] <= 'z')
                    {
                        if (str[i][j] >= 'a' && str[i][j] <= 'z')
                        {
                            if (str[i][j] == message[k] || str[i][j] - 32 == message[k])
                            {
                                schet[i]++;
                                k++;
                                bilLiSovpod = 1;
                            }
                            else
                            if (maxSchet < schet[i])
                            {
                                maxSchet = schet[i];
                                schet[i] = 0;

                                k = 0;
                            }
                        }
                        else
                        if (str[i][j] == message[k] || str[i][j] + 32 == message[k])
                        {
                            schet[i]++;
                            k++;
                            bilLiSovpod = 1;
                        }
                        else
                        if (maxSchet < schet[i])
                        {
                            maxSchet = schet[i];
                            schet[i] = 0;

                            k = 0;
                        }
                    }
                    else
                    if (str[i][j] >= '0' && str[i][j] <= '9')
                    {
                        if (str[i][j] == message[k])
                        {
                            schet[i]++;
                            k++;
                            bilLiSovpod = 1;
                        }
                        else
                        if (maxSchet < schet[i])
                        {
                            maxSchet = schet[i];
                            schet[i] = 0;

                            k = 0;
                        }
                    }

                    j++;
                }

                schet[i] = maxSchet;
                maxSchet = 0;
                k        = 0;
            }

            if (bilLiSovpod == 0)
            {
                str1.Add("Не было ни одного совпадения");
                return(str1);
            }
            else
            {
                maxSchet = 0;

                for (i = 0; i < size; i++)
                {
                    if (schet[i] > maxSchet)
                    {
                        maxSchet = schet[i];
                    }
                }
                k = 0;
                int[] mas = new int[size];
                for (i = 0; i < size; i++)
                {
                    if (schet[i] == 0)
                    {
                        continue;
                    }
                    if (schet[i] == maxSchet || schet[i] == maxSchet - 1)
                    {
                        str1.Add(str[i]);

                        k++;
                    }
                    else
                    {
                        mas[i] = 0;
                    }
                }
                i = 0;
                int size2 = k;
                k++;
                post.sendMes(k.ToString());
                k = 0;
                List <string> id = new List <string>();
                while (true)
                {
                    if (k == size2)
                    {
                        break;
                    }
                    string[] words = str1[k].ToString().Split('|');
                    id.Add(words[0]);
                    str      = objSQL.getInfoUser(id[k].ToString());
                    str1[k]  = id[k] + "|";
                    str1[k] += str[0];
                    k++;
                    i++;
                }

                return(str1);
            }
        }