Esempio n. 1
0
 private void add_bt_Click(object sender, EventArgs e)
 {
     if (t_name.Text != "")
     {
         l_error.Text = "";
         string into = @" BEGIN TRANSACTION; INSERT INTO Service (Service.Name, Service.Price, Service._delete)
                                     VALUES ('" + t_name.Text + "', '" + t_money.Text.Replace(",", ".") + "', 'False') COMMIT TRANSACTION;";
         ToConnection str_add = new ToConnection();
         SqlConnection acc_add = new SqlConnection(str_add.read_conf());
         try
         {
             StreamPro _use = new StreamPro();
             acc_add.Open();
             SqlCommand comm_insert = new SqlCommand(into, acc_add);
             comm_insert.ExecuteNonQuery();
             User_acc();
         }
         catch (SqlException ex)
         {
             MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         finally
         {
             acc_add.Close();
         }
     }
     else l_error.Text = "Не все поля заполнены.";
 }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
            string sim = DatGridUser[0, ind_sql].Value.ToString();
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());
            string s1 = @"BEGIN TRANSACTION; UPDATE Access_user
                                 SET  Access_user._delete='False', Access_user.Date_iz='" + s +
                                      "'WHERE Access_user.id_access ='" + sim + "' COMMIT TRANSACTION;";

            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                comm_insert.ExecuteNonQuery();
                User_acc();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
        }
Esempio n. 3
0
        //функция  вписания в БД таблица Level_bns
        public void str(string _bonus)
        {
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());

            string s = @"BEGIN TRANSACTION; INSERT INTO Level_bns (id_bonus, Name, level_min, level_max)
                         VALUES ('" + _bonus + "','" + t_name.Text + "', '" + t_min.Text + "', '" + t_max.Text + "') COMMIT TRANSACTION;";

            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_insert = new SqlCommand(s, acc_add);
                comm_insert.ExecuteNonQuery();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
            User_acc();
        }
Esempio n. 4
0
        //метод редактирования клиента
        private void _add_stream(string _bonus, string _level, string _bonus3)
        {
            string steam = Ustr._id;
            string s1 = "";
            string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());
            if (_level == "False")
            {
                s1 = @"BEGIN TRANSACTION;
                                 UPDATE Client
                                 SET  _level = 'True',Client.Number_card='" + t_num.Text + "' ,Client.Name='" + t_fio.Text + "' ,Client.Inform='" + r_info.Text + "' ,Client.id_bonus ='" + _bonus3 + "' WHERE Client.id_client ='" + Edit_cl._idser + "' COMMIT TRANSACTION;";

            }
            else if (_level == "True")
            {
                s1 = @" BEGIN TRANSACTION;
                                UPDATE Client
                                 SET  _level='False', Client.Number_card='" + t_num.Text + "' ,Client.Name='" + t_fio.Text + "' ,Client.Inform='" + r_info.Text + "' ,Client.id_bonus ='" + _bonus +
                                            "' WHERE Client.id_client ='" + Edit_cl._idser + "' COMMIT TRANSACTION;";

            }

            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                comm_insert.ExecuteNonQuery();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
                string sim = DatGridUser[0, ind_sql].Value.ToString();
                ToConnection str_add = new ToConnection();
                SqlConnection acc_add = new SqlConnection(str_add.read_conf());
                string s1 = @" BEGIN TRANSACTION; UPDATE Service
                                 SET  Service._delete='True'
                                      WHERE Service.id_service ='" + sim + "' COMMIT TRANSACTION;";

                try
                {
                    StreamPro _use = new StreamPro();
                    acc_add.Open();
                    SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                    comm_insert.ExecuteNonQuery();
                    User_acc();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_add.Close();
                }
            }
            catch
            {
                l_error.Text = "Не выбрана услуга.";
            }
        }
Esempio n. 6
0
        private void edit_bt_Click(object sender, EventArgs e)
        {
            if (t_name.Text != "")
            {
                int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
                string sim = DatGridUser[0, ind_sql].Value.ToString();
                ToConnection str_add = new ToConnection();
                SqlConnection acc_add = new SqlConnection(str_add.read_conf());
                string s1 = @" BEGIN TRANSACTION; UPDATE Service
                                 SET  Service.Name='" + t_name.Text + "' ,Service.Price='" + t_money.Text.Replace(",", ".") +
                                                          "'WHERE Service.id_service ='" + sim + "' COMMIT TRANSACTION;";

                try
                {
                    StreamPro _use = new StreamPro();
                    acc_add.Open();
                    SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                    comm_insert.ExecuteNonQuery();
                    User_acc();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_add.Close();
                }
            }
            else l_error.Text = "Не все поля заполнены.";
        }
Esempio n. 7
0
        private void edit_bt_Click(object sender, EventArgs e)
        {
            if ((t_Name.Text != "") & (textBox2.Text != ""))
            {
                int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
                string sim = DatGridUser[0, ind_sql].Value.ToString();
                ToConnection str_add = new ToConnection();
                SqlConnection acc_add = new SqlConnection(str_add.read_conf());
                string s1 = @"BEGIN TRANSACTION; UPDATE Bonus
                                 SET  Bonus.Name='" + t_Name.Text + "' ,Bonus.bonus='" + textBox2.Text +
                                                          "'WHERE Bonus.id_bonus ='" + sim + "' COMMIT TRANSACTION;";

                try
                {
                    StreamPro _use = new StreamPro();
                    acc_add.Open();
                    SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                    comm_insert.ExecuteNonQuery();
                    User_acc();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_add.Close();
                }
            }
            else l_error.Text = "Заполните все поля справочника услуги.";
        }
Esempio n. 8
0
        private void b_ConnetTo_BD_Click(object sender, EventArgs e)
        {
            ToConnection str=new ToConnection();
            string _user = b_login.Text;
            int s = 0;
            string _use = "";
            string _name="";
            string ac_commandText = @"select *
                                      from Access_User
                                      where LTRIM(RTRIM(Access_User.Login)) collate Cyrillic_General_CS_AS like '" + b_login .Text +
                                    "'and LTRIM(RTRIM(Access_User.Pass)) collate Cyrillic_General_CS_AS like '" + b_pass.Text + "'";

            SqlConnection connection = new SqlConnection(str.read_conf());
            try
            {
                connection.Open();
                string steamkread="";
                SqlCommand accessUser = new SqlCommand(ac_commandText, connection);
                SqlDataReader read_sql = accessUser.ExecuteReader();
                int count = 0;
                /*Цикл с условием: Пока читаю строки - счетчик +1(если счетчик 1 значит есть такая запись+открытие формы)
                 * иначе необходимо проверить логин и пароль
                 * */
                while (read_sql.Read())
                {
                    _use = read_sql["id_access"].ToString();
                    s = Convert.ToInt16(read_sql["id_role"].ToString());
                    _name = read_sql["NameInfoUser"].ToString();;
                    count += 1;
                    Ustr._id = _use;
                    Ustr._user = _name;
                    steamkread = read_sql["_delete"].ToString();

                }
                if (steamkread != "True")
                {
                    if (count == 1)
                    {
                        if (s == 1)
                        {
                            StreamPro connect_SreamPro = new StreamPro();
                            connect_SreamPro.Text = "Касса";
                            connect_SreamPro._load();
                            connect_SreamPro.ShowDialog();

                        }
                        if (s == 2)
                        {
                            StreamPro connect_SreamPro = new StreamPro();
                            connect_SreamPro.Text = "Бухгалтерия";
                            connect_SreamPro._load();
                            connect_SreamPro.ShowDialog();

                        }
                        if (s == 3)
                        {
                            Adm_User connect_SreamPro = new Adm_User();
                            connect_SreamPro.ShowDialog();

                        }
                    }
                    else if (count == 0)
                    {
                        MessageBox.Show("Вы неправильно ввели логин или пароль", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    }
                }

                else MessageBox.Show("Данный пользователь удален администратором", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
                catch(Exception ex)
            {

                MessageBox.Show(ex.Message.ToString());

            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 9
0
        //запись данных в БД
        private void _add_stream(string _bonus, string _level, string _bonus3)
        {
            string s="";
            string steam = Ustr._id;
            string s1 = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());
            if (_level == "False")
            {
                s = @"BEGIN TRANSACTION;
                        INSERT INTO Client (id_access, id_bonus, Number_card, Name, Inform, Date_reg, _delete, Block, Sum_Expenses, Sum_Flow, _level)
                         VALUES ('" + steam + "', '" + _bonus3 + "','" + t_number.Text + "', '" + t_FIO.Text + "', '" + r_info.Text + "','" + s1 + "','False','False','0','0', 'True') COMMIT TRANSACTION;";

            }
            else if (_level == "True")
            {
                s = @"BEGIN TRANSACTION;
                        INSERT INTO Client (id_access, id_bonus, Number_card, Name, Inform, Date_reg, _delete, Block, Sum_Expenses, Sum_Flow, _level)
                         VALUES ('" + steam + "','" + _bonus + "', '" + t_number.Text + "', '" + t_FIO.Text + "', '" + r_info.Text + "','" + s1 + "','False','False','0','0', 'False') COMMIT TRANSACTION;";

            }

            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_insert = new SqlCommand(s, acc_add);
                comm_insert.ExecuteNonQuery();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
        }
Esempio n. 10
0
        private void _add_stream()
        {
            double dim = (Convert.ToDouble(tex_money.Text)*Convert.ToDouble(Ustr._sim))*0.01;
            string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());

            string s2 = @"BEGIN TRANSACTION;
                         INSERT INTO Flow (id_access, id_currency, id_client, Date, Sum, Sum_bonus)
                         VALUES ('" + Ustr._id + "','" + id_currency + "', '" + Ustr._id_clients + "', '" + s + "', '" + tex_money.Text.Replace(",", ".") + "', '" + Convert.ToString(dim).Replace(",", ".") + "'); COMMIT TRANSACTION;";
            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_insert = new SqlCommand(s2, acc_add);
                comm_insert.ExecuteNonQuery();
                t_time_m = s;
                sum_bns_m = Convert.ToString(dim);

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
        }
Esempio n. 11
0
        private void _add_money()
        {
            double sum = Convert.ToDouble(tex_money.Text) +((Convert.ToDouble(tex_money.Text)*Convert.ToDouble(Ustr._sim))*0.01);
            ToConnection str_add = new ToConnection();
            SqlConnection acc_add = new SqlConnection(str_add.read_conf());
            string s1 = @"BEGIN TRANSACTION;
                        UPDATE Client
                        SET Sum_Flow +='" + Convert.ToString(sum).Replace(",",".") +
                        "' WHERE Client.Number_card = '" + t_moneys.Text + "'; COMMIT TRANSACTION;";
            try
            {
                StreamPro _use = new StreamPro();
                acc_add.Open();
                SqlCommand comm_update = new SqlCommand(s1, acc_add);
                comm_update.ExecuteNonQuery();
                sum_m = Convert.ToString(sum);

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_add.Close();
            }
        }
Esempio n. 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
                string sim = DatGridUser[0, ind_sql].Value.ToString();
                ToConnection str_add = new ToConnection();
                SqlConnection acc_add = new SqlConnection(str_add.read_conf());
                string s1 = @"BEGIN TRANSACTION;
                            UPDATE Currency
                                 SET  Currency._delete='False'
                                      WHERE Currency.id_currency ='" + sim + "' COMMIT TRANSACTION;";

                try
                {
                    StreamPro _use = new StreamPro();
                    acc_add.Open();
                    SqlCommand comm_insert = new SqlCommand(s1, acc_add);
                    comm_insert.ExecuteNonQuery();
                    User_acc();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_add.Close();
                }
            }

            catch
            {
                 MessageBox.Show("Не выбран вид валюты.", "Внимание!", MessageBoxButtons.OK,MessageBoxIcon.Information);

            }
        }