Exemplo n.º 1
0
        public DataTableSQl(string sql)
        {
            this.sql = sql;
            ConnectionClass ConCheck                      = new ConnectionClass();
            RegistryKey     DataBase_Connection           = Registry.CurrentConfig;
            RegistryKey     Connection_Base_Party_Options = DataBase_Connection.CreateSubKey("DB_PARTY_OPTIOS");

            ConCheck.Connection_Options();
            connection = new SqlConnection(ConCheck.ConnectString);
            SqlCommand     command = new SqlCommand(sql, connection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);

            connection.Open();
            adapter.Fill(Table);
            adapter.Update(Table);
            if (connection != null)
            {
                connection.Close();
            }
        }
Exemplo n.º 2
0
 private void button3_Click_1(object sender, EventArgs e)
 {
     if (dataGridZakk.SelectedCells.Count == 0)
     {
         return;
     }
     {
         string          id       = dataGridZakk.CurrentRow.Cells[0].Value.ToString();
         ConnectionClass ConCheck = new ConnectionClass();
         ConCheck.Connection_Options();
         SqlConnection connection = new SqlConnection(ConCheck.ConnectString);
         connection.Open();
         SqlCommand command = new SqlCommand("dbo.upd_Zakaz_tovara", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@Statysa_ID", comboBoxizm.SelectedValue.ToString());
         command.Parameters.AddWithValue("@ID_Zakaza", id);
         command.ExecuteNonQuery();
         connection.Close();
         UpdateStatus();
     }
 }
Exemplo n.º 3
0
        private void button6_Click(object sender, EventArgs e)
        {
            int    count = 0;
            string IDzak = dataGridView5.CurrentRow.Cells[0].Value.ToString();

            for (int j = 0; j < dataGridView3.RowCount; j++)
            {
                for (int i = 0; i < dataGridView3.ColumnCount; i++)
                {
                    if (dataGridView3[i, j].Value != null)
                    {
                        count++;
                        Gl.post = dataGridView3[5, j].Value.ToString();
                        Gl.summ = dataGridView3[1, j].Value.ToString();
                        Gl.ID   = dataGridView3[0, j].Value.ToString();
                        Tovar(dataGridView3[3, j].Value.ToString());
                        Registraciya re = new Registraciya();
                        re.textBoxName.Text = namr;
                        re.ShowDialog();
                        break;
                    }
                }
            }
            DialogResult resolt = MessageBox.Show("Изменить статус?", "Сообщение", MessageBoxButtons.YesNo);

            if (resolt == DialogResult.No)
            {
                return;
            }
            {
                ConnectionClass ConCheck = new ConnectionClass();
                ConCheck.Connection_Options();
                SqlConnection connection = new SqlConnection(ConCheck.ConnectString);
                connection.Open();
                SqlCommand command2 = new SqlCommand("UPDATE Zakaz_tovara SET Statysa_ID = '3' WHERE ID_Zakaza ='" + IDzak + "'", connection);
                command2.ExecuteNonQuery();
                connection.Close();
                Upda();
            }
        }
Exemplo n.º 4
0
        private void button18_Click(object sender, EventArgs e)
        {
            DialogResult resolt = MessageBox.Show("Удалить все?", "Сообщение", MessageBoxButtons.YesNo);

            if (resolt == DialogResult.No)
            {
                return;
            }
            {
                switch (dataGridView4.Rows[0].Cells[0].Value == null)
                {
                case (false):
                    ConnectionClass ConCheck = new ConnectionClass();
                    ConCheck.Connection_Options();
                    SqlConnection connection = new SqlConnection(ConCheck.ConnectString);
                    connection.Open();
                    int count = 0;
                    for (int j = 0; j < dataGridView4.RowCount; j++)
                    {
                        for (int i = 0; i < dataGridView4.ColumnCount; i++)
                        {
                            if (dataGridView4[i, j].Value != null)
                            {
                                count++;
                                string     tovrid  = dataGridView4[0, j].Value.ToString();
                                SqlCommand command = new SqlCommand("dbo.dell_Usloviya_zakaza", connection);
                                command.CommandType = CommandType.StoredProcedure;
                                command.Parameters.AddWithValue("@ID_Usloviya", tovrid);
                                command.ExecuteNonQuery();
                                break;
                            }
                        }
                    }
                    connection.Close();
                    zak();
                    break;
                }
            }
        }
Exemplo n.º 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ConnectionClass ConCheck = new ConnectionClass();

            RegistryKey DataBase_Connection           = Registry.CurrentConfig;
            RegistryKey Connection_Base_Party_Options = DataBase_Connection.CreateSubKey("DB_PARTY_OPTIOS");

            ConCheck.Connection_Options();
            SqlConnection connectionCheck = new SqlConnection(ConCheck.ConnectString);

            try
            {
                connectionCheck.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            switch (connectionCheck.State == ConnectionState.Open)
            {
            case (true):
                label1.Text = " - Подключение к источнику данных есть.";
                //button2.Enabled = false;
                //button1.Enabled = true;
                //button3.Enabled = true;
                break;

            case (false):
                label1.Text     = " - Отсутствует подключение к источнику данных!";
                button2.Enabled = true;
                button1.Enabled = false;
                button3.Enabled = false;

                break;
            }
        }
Exemplo n.º 6
0
        private void button14_Click(object sender, EventArgs e)
        {
            DialogResult resolt = MessageBox.Show("Добавить поставщика?", "Сообщение", MessageBoxButtons.YesNo);

            if (resolt == DialogResult.No)
            {
                return;
            }
            {
                switch (textBoxadres.Text == "" || textBoxname.Text == "" || textBoxpoch.Text == "" || maskedTextBoxtel.Text == "")

                {
                case (false):

                    ConnectionClass ConCheck = new ConnectionClass();
                    ConCheck.Connection_Options();
                    SqlConnection connection = new SqlConnection(ConCheck.ConnectString);
                    connection.Open();
                    SqlCommand command = new SqlCommand("dbo.add_Postavhik", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Nazvanie_organizacii", textBoxname.Text);
                    command.Parameters.AddWithValue("@Adres", textBoxadres.Text);
                    command.Parameters.AddWithValue("@Telefon", maskedTextBoxtel.Text);
                    command.Parameters.AddWithValue("@Kategoriya_ID", comboBoxkategr.SelectedValue.ToString());
                    command.Parameters.AddWithValue("@Pochta", textBoxpoch.Text);
                    command.ExecuteNonQuery();
                    connection.Close();
                    UpdateStatus();
                    break;

                case (true):
                    MessageBox.Show("Заполните все пустые поля");
                    break;
                }
            }
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            ConnectionClass ConCheck = new ConnectionClass();

            ConCheck.Connection_Options();
            SqlConnection connection = new SqlConnection(ConCheck.ConnectString);

            connection.Open();
            switch (Gl.tbizm)
            {
            case 1:
                texbox(IDzak, Gl.ID);

                break;

            case 2:


                int count = 0;
                for (int j = 0; j < dataGridViewpost.RowCount; j++)
                {
                    for (int i = 0; i < dataGridViewpost.ColumnCount; i++)
                    {
                        if (dataGridViewpost[i, j].Value != null)
                        {
                            count++;
                            string     name     = dataGridViewpost[0, j].Value.ToString();
                            string     firm     = dataGridViewpost[1, j].Value.ToString();
                            string     cena     = dataGridViewpost[2, j].Value.ToString();
                            string     jiv      = dataGridViewpost[3, j].Value.ToString();
                            string     kateg    = dataGridViewpost[4, j].Value.ToString();
                            SqlCommand command1 = new SqlCommand("dbo.add_Tovar", connection);
                            command1.CommandType = CommandType.StoredProcedure;
                            command1.Parameters.AddWithValue("@Cena", cena);
                            command1.Parameters.AddWithValue("@Naimenovanie", name);
                            command1.Parameters.AddWithValue("@Vid_ID", kateg);
                            command1.Parameters.AddWithValue("@Postavhik_ID", Gl.ID);
                            command1.Parameters.AddWithValue("@Jivotnoe_ID", jiv);
                            command1.Parameters.AddWithValue("@Firma", firm);
                            command1.ExecuteNonQuery();
                            this.Close();
                            break;
                        }
                    }
                }
                break;

            case 3:

                SqlCommand command = new SqlCommand("dbo.upd_Tovar", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Cena", textcena.Text);
                command.Parameters.AddWithValue("@Naimenovanie", textBoxname.Text);
                command.Parameters.AddWithValue("@Vid_ID", comboBoxkategr.SelectedValue.ToString());
                command.Parameters.AddWithValue("@Jivotnoe_ID", comboBoxjiv.SelectedValue.ToString());
                command.Parameters.AddWithValue("@Firma", textBoxfirm.Text);
                command.Parameters.AddWithValue("@ID_Tovara", Gl.ID);
                command.ExecuteNonQuery();
                connection.Close();
                this.Close();
                break;

            default:

                break;
            }
            connection.Close();
        }
Exemplo n.º 8
0
        public void Button_Click(object sender, EventArgs e)
        {
            ConnectionClass ConCheck = new ConnectionClass();

            ConCheck.Connection_Options();
            SqlConnection connectionUser = new SqlConnection(ConCheck.ConnectString);
            SqlCommand    Select_USID    = new SqlCommand("select concat(Imya,' ',Fam,' ',Oth)  from Sotrudnik where Parol='" + New_Password_Text.Text + "' and [Login]='" + New_Login_Text.Text + "'", connectionUser);
            SqlCommand    Select_ISA     = new SqlCommand("select Otdel  from Sotrudnik where Parol='" + New_Password_Text.Text + "' and [Login]='" + New_Login_Text.Text + "'", connectionUser);

            try
            {
                connectionUser.Open();
                string USID = Select_USID.ExecuteScalar().ToString();
                string ISA  = Select_ISA.ExecuteScalar().ToString();


                MessageBox.Show("Здравствуйте: " + USID);
                switch (ISA)
                {
                case "Отдел закупок":
                    Zakupka zakupka = new Zakupka();
                    Gl.sotr = USID;
                    zakupka.Show();
                    this.Hide();
                    Registration_Window.Close();
                    connectionUser.Close();
                    break;

                case "Складской отдел":
                    Sklad Sklad = new Sklad();
                    Gl.sotr = USID;
                    Sklad.Show();
                    this.Hide();
                    Registration_Window.Close();
                    connectionUser.Close();
                    break;

                case "Отдел продаж":
                    Klient Klient = new Klient();
                    Gl.sotr = USID;
                    Klient.Show();
                    this.Hide();
                    Registration_Window.Close();
                    connectionUser.Close();

                    break;

                case "Админ":
                    Admin Admin = new Admin();
                    Gl.sotr = USID;
                    Admin.Show();
                    this.Hide();
                    Registration_Window.Close();
                    connectionUser.Close();

                    break;
                }
            }
            catch
            {
                MessageBox.Show( );
            }
        }
Exemplo n.º 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            DateTime date1 = new DateTime();

            date1 = DateTime.Now;
            string       obh     = label10.Text;
            string       seichas = date1.ToLongDateString();
            DialogResult resolt  = MessageBox.Show("Создать заказ?", "Сообщение", MessageBoxButtons.YesNo);

            if (resolt == DialogResult.No)
            {
                return;
            }
            {
                switch (dataGridView2.Rows[0].Cells[0].Value == null)

                {
                case (false):
                    ConnectionClass ConCheck = new ConnectionClass();
                    ConCheck.Connection_Options();
                    SqlConnection connection = new SqlConnection(ConCheck.ConnectString);
                    connection.Open();
                    SqlCommand command = new SqlCommand("dbo.add_Zakaz_tovara", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Data_zakaza", seichas);
                    command.Parameters.AddWithValue("@Postavhik_ID", comboBoxpost.SelectedValue.ToString());
                    command.Parameters.AddWithValue("@Statysa_ID", 2);
                    command.Parameters.AddWithValue("@summa", obh);
                    int ii = 0;
                    command.Parameters.AddWithValue("@newif", ii);
                    int iii   = (int)command.ExecuteScalar();
                    int count = 0;
                    for (int j = 0; j < dataGridView2.RowCount; j++)
                    {
                        for (int i = 0; i < dataGridView2.ColumnCount; i++)
                        {
                            if (dataGridView2[i, j].Value != null)
                            {
                                count++;
                                string     tovrid   = dataGridView2[0, j].Value.ToString();
                                string     kolvo    = dataGridView2[2, j].Value.ToString();
                                string     sumt     = dataGridView2[4, j].Value.ToString();
                                SqlCommand command1 = new SqlCommand("dbo.add_Usloviya_zakaza", connection);
                                command1.CommandType = CommandType.StoredProcedure;
                                command1.Parameters.AddWithValue("@Kolvo_tovara", kolvo);
                                command1.Parameters.AddWithValue("@Summa", sumt);
                                command1.Parameters.AddWithValue("@Tovara_ID", tovrid);
                                command1.Parameters.AddWithValue("@Zakaza_ID", iii);
                                command1.ExecuteNonQuery();
                                break;
                            }
                        }
                    }
                    connection.Close();
                    break;

                case (true):
                    MessageBox.Show("Заполните все пустые поля");
                    break;
                }
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            ConnectionClass ConCheck = new ConnectionClass();

            ConCheck.Connection_Options();
            SqlConnection connection = new SqlConnection(ConCheck.ConnectString);

            connection.Open();
            switch (Gl.tbizm)
            {
            case 1:

                SqlCommand command = new SqlCommand("dbo.dell_Usloviya_zakaza", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@ID_Usloviya", Gl.ID);
                command.ExecuteNonQuery();
                this.Close();
                break;

            case 2:
                try
                {
                    SqlCommand command2 = new SqlCommand("dbo.dell_Zakaz_tovara", connection);
                    command2.CommandType = CommandType.StoredProcedure;
                    command2.Parameters.AddWithValue("@ID_Zakaza", Gl.ID);
                    command2.ExecuteNonQuery();
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("Заказ не может быть удален. Удалите сначала все товары");
                    this.Close();
                }

                break;

            case 3:
                try
                {
                    SqlCommand command3 = new SqlCommand("dbo.dell_Postavhik", connection);
                    command3.CommandType = CommandType.StoredProcedure;
                    command3.Parameters.AddWithValue("@ID_Postavhik", Gl.ID);
                    command3.ExecuteNonQuery();
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("У этого поставщика есть товары, удалите их");
                }
                break;

            case 4:

                SqlCommand command4 = new SqlCommand("dbo.dell_Tovar", connection);
                command4.CommandType = CommandType.StoredProcedure;
                command4.Parameters.AddWithValue("@ID_Tovara", Gl.ID);
                command4.ExecuteNonQuery();
                this.Close();

                break;

            default:
                connection.Close();
                break;
            }
            connection.Close();
        }