Example #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();
        }
Example #2
0
        private void UpdMasterBut_Click(object sender, EventArgs e)
        {
            DataBaseWork.OpenCon();
            string     save = String.Format("UPDATE {0} SET name = '{1}', surname = '{2}', dateofbirth  = '{3}', phonenumber = '{4}',address = '{5}', passport = '{6}'  WHERE customerid = '{7}'", "customers", SurnameText.Text, NameText.Text, dateTimePicker1.Value.Date, AddressText.Text, PhoneText.Text, SalaryText.Text, id);
            SqlCommand com  = new SqlCommand(save, DataBaseWork.Con);

            com.ExecuteNonQuery();
            MessageBox.Show("Данные о клиенте успешно изменены");
        }
Example #3
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();
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
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();
        }
Example #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();
        }
Example #8
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();
        }
Example #9
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("Данные о менеджере успешно удалены");
        }
Example #10
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();
        }
Example #11
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();
        }
Example #12
0
        private void UpdProductBut_Click(object sender, EventArgs e)
        {
            int t = Convert.ToInt32(TypeCombo.SelectedValue);

            DataBaseWork.OpenCon();
            string     save = String.Format("UPDATE {0} SET APPELATION = '{1}', P_TYPE = {2},TIME_PROD = '{3}' WHERE ID = '{4}'", "PRODUCT", Appelation.Text, t, TimeProd.Text, id);
            SqlCommand com  = new SqlCommand(save, DataBaseWork.Con);

            com.ExecuteNonQuery();
            MessageBox.Show("Данные об изделии успешно изменены");
        }
Example #13
0
        private void UpdMasterBut_Click(object sender, EventArgs e)
        {
            int q = Convert.ToInt32(QualList.SelectedValue);

            DataBaseWork.OpenCon();
            string     save = String.Format("UPDATE {0} SET MAS_SURNAME = '{1}', MAS_NAME = '{2}',MAS_PATRONYMIC = '{3}', MAS_ADDRESS = '{4}', MAS_NUMBER = '{5}',ID_QUAL = {6},MAS_MONEY = '{7}'  WHERE ID = '{8}'", "MASTERS", SurnameText.Text, NameText.Text, PatronimycText.Text, AddressText.Text, PhoneText.Text, q, SalaryText.Text, id);
            SqlCommand com  = new SqlCommand(save, DataBaseWork.Con);

            com.ExecuteNonQuery();
            MessageBox.Show("Данные о мастере успешно изменены");
        }
Example #14
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();
        }
Example #15
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("Мастер успешно добавлен");
        }
Example #16
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("Менеджер успешно добавлен");
        }
Example #17
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("Изделие успешно добавлено");
        }
Example #18
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();
        }
Example #19
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("Договор успешно добавлен");
        }
Example #20
0
 private void Save_Client_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     save = String.Format("UPDATE {0} SET address = '{1}', contactphone = '{2}' WHERE brunchid = '{3}'", "brunches", Surname_Client.Text, Name_Client.Text, id);
         SqlCommand com  = new SqlCommand(save, DataBaseWork.Con);
         com.ExecuteNonQuery();
         MessageBox.Show("Успех!");
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Example #21
0
 private void Save_Client_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseWork.OpenCon();
         string     save = 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_Client.Text, Name_Client.Text, Patronymic_Client.Text, Address_Client.Text, Phone_Client.Text, id);
         SqlCommand com  = new SqlCommand(save, DataBaseWork.Con);
         com.ExecuteNonQuery();
         MessageBox.Show("Успех!");
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Example #22
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Попробуйте ещё раз");
     }
 }
Example #23
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("Заказ успешно добавлен");
        }
Example #24
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");
     }
 }
Example #25
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Попробуйте ещё раз");
     }
 }
Example #26
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Попробуйте ещё раз.");
     }
 }
Example #27
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Попробуйте ещё раз.");
     }
 }
Example #28
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("Ошибка удаления");
     }
 }
Example #29
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("Ошибка удаления");
     }
 }
Example #30
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();
        }