示例#1
0
        public void User_acc()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql= @"Select me.id_access, me.Login, me.NameInfoUser, me2.Name_R, me.Date_iz
                                                  From Role me2, Access_User me
                                                   Where me.id_Role=me2.id_Role and me._delete = 'True'";

            try
            {
                acc.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(tab_sql, acc);
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt);
                DatGridUser.DataSource = dt;
                _size();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#2
0
        //Вставка данных в таблицу
        public void User_acc()
        {
            t_filter.SelectedIndex = 0;
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"Select me.id_client, me.Number_card, me.Name, me4.Name, me.Date_reg, me.Block, me.Sum_money, me3.NameInfoUser, me.Inform
                                      From Client me, Access_user me3, Bonus me4
                                      Where me.id_access = me3.id_access and me.id_bonus=me4.id_bonus and me._delete='False'";
            try
            {
                acc.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(tab_sql, acc);
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt);
                DatGridUser.DataSource = dt;
                _size();
                l_count.Text = Convert.ToString(DatGridUser.RowCount);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#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();
        }
示例#4
0
        //Вставка данных в таблицу
        public void User_acc()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"Select me.id_service, me.Name, me.Price
                                      From Service me
                                      Where me._delete='False'";
            try
            {
                acc.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(tab_sql, acc);
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt);
                DatGridUser.DataSource = dt;
                _size();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#5
0
        //метод блокировки клиента
        public void _block(string star_del)
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"BEGIN TRANSACTION; UPDATE Client
                                      SET Client.Block = 'True'
                                      Where Client.id_client='" + star_del + "' COMMIT TRANSACTION;";

            try
            {
                acc.Open();
                SqlCommand s_User = new SqlCommand(tab_sql, acc);
                s_User.ExecuteNonQuery();
                l_count.Text = Convert.ToString(DatGridUser.RowCount);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#6
0
        private void bt_add_sql(string FIO, string login, string password, int role, string _inform)
        {
            string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());
            string s1 = @"BEGIN TRANSACTION;
                            INSERT INTO Access_User (Login, Pass, id_Role, NameInfoUser, Info_dop, Date, Date_iz, _delete)
                         VALUES ('" + login + "', '" + password + "','" + role + "', '" + FIO + "', '" + _inform + "', '" + s + "','" + s + "','False') COMMIT TRANSACTION;";

            try
            {
                acc.Open();

                SqlCommand comm_insert = new SqlCommand(s1, acc);
                comm_insert.ExecuteNonQuery();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#7
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 = "Не все поля заполнены.";
 }
示例#8
0
        //Вставка данных в таблицу
        public void User_acc()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"Select me.id_client, me.Number_card, me.Name, me.Date_reg, me.Sum_money, me3.NameInfoUser, me._inform_delete
                                      From Client me, Access_user me3
                                      Where me.id_access = me3.id_access and me._delete='True'";
            try
            {
                acc.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(tab_sql, acc);
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt);
                DatGridUser.DataSource = dt;
                _size();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#9
0
        private void b_add_Click(object sender, EventArgs e)
        {
            int role = cBox_role.SelectedIndex + 1;
            bool otv1 = false;
            string us_login = txt_login.Text;
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());
            string tab_sql = @"Select me.Login
                                      From Access_User me
                                      Where me.Login='******';";
            int count = 0;

            try
            {
                acc.Open();
                SqlCommand s_User = new SqlCommand(tab_sql, acc);
                SqlDataReader read_sql = s_User.ExecuteReader();

                while (read_sql.Read())
                {
                    count += 1;

                }
                if (count == 1)
                {
                    otv1 = false;
                }
                else if (count == 0)
                {
                    otv1 = true;

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
            if (otv1 == true)
            {

                if ((txt_login.Text != "") & (txt_FIO.Text != "") & (txt_pass.Text != "") & (role != 0))
                {

                    string login = txt_login.Text;
                    string FIO = txt_FIO.Text;
                    string password = txt_pass.Text;
                    string _inform = t_info.Text;
                    bt_add_sql(FIO, login, password, role, _inform);

                }
                else MessageBox.Show("Не все поля заполнены.");

            }
            else MessageBox.Show("Такой пользователь уже сущестует.");
        }
示例#10
0
        //Заполняем имена бонусов в c_bonus автоматически
        public void _select2()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());
            string queryString1 = @"Select me.id_bonus, me.Name
                                    From Bonus me";

            try
            {
                acc.Open();
                SqlCommand cmd1 = new SqlCommand(queryString1, acc);
                SqlDataReader dr = cmd1.ExecuteReader();
                while (dr.Read())
                {
                    c_Bonus.Items.Add(dr["Name"]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();

            }
        }
示例#11
0
        public void _select2()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());
            string queryString1 = @"Select me.Name, me.id_currency
                                    From Currency me
                                    Where me._delete = 'False'";

            try
            {
                acc.Open();
                SqlCommand cmd1 = new SqlCommand(queryString1, acc);
                SqlDataReader dr1 = cmd1.ExecuteReader();
                while (dr1.Read())
                {
                    c_money.Items.Add(dr1["Name"]);
                    c_money.SelectedIndex = 0;
                    id_currency = dr1["id_currency"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();

            }
        }
示例#12
0
        //Вставка данных в таблицу
        public void User_acc()
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"Select me.id_level, me.Name, me2.Name, me.level_min, me.level_max
                                      From Level_bns me, Bonus me2
                                      Where me.id_bonus=me2.id_bonus";
            try
            {
                acc.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(tab_sql, acc);
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt);
                DatGridUser.DataSource = dt;
                _size();

            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#13
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();
            }
        }
示例#14
0
 private void b_save_Click(object sender, EventArgs e)
 {
     string conStr = @"Data Source=" + txtBoxSRV.Text +
                     ";Initial Catalog=" + txtBoxBD.Text +
                     ";Integrated Security=False;User ID=" + t_Login.Text +
                     ";Password="******";Pooling = true;";
     ToConnection ToConnection = new ToConnection();
     ToConnection.add_conf(conStr);
 }
示例#15
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (t_card.Text != "")
     {
         ToConnection st = new ToConnection();
         this.DataTable3TableAdapter.Connection.ConnectionString = st.read_conf();
         this.DataTable3TableAdapter.Fill(this.UsersSSQl.DataTable3, Convert.ToInt32(t_card.Text));
         this.reportViewer1.RefreshReport();
     }
     else MessageBox.Show("Введите номер карты");
 }
示例#16
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (date_1.Value <= date_2.Value)
            {

                DateTime date1 = new DateTime(date_1.Value.Year, date_1.Value.Month, date_1.Value.Day, 00, 00, 00);
                DateTime date2 = new DateTime(date_2.Value.Year, date_2.Value.Month, date_2.Value.Day, 23, 59, 00);
                ToConnection st = new ToConnection();
                this.DataTable7TableAdapter.Connection.ConnectionString = st.read_conf();
                this.DataTable7TableAdapter.Fill(this.UsersSSQl.DataTable7, date1, date2);
                this.reportViewer1.RefreshReport();
            }
            else MessageBox.Show("Начальная дата не может быть больше даты окончания.");
        }
示例#17
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 = new ToConnection();
                string ac_commandText = @"select me.id_currency
                                      from Flow me
                                      where me.id_currency = '" + sim + "'";
                SqlConnection connection = new SqlConnection(str.read_conf());
                try
                {
                    connection.Open();
                    SqlCommand accessUser = new SqlCommand(ac_commandText, connection);
                    SqlDataReader read_sql = accessUser.ExecuteReader();
                    int count = 0;
                    while (read_sql.Read())
                    {
                        count += 1;
                    }
                    if (count == 0)
                    {
                        _delete(sim);
                    }
                    else if (count >= 1)
                    {
                        MessageBox.Show("Данный метод оплаты не может быть удален по скольку использовался ранее в пополнении денежных средст на счет.", "Внимание!", MessageBoxButtons.OK,MessageBoxIcon.Information);
                    }
                }

                catch (Exception ex)
                {

                    MessageBox.Show(ex.Message.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

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

            }
        }
示例#18
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 = new ToConnection();
                string ac_commandText = @"select me.id_service
                                      from Expenses me
                                      where me.id_service = '" + sim + "'";
                SqlConnection connection = new SqlConnection(str.read_conf());
                try
                {
                    connection.Open();
                    SqlCommand accessUser = new SqlCommand(ac_commandText, connection);
                    SqlDataReader read_sql = accessUser.ExecuteReader();
                    int count = 0;
                    while (read_sql.Read())
                    {
                        count += 1;
                    }
                    if (count == 0)
                    {
                        _delete(sim);
                    }
                    else MessageBox.Show("Данная услуга использовалась в транзакциях. Удаление услуги невозможно.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }

                catch (Exception ex)
                {

                    MessageBox.Show(ex.Message.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                }
                finally
                {
                    connection.Close();
                }
            }
            catch
            {
                MessageBox.Show("Услуга не выбрана.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#19
0
        //кнопка редактирования
        private void b_edit_Click(object sender, EventArgs e)
        {
            string _bonus3 = "";
            ToConnection str_id_bonus2 = new ToConnection();
            SqlConnection acc_id_bonus2 = new SqlConnection(str_id_bonus2.read_conf());
            string queryString3 = @"Select me.id_bonus
                                        From Bonus me
                                        where me.bonus = '0'";
            try
            {
                acc_id_bonus2.Open();
                SqlCommand cmd2 = new SqlCommand(queryString3, acc_id_bonus2);
                SqlDataReader dr2 = cmd2.ExecuteReader();
                while (dr2.Read())
                {
                    _bonus3 = dr2["id_bonus"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_id_bonus2.Close();

            }
            bool mil = false;
            string _level = c_Bonus.Enabled.ToString();
            bool sim = false;
            if (_level == "True")
            {
                if (c_Bonus.SelectedIndex != -1)
                {
                    sim = true;
                    mil = true;
                }
                else sim = false;

            }
            else sim = true;

            if (sim == true)
            {
                string _bonus = "";
                if (mil == true)
                {
                    //Поиск выбранных бонусов

                    ToConnection str_id_bonus = new ToConnection();
                    SqlConnection acc_id_bonus = new SqlConnection(str_id_bonus.read_conf());
                    string queryString2 = @"Select me.id_bonus
                                        From Bonus me
                                        where me.Name = '" + c_Bonus.SelectedItem.ToString() + "'";
                    try
                    {
                        acc_id_bonus.Open();
                        SqlCommand cmd2 = new SqlCommand(queryString2, acc_id_bonus);
                        SqlDataReader dr2 = cmd2.ExecuteReader();
                        while (dr2.Read())
                        {
                            _bonus = dr2["id_bonus"].ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    finally
                    {
                        acc_id_bonus.Close();

                    }
                }

                //поиск схожих номеров
                bool otv1 = false;
                int count = 0;
                ToConnection str_number = new ToConnection();
                SqlConnection acc_number = new SqlConnection(str_number.read_conf());
                string tab_sql = @"Select me.Number_card
                                      From Client me
                                      Where me.Number_card='" + t_num.Text + "';";

                try
                {
                    acc_number.Open();
                    SqlCommand s_User = new SqlCommand(tab_sql, acc_number);
                    SqlDataReader read_sql = s_User.ExecuteReader();

                    while (read_sql.Read())
                    {
                        count += 1;

                    }
                    if (count == 1)
                    {
                        otv1 = false;
                    }
                    else if (count == 0)
                    {
                        otv1 = true;

                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_number.Close();
                }
                if (otv1 == true)
                {
                    l_error.Text = "";
                    if ((t_num.Text != "") & (t_fio.Text != ""))
                    {
                        _add_stream(_bonus, _level, _bonus3);
                        l_error.Text = "";
                    }
                    else l_error.Text = "Не заполнены поля:Номер карты или ФИО";
                }
                else l_error.Text = "Такой номер карты уже существует.";

            }
            else l_error.Text = "Не выбрана скидка.";
        }
示例#20
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();
            }
        }
示例#21
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();
            }
        }
示例#22
0
        private void limb()
        {
            string _bonus3 = "";
            ToConnection str_id_bonus2 = new ToConnection();
            SqlConnection acc_id_bonus2 = new SqlConnection(str_id_bonus2.read_conf());
            string queryString3 = @"Select me.id_bonus
                                        From Bonus me
                                        where me.bonus = '0'";
            try
            {
                acc_id_bonus2.Open();
                SqlCommand cmd2 = new SqlCommand(queryString3, acc_id_bonus2);
                SqlDataReader dr2 = cmd2.ExecuteReader();
                while (dr2.Read())
                {
                    _bonus3 = dr2["id_bonus"].ToString();

                }
                if (_bonus3 != "")
                {
                    checkedListBox1.Enabled = true;
                }
                else
                {
                    checkedListBox1.Enabled = false;
                    MessageBox.Show("Для использования уровней бонусной системы необходимо создать Нулевой бонус!", "Предупреждение!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc_id_bonus2.Close();

            }
        }
示例#23
0
        //метод снятия
        private void _remove(string star_del)
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @" BEGIN TRANSACTION;
                                        UPDATE Client
                                      SET Client._delete = 'False'
                                      Where Client.id_client='" + star_del + "' COMMIT TRANSACTION;";

            try
            {
                acc.Open();
                SqlCommand s_User = new SqlCommand(tab_sql, acc);
                s_User.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#24
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 = "Заполните все поля справочника услуги.";
        }
示例#25
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 = "Не выбрана услуга.";
            }
        }
示例#26
0
        private void delete_bt_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 = new ToConnection();
                string ac_commandText = @"select me.id_bonus
                                      from Client me
                                      where me.id_bonus = '" + sim + "'";
                SqlConnection connection = new SqlConnection(str.read_conf());
                try
                {
                    l_error.Text = "";
                    connection.Open();
                    SqlCommand accessUser = new SqlCommand(ac_commandText, connection);
                    SqlDataReader read_sql = accessUser.ExecuteReader();
                    int count = 0;
                    while (read_sql.Read())
                    {
                        count += 1;
                    }
                    if (count == 0)
                    {
                        _delete(sim);
                    }
                    else if (count >= 1)
                    {
                        l_error.Text = "Данный бонус уже используеться. Удалить нельзя.";
                    }
                }
                catch (Exception ex)
                {

                    MessageBox.Show(ex.Message.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                }
                finally
                {
                    connection.Close();
                }
            }
            catch
            {
                l_error.Text = "Не выбран бонус.";
            }
        }
示例#27
0
        //кнопка добавить с условиями
        private void add_bt_Click(object sender, EventArgs e)
        {
            //Поиск максимального числа в МАХ для сравнения с предыдущем
                string _sill = "";
                ToConnection str_id_bonus2 = new ToConnection();
                SqlConnection acc_id_bonus2 = new SqlConnection(str_id_bonus2.read_conf());
                string queryString3 = @"Select  Max(me.level_max) as Simm
                                        From Level_bns me";
                try
                {
                    acc_id_bonus2.Open();
                    SqlCommand cmd2 = new SqlCommand(queryString3, acc_id_bonus2);
                    SqlDataReader dr2 = cmd2.ExecuteReader();
                    while (dr2.Read())
                    {
                        if (dr2["Simm"].ToString() != "")
                        {
                            _sill = dr2["Simm"].ToString();
                        }
                        else _sill = "0";

                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    acc_id_bonus2.Close();

                }

                //Проверка если он залезет в диапозон в других уровней
                if (Convert.ToDouble(t_min.Text) > Convert.ToDouble(_sill))
                {
                    //Проверка правильность МАХ и МIN
                    if (Convert.ToInt32(t_min.Text) < Convert.ToInt32(t_max.Text))
                    {
                        //Выбран ли бонус
                        if (c_Bonus.SelectedIndex != -1)
                        {

                            string _bonus = "";
                            //Поиск выбранных бонусов
                            ToConnection str_id_bonus = new ToConnection();
                            SqlConnection acc_id_bonus = new SqlConnection(str_id_bonus.read_conf());
                            string queryString2 = @"Select me.id_bonus
                                                From Bonus me
                                                where me.Name = '" + c_Bonus.SelectedItem.ToString() + "'";
                            try
                            {
                                acc_id_bonus.Open();
                                SqlCommand cmd2 = new SqlCommand(queryString2, acc_id_bonus);
                                SqlDataReader dr2 = cmd2.ExecuteReader();
                                while (dr2.Read())
                                {
                                    _bonus = dr2["id_bonus"].ToString();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            finally
                            {
                                acc_id_bonus.Close();

                            }
                            //Поиск идентичного бонуса
                            bool otv1 = false;
                            int count = 0;
                            ToConnection str_number = new ToConnection();
                            SqlConnection acc_number = new SqlConnection(str_number.read_conf());
                            string tab_sql = @"Select me.id_bonus
                                              From Level_bns me
                                              Where me.id_bonus='" + _bonus + "';";

                            try
                            {
                                acc_number.Open();
                                SqlCommand s_User = new SqlCommand(tab_sql, acc_number);
                                SqlDataReader read_sql = s_User.ExecuteReader();

                                while (read_sql.Read())
                                {
                                    count += 1;

                                }
                                if (count == 1)
                                {
                                    otv1 = false;
                                }
                                else if (count == 0)
                                {
                                    otv1 = true;

                                }

                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(Convert.ToString(ex), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            finally
                            {
                                acc_number.Close();
                            }
                            if (otv1 == true)
                            {
                                l_error.Text = "";
                                if ((t_min.Text != "") & (t_max.Text != ""))
                                {
                                    str(_bonus);
                                    l_error.Text = "";
                                }
                                else l_error.Text = "Не все поля заполнены.";
                            }
                            else l_error.Text = "Такой бонус в уровне уже существует.";
                        }
                        else l_error.Text = "Не выбран бонус для уровня.";
                    }
                    else l_error.Text = "Min не может быть больше MAX.";
                }
                else l_error.Text = "Такой уровень уже есть.";
        }
示例#28
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 = "Не все поля заполнены.";
        }
示例#29
0
        private void _delete(string sim)
        {
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"BEGIN TRANSACTION; DELETE From Service
                                      Where Service.id_service='" + sim + "'; COMMIT TRANSACTION;";
            try
            {
                acc.Open();
                SqlCommand s_User = new SqlCommand(tab_sql, acc);
                s_User.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
        }
示例#30
0
        //удаление бонусов
        private void delete_bt_Click(object sender, EventArgs e)
        {
            int ind_sql = Convert.ToInt32(DatGridUser.CurrentRow.Index.ToString());
            string sim = DatGridUser[0, ind_sql].Value.ToString();
            ToConnection str_config = new ToConnection();
            SqlConnection acc = new SqlConnection(str_config.read_conf());

            string tab_sql = @"BEGIN TRANSACTION; DELETE From Level_bns COMMIT TRANSACTION;";
            try
            {
                acc.Open();
                SqlCommand s_User = new SqlCommand(tab_sql, acc);
                s_User.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Критическая ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                acc.Close();
            }
            User_acc();
        }