Esempio n. 1
0
        private bool AddNewApplication()
        {
            if (F_Name.Text.Length <= 0)
            {
                MessageBox.Show("Впишите название для компонента");
                return(false);
            }
            try
            {
                if (F_Count.Text.Length <= 0)
                {
                    MessageBox.Show("Введите количество компонентов");
                    return(false);
                }

                Convert.ToInt32(F_Count.Text);
            }
            catch
            {
                MessageBox.Show("В поле количество присутсвуют лишние символы");
                return(false);
            }
            if (F_Postav.SelectedItem.ToString() == "---")
            {
                MessageBox.Show("Поставщик не выбран");
                return(false);
            }

            string ID_Postavchik = UsAc.Execute($@"SELECT ID_Postavchik FROM Postavchiki WHERE Nazvanie_Postavchik = ""{F_Postav.SelectedItem.ToString()}""").Table.Rows[0]["ID_Postavchik"].ToString();

            UsAc.ExecuteNonQuery($@"INSERT INTO TMC (Nazvanie_TMC, Kolichestvo_TMC, Postavchik_TMC) VALUES (""{F_Name.Text}"", {F_Count.Text}, {ID_Postavchik})");

            return(true);
        }
Esempio n. 2
0
        private void Enter(object sender, RoutedEventArgs e)
        {
            //Проверка длины
            if (F_Pas1.Password.Length < 4)
            {
                MessageBox.Show("Пароль должен содежать не менее 4 символов");
                return;
            }

            if (F_Pas1.Password != F_Pas2.Password)
            {
                MessageBox.Show("Пароли не совпадают");
                return;
            }

            UsAc.ExecuteNonQuery($@"UPDATE Users SET Password_User = ""{F_Pas1.Password}"" WHERE Login_User = ""{login}""");

            MessageBox.Show("Пароль был создан");
            this.DialogResult = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Создает запись о том, что пользователь вошел в то или иное время
        /// </summary>
        /// <param name="InOut">1 - вход. 0 - выход</param>
        private void AddLogToAutorization(int InOut)
        {
            if (UserID == null)
            {
                return;
            }

            try
            {
                if (InOut == 1)
                {
                    var time = DateTime.Now.ToString();
                    UsAc.ExecuteNonQuery($@"INSERT INTO Log_avtorizatcii (ID_User, Time_in) VALUES ({UserID}, ""{time}"")");
                    TimeIn = time;
                }
                else if (InOut == 0)
                {
                    UsAc.ExecuteNonQuery($@"UPDATE Log_avtorizatcii SET Time_out = ""{DateTime.Now.ToString()}"" WHERE Time_in = ""{TimeIn}""");
                    TimeIn = null;
                }
            }
            catch { }
        }
Esempio n. 4
0
        private bool AddNewUser()
        {
            //Проверка длины логина
            if (F_Login.Text.Length < 4)
            {
                MessageBox.Show("Длина логина не может быть короче 4 символов");
                return(false);
            }

            //Добавление как пользователя
            UsAc.ExecuteNonQuery($@"INSERT INTO Users (Login_User, Password_User, Role) VALUES (""{F_Login.Text}"","""", 2)");

            //Получение ID пользователя
            string ID    = null;
            var    table = UsAc.Execute("SELECT Max(Users.ID_User) AS [ID] FROM Users");

            ID = table.Table.Rows[0]["ID"].ToString();

            //Добавление как сотрдуника
            string value = null;

            string From   = null;
            string Values = null;

            value = F_FIO.Text;
            if (value.Length != 0)
            {
                From   += "FIO_Master";
                Values += $@"""{F_FIO.Text}""";
            }

            value = F_Doljnost.Text;
            if (value != "---")
            {
                From   += ",Doljnost_Master";
                Values += "," + GetId("Doljnosti", "ID_Doljnost", F_Doljnost.SelectedItem.ToString(), "Nazvanie_Doljnost");
            }

            value = F_Birthday.Text;
            if (value.Length != 0)
            {
                From   += ",DateOfBirth_Master";
                Values += $@",""{F_Birthday.Text}""";
            }

            value = F_Phone.Text;
            if (value.Length != 0)
            {
                From   += ",Phone_Master";
                Values += $@",""{F_Phone.Text}""";
            }

            value = F_Address.Text;
            if (value.Length != 0)
            {
                From   += ",Adress_Master";
                Values += $@",""{F_Address.Text}""";
            }

            value = F_Email.Text;
            if (value.Length != 0)
            {
                From   += ",Email_Master";
                Values += $@",""{F_Email.Text}""";
            }

            From   += ",IDUsera";
            Values += $@",{ID}";

            UsAc.ExecuteNonQuery($@"INSERT INTO Sotrudniki ({From}) VALUES ({Values})");

            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Метод добавления новой записи
        /// </summary>
        private void AddNewApplication()
        {
            string value = null;

            string From   = null;
            string Values = null;

            value = F_DataZayavki.Text;
            if (value.Length != 0)
            {
                From   += "Date_Zayavki";
                Values += $@"""{F_DataZayavki.Text}""";
            }

            value = F_FIO_Master.Text;
            if (value != "---")
            {
                From   += ",Master";
                Values += "," + GetId("Sotrudniki", "ID_Master", F_FIO_Master.SelectedItem.ToString(), "FIO_Master");
            }

            value = F_FIO_Client.Text;
            if (value != "---")
            {
                From   += ",Client";
                Values += "," + GetId("Clients", "ID_Client", F_FIO_Client.SelectedItem.ToString(), "FIO_Client");
            }

            value = F_Type_neispravnosti.Text;
            if (value != "---")
            {
                From   += ",Neispravnost_Zayavki";
                Values += "," + GetId("Neispravnosti", "ID_Neispravnosti", F_Type_neispravnosti.SelectedItem.ToString(), "Naimenovanie");
            }

            value = F_Type_tehniki.Text;
            if (value != "---")
            {
                From   += ",Type_Tehniki_Zayavki";
                Values += "," + GetId("TypeTehniki", "ID_TypeTehniki", F_Type_tehniki.SelectedItem.ToString(), "Type_TypeTehniki");
            }

            value = F_Producer.Text;
            if (value != "---")
            {
                From   += ",Izgotovitel";
                Values += "," + GetId("Izgotovitel", "ID_Izgotovitel", F_Producer.SelectedItem.ToString(), "Nazvanie_Izgotovitel");
                ;
            }

            value = F_Model.Text;
            if (value != "---")
            {
                From   += ",ID_Oborudovaniya";
                Values += "," + GetId("Oborudovanie", "ID_Oborudovaniya", F_Model.SelectedItem.ToString(), "Model");
            }

            value = F_NameUsligu.Text;
            if (value != "---")
            {
                From   += ",Services";
                Values += "," + GetId("Services", "ID_Services", F_NameUsligu.SelectedItem.ToString(), "Nazvanie_Services");
            }

            value = F_DetalCount.Text;
            if (value.Length != 0)
            {
                From   += ",KolvoServ";
                Values += "," + F_DetalCount.Text;
            }

            value = F_DetalName.Text;
            if (value != "---")
            {
                From   += ",Materiali";
                Values += "," + GetId("TMC", "ID_TMC", F_DetalName.SelectedItem.ToString(), "Nazvanie_TMC");
            }

            value = F_Statys.Text;
            if (value != "---")
            {
                From   += ",Statys";
                Values += "," + GetId("Statys", "ID_Statys", F_Statys.SelectedItem.ToString(), "Statys_Statys");
            }

            value = F_DataFinished.Text;
            if (value.Length != 0)
            {
                From   += ",Date_okonchaniya_Zayavki";
                Values += "," + $@"""{F_DataFinished.Text}""";
            }

            value = F_Summ.Text;
            if (value.Length != 0)
            {
                From   += ",Summa";
                Values += "," + $@"""{F_Summ.Text}""";
            }

            UsAc.ExecuteNonQuery($@"INSERT INTO Zayavki ({From}) VALUES ({Values})");
        }