Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            String Theme   = richTextBox1.Text;
            String Comment = richTextBox2.Text;

            int            NewID    = 0;
            DB             db       = new DB();
            DataTable      table    = new DataTable();
            DataTable      table1   = new DataTable();
            SqlDataAdapter adapter  = new SqlDataAdapter();
            SqlCommand     searchID = new SqlCommand("SELECT * FROM Letters", db.GetConnection());

            //SqlCommand searchID1 = new SqlCommand("SELECT * FROM LettersOfWorkers", db.GetConnection());
            adapter.SelectCommand = searchID;
            adapter.Fill(table);
            NewID = table.Rows.Count + 1;
            int        id_recip = comboBox1.SelectedIndex + 1;
            SqlCommand command  = new SqlCommand("INSERT INTO Letters(id, id_Sender, id_recipient,SendDate,SendTime,id_status,Theme,Comment,IsInDrafts,IsInTrash,IsSigned) VALUES(@UID, @USender, @URecipient,@UDate,@UTime,@UStatus,@UTheme,@UComment,@IsInDrafts,@IsInTrash,@IsSigned)", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.Int).Value          = NewID;
            command.Parameters.Add("@USender", SqlDbType.Int).Value      = Convert.ToInt32(ClientSession.iduser);
            command.Parameters.Add("@URecipient", SqlDbType.Int).Value   = Convert.ToInt32(id_recip);
            command.Parameters.Add("@UTheme", SqlDbType.VarChar).Value   = richTextBox1.Text;
            command.Parameters.Add("@UStatus", SqlDbType.Int).Value      = "1";
            command.Parameters.Add("@UComment", SqlDbType.VarChar).Value = richTextBox2.Text;
            command.Parameters.Add("@UDate", SqlDbType.Date).Value       = DateTime.Now.ToString("dd MMMM yyyy");
            command.Parameters.Add("@UTime", SqlDbType.Time).Value       = DateTime.Now.ToString("HH:mm:ss");
            command.Parameters.Add("@UWritten", SqlDbType.Bit).Value     = false;
            command.Parameters.Add("@IsInDrafts", SqlDbType.Bit).Value   = false;
            command.Parameters.Add("@IsInTrash", SqlDbType.Bit).Value    = false;
            command.Parameters.Add("@IsSigned", SqlDbType.Bit).Value     = false;


            adapter.SelectCommand = command;
            adapter.Fill(table);
            string Link = "C:/Users/Viral/OneDrive/Рабочий стол/Тестовая папка для писем/document" + NewID + ".txt";

            File.WriteAllText(Link, DocumentText);

            SqlCommand command1 = new SqlCommand("INSERT INTO Documents(id, Name,CreationDate,CreationTime,Link) VALUES(@LID,@LName,@LCreationDate,@LCreationTime,@LLink)", db.GetConnection());

            command1.Parameters.Add("@LID", SqlDbType.Int).Value            = NewID;
            command1.Parameters.Add("@LName", SqlDbType.VarChar).Value      = richTextBox1.Text;
            command1.Parameters.Add("@LCreationDate", SqlDbType.Date).Value = "2021-05-11";
            command1.Parameters.Add("@LCreationTime", SqlDbType.Time).Value = "02:45:36";
            command1.Parameters.Add("@LLink", SqlDbType.VarChar).Value      = Link;
            //command1.Parameters.Add("@LDID", SqlDbType.Int).Value = NewID;
            adapter.SelectCommand = command1;
            adapter.Fill(table1);
            Form1 form1 = new Form1();

            form1.Show();
            Hide();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String FirstNameBox      = textBox2.Text;
            String LastNameBox       = textBox1.Text;
            String MiddleNameBox     = textBox3.Text;
            String Position          = textBox4.Text;
            String PasswordBox       = textBox6.Text;
            String PasswordBoxRepeat = textBox5.Text;
            String Department        = textBox7.Text;
            String LoginBox          = textBox9.Text;
            String Email             = textBox8.Text;

            int            NewID    = 0;
            DB             db       = new DB();
            DataTable      table    = new DataTable();
            SqlDataAdapter adapter  = new SqlDataAdapter();
            SqlCommand     searchID = new SqlCommand("SELECT * FROM workers", db.GetConnection());

            adapter.SelectCommand = searchID;
            adapter.Fill(table);
            NewID = table.Rows.Count + 1;
            SqlCommand command = new SqlCommand("INSERT INTO Workers(ID, FirstName, LastName, MiddleName, Login, Password, Position, Department, IsActive, Email, id_AccessGroup) VALUES(@UID, @UFN, @ULN, @UMD, @UL, @UP, @UPos, @UDepart, @UActive, @UEmail,@UAcc)", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.Int).Value         = NewID;
            command.Parameters.Add("@UFN", SqlDbType.VarChar).Value     = FirstNameBox;
            command.Parameters.Add("@ULN", SqlDbType.VarChar).Value     = LastNameBox;
            command.Parameters.Add("@UMD", SqlDbType.VarChar).Value     = MiddleNameBox;
            command.Parameters.Add("@UL", SqlDbType.VarChar).Value      = LoginBox;
            command.Parameters.Add("@UP", SqlDbType.VarChar).Value      = PasswordBox;
            command.Parameters.Add("@UPos", SqlDbType.VarChar).Value    = Position;
            command.Parameters.Add("@UDepart", SqlDbType.VarChar).Value = Department;
            command.Parameters.Add("@UEmail", SqlDbType.VarChar).Value  = Email;
            command.Parameters.Add("@UActive", SqlDbType.VarChar).Value = "True";
            command.Parameters.Add("@UAcc", SqlDbType.VarChar).Value    = "2";



            adapter.SelectCommand = command;
            adapter.Fill(table);
            // подумать о генерации ключа
        }
Exemplo n.º 3
0
        public bool isUserExists()
        {
            DB               db      = new DB();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = login_box.Text;

            adapter.SelectCommand = command; //Указываем какую команду будем выполнять
            adapter.Fill(table);             //Заполняем таблицу данными

            if (table.Rows.Count > 0)
            {
                MessageBox.Show("Такой логин есть, введите другой");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            String    Login = textBox1.Text;
            String    Pass  = textBox2.Text;
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Workers where Login = @UL AND Password = @UP", db.GetConnection());

            command.Parameters.Add("@UL", SqlDbType.VarChar).Value = Login;
            command.Parameters.Add("@UP", SqlDbType.VarChar).Value = Pass;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            ClientSession.UserName = textBox1.Text;

            if (table.Rows.Count > 0)
            {
                ClientSession.iduser = table.Rows[0][0].ToString();
                string accessgroup = table.Rows[0][9].ToString();
                if (accessgroup == "1")
                {
                    Form8 form8 = new Form8();
                    form8.Show();
                    Hide();
                }
                else
                {
                    Form1 form1 = new Form1();
                    form1.Show();
                    Hide();
                }
            }
            else
            {
                MessageBox.Show("Введен неверный логин или пароль");
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            DB             db         = new DB();
            SqlCommand     newcommand = new SqlCommand("Select * from Workers where id = @UIDU", db.GetConnection());
            SqlDataAdapter adapter    = new SqlDataAdapter();

            newcommand.Parameters.Add("@UIDU", SqlDbType.VarChar).Value = ClientSession.iduser;
            DataTable table2 = new DataTable();

            adapter.SelectCommand = newcommand;
            adapter.Fill(table2);
            string Pass        = table2.Rows[0][7].ToString();
            string Passnospace = Pass.Replace(" ", "");

            if (Passnospace == textBox1.Text)
            {   // поменять на реплейс
                SqlCommand command = new SqlCommand("UPDATE Workers(Password) Values(@UNewPass) where id = @UIDU ", db.GetConnection());
                command.Parameters.Add("@UIDU", SqlDbType.VarChar).Value     = ClientSession.iduser;
                command.Parameters.Add("@UNewPass", SqlDbType.VarChar).Value = textBox2.Text;
                Hide();
            }
            else
            {
                MessageBox.Show("Введен неверный логин или пароль");
            }
            Hide();
        }
Exemplo n.º 6
0
        private void buttonCreateAccount_Click(object sender, EventArgs e)
        {
            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("INSERT INTO `users`(`firstname`, `lastname`, `emailaddress`, `username`, `password`) VALUES (@fn, @ln, @email, @usn, @pass)", db.GetConnection());

            command.Parameters.Add("@fn", MySqlDbType.VarChar).Value    = textboxFirstname.Text;
            command.Parameters.Add("@ln", MySqlDbType.VarChar).Value    = textboxLastname.Text;
            command.Parameters.Add("@email", MySqlDbType.VarChar).Value = textboxEmailaddress.Text;
            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value   = textboxUsername.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value  = textboxPassword.Text;
            db.openConnection();

            if (!checktbvalues())
            {
                if (textboxPassword.Text == textboxConfirmpassword.Text)
                {
                    if (checkUsername())
                    {
                        MessageBox.Show("This username has already taken");
                    }
                    else
                    {
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Account Created Successfully");
                            LoginForm loginform = new LoginForm();
                            this.Hide();
                            loginform.Show();
                        }
                        else
                        {
                            MessageBox.Show("Error");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Confirm Password wrong!");
                }
            }
            else
            {
                MessageBox.Show("Form can't be blank!");
            }



            db.closeConnection();
        }
Exemplo n.º 7
0
        public Form3()
        {
            InitializeComponent();
            String    userid = ClientSession.iduser;
            DB        db     = new DB();
            DataTable table  = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Letters where id_Recipient=@UID AND isSigned = @isSigned AND IsinTrash = @isInTrash  AND IsInDrafts = @isInDrafts", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.VarChar).Value    = userid;
            command.Parameters.Add("@isSigned", SqlDbType.Bit).Value   = 0;
            command.Parameters.Add("@isInTrash", SqlDbType.Bit).Value  = 1;
            command.Parameters.Add("@isInDrafts", SqlDbType.Bit).Value = 0;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            int Rowscount = table.Rows.Count;

            tableLayoutPanel1.RowCount = Rowscount;

            if (Rowscount != 0)
            {
                for (int i = 0; i < Rowscount; i++)
                {
                    string theme           = table.Rows[i][8].ToString();
                    string themenospaces   = theme.Replace(" ", "");
                    string comment         = table.Rows[i][9].ToString();
                    string commentnospaces = comment.Replace(" ", "");
                    string id_Sender       = table.Rows[i][1].ToString();
                    string id_status       = table.Rows[i][10].ToString();
                    string statusSigned    = table.Rows[i][7].ToString();
                    string id       = table.Rows[i][0].ToString();
                    string SendDate = table.Rows[i][3].ToString();
                    string SendTime = table.Rows[i][4].ToString();



                    SqlCommand newcommand = new SqlCommand("Select * from Workers where id = @UIDU", db.GetConnection());
                    newcommand.Parameters.Add("@UIDU", SqlDbType.VarChar).Value = id_Sender;
                    DataTable table2 = new DataTable();
                    adapter.SelectCommand = newcommand;
                    adapter.Fill(table2);

                    string ShortUserName = table2.Rows[0][2].ToString();

                    tableLayoutPanel1.Controls.Add(new Label {
                        Text = themenospaces + "\r\n" + ShortUserName + "\r\n" + commentnospaces + "\r\n" + SendDate + " " + SendTime, Name = "LinkClick" + id, Tag = i, Size = new Size(353, 78), BorderStyle = BorderStyle.FixedSingle
                    });
                    tableLayoutPanel1.Controls.Add(new Button {
                        Name = "buttonclick" + id, BackgroundImage = WindowsFormsApp1.Properties.Resources.z00SzkeG89Q, Size = new Size(16, 20)
                    });
                    (tableLayoutPanel1.Controls["LinkClick" + id] as Label).Click    += OpenMy;
                    (tableLayoutPanel1.Controls["buttonclick" + id] as Button).Click += DeleteMy;

                    if (statusSigned == "2")
                    {
                        bool Signed = true;
                        tableLayoutPanel1.Controls.Add(new CheckBox {
                            Checked = Signed
                        });
                    }
                    else
                    {
                        bool Signed = false;
                        tableLayoutPanel1.Controls.Add(new CheckBox {
                            Checked = Signed
                        });
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DB     db       = new DB();
            String username = textboxUsername.Text;
            String password = textboxPassword.Text;
            var    account  = new member(username, password);

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `users` WHERE `username` = @usn and `password` = @pass", db.GetConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;
            adapter.SelectCommand = command;
            adapter.Fill(table);

            //Mengecek bahwa user ada dalam database atau tidak.
            if (table.Rows.Count > 0)
            {
                MessageBox.Show(string.Format("Hello, {0}", username));
                Usermenu usermenu = new Usermenu();
                this.Hide();
                usermenu.Show();
            }
            else
            {
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Username.");
                }
                else if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Password.");
                }
                else
                {
                    MessageBox.Show("Wrong username or password.");
                }
            }
        }
Exemplo n.º 9
0
        public Boolean isUserExist()
        {
            DB db = new DB();

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `Login` = @uL", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginField.Text;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                MessageBox.Show("This profile is exist");
                return(true);
            }

            else
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            if (nameField.Text == "")
            {
                MessageBox.Show("Name is empty");
                return;
            }

            if (surnameField.Text == "")
            {
                MessageBox.Show("Surname is empty");
                return;
            }

            if (loginField.Text == "")
            {
                MessageBox.Show("Login is empty");
                return;
            }

            if (passField.Text == "")
            {
                MessageBox.Show("Password is empty");
                return;
            }

            if (isUserExist())
            {
                return;
            }



            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("INSERT INTO `users` (`Login`, `Password`, `Name`, `Surname`) VALUES (@login, @password, @Name, @Surname)", db.GetConnection());

            command.Parameters.Add("@login", MySqlDbType.VarChar).Value    = loginField.Text;
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value = passField.Text;
            command.Parameters.Add("@Name", MySqlDbType.VarChar).Value     = nameField.Text;
            command.Parameters.Add("@Surname", MySqlDbType.VarChar).Value  = surnameField.Text;

            db.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Account was successfully added");
            }
            else
            {
                MessageBox.Show("Account was not added");
            }

            db.closeConnection();
        }
Exemplo n.º 11
0
        private void button3_Click(object sender, EventArgs e)
        {
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter  = new SqlDataAdapter();
            SqlCommand     command1 = new SqlCommand("Update Letters SET IsWritten = @IsWritten WHERE id=@UID", db.GetConnection());

            command1.Parameters.Add("@UID", SqlDbType.VarChar).Value   = ClientSession.idletter;
            command1.Parameters.Add("@IsWritten", SqlDbType.Bit).Value = true;

            Sign sign = new Sign();

            sign.Show();
            Hide();
        }
Exemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            String letterid = ClientSession.letter;

            ClientSession.idletter = letterid.Replace("LinkClick", "");
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Letters where id = @UID", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.VarChar).Value = ClientSession.idletter;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            string theme           = table.Rows[0][8].ToString();
            string themenospaces   = theme.Replace(" ", "");
            string comment         = table.Rows[0][9].ToString();
            string commentnospaces = comment.Replace(" ", "");
            string SendDate        = table.Rows[0][3].ToString();
            string SendTime        = table.Rows[0][4].ToString();
            string documentid      = table.Rows[0][6].ToString();

            ClientSession.documentid = documentid;

            label1.Text = themenospaces;
            label2.Text = commentnospaces;
            label3.Text = SendDate;
            label4.Text = SendTime;
        }
Exemplo n.º 13
0
        private void Form10_Load(object sender, EventArgs e)
        {
            String    Login = ClientSession.UserName;
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Workers where Login = @UL", db.GetConnection());

            command.Parameters.Add("@UL", SqlDbType.VarChar).Value = Login;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            lastNameTextBox.Text   = table.Rows[0][1].ToString();
            firstNameTextBox.Text  = table.Rows[0][2].ToString();
            middleNameTextBox.Text = table.Rows[0][3].ToString();
            departmentTextBox.Text = table.Rows[0][4].ToString();
            positionTextBox.Text   = table.Rows[0][5].ToString();
            loginTextBox.Text      = table.Rows[0][6].ToString();
            passwordTextBox.Text   = table.Rows[0][7].ToString();
        }
Exemplo n.º 14
0
        public Boolean checkUsername()
        {
            DB        db       = new DB();
            String    username = textboxUsername.Text;
            DataTable table    = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `users` WHERE `username` = @usn ", db.GetConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = username;
            adapter.SelectCommand = command;
            adapter.Fill(table);

            //Mengecek bahwa user sudah ada dalam database atau belum
            if (table.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        //Регистрация
        private void register_button_Click(object sender, EventArgs e)
        {
            if (userNameField.Text == "Введите имя")
            {
                return;
            }

            if (userSurnameField.Text == "Введите фамилию")
            {
                return;
            }

            if (isUserExists())
            {
                return;
            }

            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("INSERT INTO `users` (`login`, `password`, `name`, `surname`) VALUES (@login, @pass, @name, @surname)", db.GetConnection());

            command.Parameters.Add("@login", MySqlDbType.VarChar).Value   = login_box.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value    = password_box.Text;
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value    = userNameField.Text;
            command.Parameters.Add("@surname", MySqlDbType.VarChar).Value = userSurnameField.Text;

            db.OpenConnection();  //Открытие базы данных

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Аккаунт создан");
            }
            else
            {
                MessageBox.Show("Аккаунт не создан");
            }

            db.CloseConnection(); //Закрытие базы данных
        }
Exemplo n.º 16
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            string loginUser = LoginField.Text;
            string passUser  = PassField.Text;

            DB               db      = new DB();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            //команда, которая должна выполниться
            //параметр - команда sql, метод функции (для открытия)
            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `password` = @uP", db.GetConnection()); // заглушки @ для безопасности

            //меняем в команде заглушки на нужные значения
            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command; // позволяет выбрать данные из БД
            adapter.Fill(table);             // заполняем объект table данными по запросу command

            if (table.Rows.Count > 0)        // елси количество рядов (записей) > 0 (если хоть что-то в таблице есть)
            {
                MessageBox.Show("Пользователь авторизован");
            }
            else
            {
                MessageBox.Show("Пользователь не авторизован");
            }
        }
Exemplo n.º 17
0
        private void button12_Click(object sender, EventArgs e)
        {
            tableLayoutPanel1.Controls.Clear();
            String    userid = ClientSession.iduser;
            DB        db     = new DB();
            DataTable table  = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Letters where id_Recipient=@UID AND isSigned = @isSigned AND IsinTrash = @isInTrash  AND IsInDrafts = @isInDrafts AND Theme LIKE @USearch", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.VarChar).Value     = userid;
            command.Parameters.Add("@isSigned", SqlDbType.Bit).Value    = 0;
            command.Parameters.Add("@isInTrash", SqlDbType.Bit).Value   = 0;
            command.Parameters.Add("@isInDrafts", SqlDbType.Bit).Value  = 0;
            command.Parameters.Add("@USearch", SqlDbType.VarChar).Value = textBox1.Text + "%";
            adapter.SelectCommand = command;
            adapter.Fill(table);
            int Rowscount = table.Rows.Count;

            tableLayoutPanel1.RowCount = Rowscount;

            if (Rowscount != 0)
            {
                for (int i = 0; i < Rowscount; i++)
                {
                    string theme           = table.Rows[i][8].ToString();
                    string themenospaces   = theme.Replace(" ", "");
                    string comment         = table.Rows[i][9].ToString();
                    string commentnospaces = comment.Replace(" ", "");
                    string id_recipient    = table.Rows[i][2].ToString();
                    string id_status       = table.Rows[i][10].ToString();
                    string statusSigned    = table.Rows[i][7].ToString();
                    string id = table.Rows[i][0].ToString();
                    if (id_status == "True")
                    {
                        bool Written = true;
                        tableLayoutPanel1.Controls.Add(new RadioButton {
                            Checked = Written
                        });
                    }
                    else
                    {
                        bool Written = false;
                        tableLayoutPanel1.Controls.Add(new RadioButton {
                            Checked = Written
                        });
                    }


                    SqlCommand newcommand = new SqlCommand("Select * from Workers where id = @UIDU", db.GetConnection());
                    newcommand.Parameters.Add("@UIDU", SqlDbType.VarChar).Value = id_recipient;
                    DataTable table2 = new DataTable();
                    adapter.SelectCommand = newcommand;
                    adapter.Fill(table2);
                    string ShortUserName = table2.Rows[0][2].ToString();

                    tableLayoutPanel1.Controls.Add(new Label {
                        Text = themenospaces + "\r\n" + "\r\n" + ShortUserName + "\r\n" + commentnospaces, Name = "LinkClick" + id, Tag = i, Size = new Size(353, 78), BorderStyle = BorderStyle.FixedSingle
                    });
                    tableLayoutPanel1.Controls.Add(new Button {
                        Name = "buttonclick" + id, BackgroundImage = WindowsFormsApp1.Properties.Resources.z00SzkeG89Q, Size = new Size(16, 20)
                    });
                    (tableLayoutPanel1.Controls["LinkClick" + id] as Label).Click    += OpenMy;
                    (tableLayoutPanel1.Controls["buttonclick" + id] as Button).Click += DeleteMy;
                    TableLayoutRowStyleCollection styles =
                        this.tableLayoutPanel1.RowStyles;



                    if (statusSigned == "2")
                    {
                        bool Signed = true;
                        tableLayoutPanel1.Controls.Add(new CheckBox {
                            Checked = Signed
                        });
                    }
                    else
                    {
                        bool Signed = false;
                        tableLayoutPanel1.Controls.Add(new CheckBox {
                            Checked = Signed
                        });
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            String Email = textBox1.Text;
           
            DB db = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand("Select * from Workers where Email = @UEmail", db.GetConnection());
            command.Parameters.Add("@UEmail", SqlDbType.VarChar).Value = Email;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            string UserEmail = table.Rows[0][11].ToString();
            string pass = table.Rows[0][7].ToString();

            // отправитель - устанавливаем адрес и отображаемое в письме имя
            MailAddress from = new MailAddress("*****@*****.**", "Tom");
            // кому отправляем
            MailAddress to = new MailAddress(UserEmail);
            // создаем объект сообщения
            MailMessage m = new MailMessage(from, to);
            // тема письма
            m.Subject = "Тест";
            // текст письма
            m.Body = "Ваш пароль:" + pass;
            // письмо представляет код html
            m.IsBodyHtml = true;
            // адрес smtp-сервера и порт, с которого будем отправлять письмо
            SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
            
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.UseDefaultCredentials = true;
            
            // логин и пароль
            smtp.Credentials = new NetworkCredential("*****@*****.**", "Feyanebey666");
            smtp.EnableSsl = true;
            smtp.Send(m);
            MessageBox.Show("Вам отправлено письмо с паролем");
            Hide();

        }
Exemplo n.º 19
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            String loginUser = loginField.Text;
            String passUser  = passField.Text;

            DB db = new DB();

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `pass` = @uP", db.GetConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                MessageBox.Show("Great");
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Exemplo n.º 20
0
        public Sign()
        {
            InitializeComponent();

            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select * from Documents where id = @UID", db.GetConnection());

            command.Parameters.Add("@UID", SqlDbType.VarChar).Value = ClientSession.idletter;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            documentid = table.Rows[0][0].ToString();
            string Name         = table.Rows[0][1].ToString();
            string CreationDate = table.Rows[0][3].ToString();
            string CreationTime = table.Rows[0][4].ToString();
            string Link         = table.Rows[0][5].ToString();

            label1.Text = Name;
            label8.Text = CreationDate;
            string fileText = System.IO.File.ReadAllText("C:/Users/Viral/OneDrive/Рабочий стол/Тестовая папка для писем/document" + documentid + ".txt");

            richTextBox2.Text = fileText;
        }
Exemplo n.º 21
0
        private void DeleteMy(object sender, EventArgs e)
        {
            Button btn = sender as Button;
            string s   = btn.Name;

            ClientSession.letter = s;
            String letterid = ClientSession.letter;

            ClientSession.idletter = letterid.Replace("buttonclick", "");
            textBox1.Text          = ClientSession.idletter;
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Update Letters SET IsInTrash = @IsinTrash  WHERE id=@UID", db.GetConnection());

            command.Parameters.Add("@IsinTrash", SqlDbType.VarChar).Value = 1;
            command.Parameters.Add("@UID", SqlDbType.VarChar).Value       = ClientSession.idletter;
            adapter.SelectCommand = command;
            adapter.Fill(table);
        }
Exemplo n.º 22
0
        private void button2_Click(object sender, EventArgs e)
        {
            DB        db    = new DB();
            DataTable table = new DataTable();

            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Update Documents SET Signs = @IsSigned  WHERE id=@UID", db.GetConnection());

            command.Parameters.Add("@IsSigned", SqlDbType.VarChar).Value = ClientSession.iduser;
            command.Parameters.Add("@UID", SqlDbType.VarChar).Value      = ClientSession.idletter;


            adapter.SelectCommand = command;
            adapter.Fill(table);

            DataTable table1 = new DataTable();

            if (Comment == "")
            {
                DeclineReason = "Подписано";
            }
            else
            {
                DeclineReason = Comment;
            }
            SqlCommand command1 = new SqlCommand("Update Letters SET IsSigned = @IsSigned, id_status = @Status WHERE id=@UID", db.GetConnection());

            command1.Parameters.Add("@UID", SqlDbType.VarChar).Value = ClientSession.idletter;
            //command1.Parameters.Add("@DeclineReason", SqlDbType.VarChar).Value = DeclineReason;
            command1.Parameters.Add("@IsSigned", SqlDbType.Bit).Value = true;
            command1.Parameters.Add("@Status", SqlDbType.Int).Value   = 2;


            adapter.SelectCommand = command1;
            adapter.Fill(table1);
            Form1 form1 = new Form1();

            form1.Show();
            Hide();
        }
Exemplo n.º 23
0
        public Form5()
        {
            InitializeComponent();
            DB             db      = new DB();
            DataTable      table   = new DataTable();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand     command = new SqlCommand("Select id,FirstName,LastName from Workers", db.GetConnection());

            adapter.SelectCommand = command;
            adapter.Fill(table);
            int Rowscount = table.Rows.Count;

            if (Rowscount != 0)
            {
                for (int i = 0; i < Rowscount; i++)
                {
                    string id        = table.Rows[i][0].ToString();
                    string FirstName = table.Rows[i][1].ToString();
                    string LastName  = table.Rows[i][2].ToString();
                    string Text      = FirstName + " " + LastName;
                    comboBox1.Items.Add(Text);
                }
            }
        }
Exemplo n.º 24
0
        //Кнопка входа
        private void enter_button_Click(object sender, EventArgs e)
        {
            string loginUser = login_box.Text;
            string passUser  = password_box.Text;

            DB               db      = new DB();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `password` = @uP", db.GetConnection());

            //Присваиваем заглушкам логин и пароль соответсвенно
            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command; //Указываем какую команду будем выполнять
            adapter.Fill(table);             //Заполняем таблицу данными

            if (table.Rows.Count > 0)
            {
                Hide();
                MainForm mainForm = new MainForm();
                mainForm.Show();
            }
            else
            {
                MessageBox.Show("Пользователь не найден");
            }
        }