Example #1
0
        private void Look_document_Load(object sender, EventArgs e)
        {
            try
            {
                Document_look.LoadFile(document);
                class_for_id_user buffer_doc = new class_for_id_user();
                buffer_doc.set_doc(Document_look.Text);

                result = Document_look.Text;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
        private void loginbutton_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection cn = getConnection())
                {
                    DataTable      table   = new DataTable();
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    SqlCommand     command = new SqlCommand("SELECT * FROM users where user_login = @login AND user_password=@password ", cn);
                    command.Parameters.Add("@login", SqlDbType.VarChar).Value    = login.Text;
                    command.Parameters.Add("@password", SqlDbType.VarChar).Value = password.Text;
                    adapter.SelectCommand = command;
                    adapter.Fill(table);
                    var myData = table.Select();

                    if (table.Rows.Count == 1)
                    {
                        class_for_id_user id = new class_for_id_user();
                        id.set_Id(myData[0].ItemArray[0].ToString());
                        id.set_AR((myData[0].ItemArray[3]).ToString());
                        if (Convert.ToInt32(myData[0].ItemArray[3]) == 2 || Convert.ToInt32(myData[0].ItemArray[3]) == 3)
                        {
                            data DU1 = new data();
                            DU1.Show();
                        }
                        else
                        {
                            datau DU = new datau();
                            DU.Show();
                        }


                        this.Hide();

                        //Показываем форму. В данном конкретном случае все равно как показывать: с помощью метода Show() либо ShowDialog()
                    }
                    else
                    {
                        MessageBox.Show("Повторите заново!");
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
                //MessageBox.Show("Повторите заново!");
            }
        }