Пример #1
0
        private void Check()
        {
            DataBaseWork.OpenCon();

            string login    = Convert.ToString(LoginText.Text);
            string password = Convert.ToString(PassText.Text);
            int    i        = 0;

            string security = "SELECT * FROM access WHERE login = '******' AND password = '******';";

            SqlCommand sc = new SqlCommand(security, DataBaseWork.Con);

            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(sc);


            sda.Fill(dt);
            i = Convert.ToInt32(dt.Rows.Count.ToString());

            if (i == 0)
            {
                MessageBox.Show("Ошибка автоизации");
            }
            else
            {
                Main main = new Main();
                main.Show();
                Hide();
            }

            DataBaseWork.CloseConnection();
        }
Пример #2
0
        public static void UpdClient(string surname, string name, string patronimyc, string address, string phone)
        {
            DataBaseWork.OpenCon();
            string     add = String.Format("UPDATE {0} SET C_SURNAME = '{1}', C_NAME = '{2}', C_PATRONYMIC = '{3}', C_ADDRESS = '{4}', C_NUMBER = '{5}' WHERE ID = '{6}'", "CLIENTS", surname, name, patronimyc, address, phone);
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
        }
Пример #3
0
        public static void AddManager(string surname, string name, string patronimyc, string address, string phone, string salary, string login, string password)
        {
            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO MANAGERS (MANAGER_SURNAME,MANAGER_NAME,MANAGER_PATRONYMIC,MANAGER_ADDRESS, MANAGER_PHONE, MANAGER_SALARY,MANAGER_LOGIN, MANAGER_PASSWORD) VALUES ('" + surname + "', '" + name + "', '" + patronimyc + "', '" + address + "', '" + phone + "', '" + salary + "', '" + login + "', '" + password + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
        }
Пример #4
0
        public static void DeleteManager(DataGridView grid)
        {
            DataBaseWork.OpenCon();
            var        num = (int)grid.CurrentRow.Cells["ID"].Value;
            SqlCommand sc  = new SqlCommand(String.Format("DELETE FROM MANAGERS WHERE ID = {0}", num), DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
        }
Пример #5
0
        public static void AddClient(string surname, string name, string patronimyc, string address, string phone)
        {
            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO CLIENTS (C_SURNAME,C_NAME,C_PATRONYMIC,C_ADDRESS,C_NUMBER) VALUES ('" + surname + "', '" + name + "', '" + patronimyc + "', '" + address + "', '" + phone + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
        }
Пример #6
0
        private void AddButQual_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            string     upd = String.Format("UPDATE {0} SET APPELATION = '{1}', Q_POWER = '{2}' WHERE ID = '{3}'", "QUALIFICATION", AText.Text, PText.Text, id);
            SqlCommand sc  = new SqlCommand(upd, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            MessageBox.Show("Данные о квалификации успешно изменены.");
            DataBaseWork.CloseConnection();
        }
Пример #7
0
        private void AddMasterBut_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            string     upd = String.Format("UPDATE {0} SET name = '{1}', surname = '{2}', dateofbirth = '{3}', phonenumber = '{4}', salary = '{5}', brunchid = '{6}' WHERE managerid = '{7}'", "managers", SurnameText.Text, NameText.Text, dateTimePicker1.Value.Date, AddressText.Text, PhoneText.Text, QualList.ValueMember);
            SqlCommand sc  = new SqlCommand(upd, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            MessageBox.Show("Данные о менеджере успешно изменены.");
            DataBaseWork.CloseConnection();
        }
Пример #8
0
        private void UpdManagerBut_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            string     upd = String.Format("UPDATE {0} SET MANAGER_SURNAME = '{1}', MANAGER_NAME = '{2}', MANAGER_PATRONYMIC = '{3}',MANAGER_ADDRESS = '{4}',MANAGER_PHONE = '{5}',MANAGER_SALARY = '{6}',MANAGER_LOGIN = '******', MANAGER_PASSWORD = '******' WHERE ID = '{9}'", "MANAGERS", SurnameText.Text, NameText.Text, PatronymicText.Text, AddressText.Text, PhoneText.Text, SalaryText.Text, LoginText.Text, PasswordText.Text, id);
            SqlCommand sc  = new SqlCommand(upd, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            MessageBox.Show("Данные менеджера успешно изменены.");
            DataBaseWork.CloseConnection();
        }
Пример #9
0
        private void UpdTypeBut_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            string     upd = String.Format("UPDATE {0} SET NAME_TYPE = '{1}' WHERE ID = '{2}'", "PRODUCT_TYPE", ApText.Text, id);
            SqlCommand sc  = new SqlCommand(upd, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            MessageBox.Show("Данные типа изделий успешно изменены.");
            DataBaseWork.CloseConnection();
        }
Пример #10
0
        private void delete_manager_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            var        num = (int)manager_list.CurrentRow.Cells["managerid"].Value;
            SqlCommand sc  = new SqlCommand(String.Format("DELETE FROM managers WHERE managerid = {0}", num), DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Данные о менеджере успешно удалены");
        }
Пример #11
0
        private void LoadCombo()
        {
            DataBaseWork.OpenCon();

            SqlCommand     sc = new SqlCommand("SELECT * FROM PRODUCT", DataBaseWork.Con);
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(sc);

            da.Fill(dt);
            ProdList.DataSource    = dt;
            ProdList.DisplayMember = "APPELATION";
            ProdList.ValueMember   = "ID";
            ProdList.SelectedIndex = 0;

            SqlCommand     sc1 = new SqlCommand("SELECT * FROM MATERIALS", DataBaseWork.Con);
            DataTable      dt1 = new DataTable();
            SqlDataAdapter da1 = new SqlDataAdapter(sc1);

            da1.Fill(dt1);
            MatList.DataSource    = dt1;
            MatList.DisplayMember = "APPELATION";
            MatList.ValueMember   = "ID";


            SqlCommand     sc2 = new SqlCommand("SELECT * FROM MASTERS", DataBaseWork.Con);
            DataTable      dt2 = new DataTable();
            SqlDataAdapter da2 = new SqlDataAdapter(sc2);

            da2.Fill(dt2);
            MasList.DataSource    = dt2;
            MasList.DisplayMember = "MAS_SURNAME";
            MasList.ValueMember   = "ID";


            SqlCommand     sc3 = new SqlCommand("SELECT * FROM CLIENTS", DataBaseWork.Con);
            DataTable      dt3 = new DataTable();
            SqlDataAdapter da3 = new SqlDataAdapter(sc3);

            da3.Fill(dt3);
            CliList.DataSource    = dt3;
            CliList.DisplayMember = "C_SURNAME";
            CliList.ValueMember   = "ID";
            CliList.SelectedIndex = 0;

            SqlCommand     sc4 = new SqlCommand("SELECT * FROM ORDERS", DataBaseWork.Con);
            DataTable      dt4 = new DataTable();
            SqlDataAdapter da4 = new SqlDataAdapter(sc4);

            da4.Fill(dt4);
            OrderNum.DataSource    = dt4;
            OrderNum.DisplayMember = "ID";
            OrderNum.ValueMember   = "ID";
            DataBaseWork.CloseConnection();
        }
Пример #12
0
        private void AddProductBut_Click(object sender, EventArgs e)
        {
            int t = Convert.ToInt32(TypeCombo.SelectedValue);

            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO PRODUCT (APPELATION,P_TYPE,TIME_PROD ) VALUES ('" + Appelation.Text + "', " + t + ", '" + TimeProd.Text + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Изделие успешно добавлено");
        }
Пример #13
0
        private void AddMasterBut_Click(object sender, EventArgs e)
        {
            int q = Convert.ToInt32(QualList.SelectedValue);

            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO managers (name, surname, dateofbirth, phonenumber, salary, brunchid ) VALUES ('" + SurnameText.Text + "', '" + NameText.Text + "', '" + dateTimePicker1.Value.Date + "', '" + AddressText.Text + "', '" + PhoneText.Text + "', " + q + ")");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Менеджер успешно добавлен");
        }
Пример #14
0
        private void AddMasterBut_Click(object sender, EventArgs e)
        {
            int q = Convert.ToInt32(QualList.SelectedValue);

            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO MASTERS (MAS_SURNAME, MAS_NAME, MAS_PATRONYMIC, MAS_ADDRESS, MAS_NUMBER, ID_QUAL, MAS_MONEY) VALUES ('" + SurnameText.Text + "', '" + NameText.Text + "', '" + PatronimycText.Text + "', '" + AddressText.Text + "', '" + PhoneText.Text + "', " + q + ", '" + SalaryText.Text + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Мастер успешно добавлен");
        }
Пример #15
0
        private void ContrBut_Click(object sender, EventArgs e)
        {
            int o      = Convert.ToInt32(OrderNum.SelectedValue);
            int client = Convert.ToInt32(CliList.SelectedValue);

            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO CONTRACTS (ID_ORDER,ID_CLIENT, ID_MANAGER, DATE_CONTR) VALUES (" + o + ", " + client + ", " + Manager.id + ", '" + DateContr.Value.Date + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Договор успешно добавлен");
        }
Пример #16
0
        private void UpdMaterialBut_Click(object sender, EventArgs e)
        {
            decimal p = Convert.ToDecimal(price);
            decimal q = Convert.ToDecimal(QuaText.Text);

            DataBaseWork.OpenCon();
            string     upd = String.Format("UPDATE {0} SET APPELATION = '{1}', PRICE_GRAM = {2}, QUANTITY = {3} WHERE ID = '{4}'", "MATERIALS", ApText.Text, p, q, id);
            SqlCommand sc  = new SqlCommand(upd, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            MessageBox.Show("Данные о материале успешно изменены.");
            DataBaseWork.CloseConnection();
        }
Пример #17
0
 private void AddTypeBut_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     add = String.Format("INSERT INTO PRODUCT_TYPE (NAME_TYPE) VALUES ('" + ApText.Text + "')");
         SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);
         sc.ExecuteNonQuery();
         DataBaseWork.CloseConnection();
         MessageBox.Show("Тип успешно добавлен в базу.");
     }
     catch
     {
         MessageBox.Show("При доавлении типа изделий произошла ошибка.\nПопробуйте ещё раз.");
     }
 }
Пример #18
0
 private void Save_Client_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     add = String.Format("INSERT INTO brunches (address, contactphone) VALUES ('" + address_brunch.Text + "', '" + conphone_brunch.Text + "')");
         SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);
         sc.ExecuteNonQuery();
         DataBaseWork.CloseConnection();
         MessageBox.Show("Филиал успешно добавлен в базу.");
     }
     catch
     {
         MessageBox.Show("Ошибка добавления.\nПопробуйте ещё раз");
     }
 }
Пример #19
0
 private void AddManager_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     add = String.Format("INSERT INTO customers (name, surname, dateofbirth, phonenumber, address, passport ) VALUES ('" + SurnameText.Text + "', '" + NameText.Text + "', '" + date_birth.Value.Date + "', '" + AddressText.Text + "', '" + PhoneText.Text + "', '" + SalaryText.Text + "')");
         SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);
         sc.ExecuteNonQuery();
         DataBaseWork.CloseConnection();
         MessageBox.Show("Клиент успешно добавлен в базу.");
     }
     catch
     {
         MessageBox.Show("Ошибка добавления.\nПопробуйте ещё раз");
     }
 }
Пример #20
0
 private void AddButQual_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     add = String.Format("INSERT INTO QUALIFICATION (APPELATION, Q_POWER) VALUES ('" + AText.Text + "', '" + PText.Text + "')");
         SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);
         sc.ExecuteNonQuery();
         DataBaseWork.CloseConnection();
         MessageBox.Show("Квалификация успешно добавлена в базу.");
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Пример #21
0
        private void OrderBut_Click(object sender, EventArgs e)
        {
            int     p    = Convert.ToInt32(ProdList.SelectedValue);
            int     mat  = Convert.ToInt32(MatList.SelectedValue);
            int     mas  = Convert.ToInt32(MasList.SelectedValue);
            decimal pr   = Convert.ToDecimal(PriceEnd.Text);
            string  time = TimeProd.Text;

            DataBaseWork.OpenCon();
            string     add = String.Format("INSERT INTO ORDERS (ID_PRODUCT,ID_MATERIAL, ID_MASTER, PRICE, TIME_PROD ) VALUES (" + p + ", " + mat + ", " + mas + ", " + pr + ", '" + time + "')");
            SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);

            sc.ExecuteNonQuery();
            DataBaseWork.CloseConnection();
            MessageBox.Show("Заказ успешно добавлен");
        }
Пример #22
0
 private void AddMaterialBut_Click(object sender, EventArgs e)
 {
     try
     {
         decimal pr = Convert.ToDecimal(PrText.Text);
         decimal q  = Convert.ToDecimal(QuaText.Text);
         DataBaseWork.OpenCon();
         string     add = String.Format("INSERT INTO MATERIALS (APPELATION, PRICE_GRAM,QUANTITY ) VALUES ('" + ApText.Text + "', " + pr + ", " + q + ")");
         SqlCommand sc  = new SqlCommand(add, DataBaseWork.Con);
         sc.ExecuteNonQuery();
         DataBaseWork.CloseConnection();
         MessageBox.Show("Материал успешно добавлен в базу.");
     }
     catch
     {
         MessageBox.Show("Ошибка при добавлении материала.\nПопробуйте ещё раз.");
     }
 }
Пример #23
0
 private void Delete_Product_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Вы точно хотите удалить запись?", "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             DataBaseWork.OpenCon();
             var        num = (int)ProductList.CurrentRow.Cells["ID"].Value;
             SqlCommand sc  = new SqlCommand(String.Format("DELETE FROM PRODUCT WHERE ID = {0}", num), DataBaseWork.Con);
             sc.ExecuteNonQuery();
             DataBaseWork.CloseConnection();
             MessageBox.Show("Изделие удалено.");
             Main.Loading("SELECT * FROM PRODUCT", ProductList);
         }
     }
     catch
     {
         MessageBox.Show("Ошибка удаления");
     }
 }
Пример #24
0
 private void Delete_Client_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Вы точно хотите удалить запись?", "Deleting", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             DataBaseWork.OpenCon();
             var        num = (int)brunch_list.CurrentRow.Cells["brunchid"].Value;
             SqlCommand sc  = new SqlCommand(String.Format("DELETE FROM brunches WHERE brunchid = {0}", num), DataBaseWork.Con);
             sc.ExecuteNonQuery();
             DataBaseWork.CloseConnection();
             MessageBox.Show("Данные о филиале удалены");
             Loading("SELECT * FROM brunches", brunch_list);
         }
     }
     catch
     {
         MessageBox.Show("Ошибка удаления");
     }
 }
Пример #25
0
        private void Check()
        {
            DataBaseWork.OpenCon();

            string login    = Convert.ToString(LoginText.Text);
            string password = Convert.ToString(PassText.Text);
            int    i        = 0;

            string security = "SELECT * FROM MANAGERS WHERE MANAGER_LOGIN = '******' AND MANAGER_PASSWORD = '******';";

            SqlCommand sc = new SqlCommand(security, DataBaseWork.Con);

            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(sc);


            sda.Fill(dt);
            i = Convert.ToInt32(dt.Rows.Count.ToString());

            if (i == 0)
            {
                AdminInput();
            }
            else
            {
                SqlDataReader read = sc.ExecuteReader();
                while (read.Read())
                {
                    Manager.id         = Convert.ToInt32(read.GetValue(0).ToString());
                    Manager.surname    = Convert.ToString(read.GetValue(1).ToString());
                    Manager.name       = Convert.ToString(read.GetValue(2).ToString());
                    Manager.patronymic = Convert.ToString(read.GetValue(3).ToString());
                }
                Main main = new Main();
                main.Show();
                Hide();
            }

            DataBaseWork.CloseConnection();
        }