Пример #1
0
 private void EMP_ISERT_CANCEL_Click(object sender, EventArgs e)
 {
     NameSet.Clear();
     AgeSet.Value     = 20;
     SalarySet.Value  = 5000;
     PremiumSet.Value = 0;
     PhoneSet.Clear();
     EmailSet.Clear();
     Dep_IdSET.Value = 0;
     label22.Visible = false;
 }
Пример #2
0
        private async void EMP_UPDATE_OK_Click(object sender, EventArgs e)
        {
            if (label25.Visible)
            {
                label25.Visible = false;
            }

            if (!string.IsNullOrEmpty(Name_Update.Text) && !string.IsNullOrWhiteSpace(Name_Update.Text) &&
                !string.IsNullOrEmpty(ID_UPDATE.Text) && !string.IsNullOrWhiteSpace(ID_UPDATE.Text))
            {
                SqlCommand command = new SqlCommand("UPDATE [Employees] SET [Name]=@Name, " +
                                                    "[Age]=@Age,[Salary]=@Salary,[Premium]=@Premium,[PhoneNumber]=@phoneNumber," +
                                                    "[Email]=@Email,[Dep_Id]=@Dep_Id WHERE [Id]=@Id", sqlconnection);
                command.Parameters.AddWithValue("Id", ID_UPDATE.Text);
                command.Parameters.AddWithValue("Name", Name_Update.Text);
                command.Parameters.AddWithValue("Age", Age_Update.Value);
                command.Parameters.AddWithValue("Salary", Salary_Update.Value);
                command.Parameters.AddWithValue("Premium", Premium_Update.Value);
                command.Parameters.AddWithValue("PhoneNumber", PhoneNumber_Update.Text);
                command.Parameters.AddWithValue("Email", Email_Update.Text);
                command.Parameters.AddWithValue("Dep_Id", DepID_Update.Text);

                await command.ExecuteNonQueryAsync();

                ID_UPDATE.Clear();
                NameSet.Clear();
                Age_Update.Value     = 20;
                Salary_Update.Value  = 5000;
                Premium_Update.Value = 0;
                PhoneNumber_Update.Clear();
                Email_Update.Clear();
                DepID_Update.Value = 1;
            }
            else if (string.IsNullOrEmpty(ID_UPDATE.Text) && string.IsNullOrWhiteSpace(ID_UPDATE.Text))
            {
                label25.Visible = true;
                label25.Text    = "идентификатор должен быть заполнен ";
            }
            else
            {
                label25.Visible = true;
                label25.Text    = "поля введены не коректно";
            }
        }
Пример #3
0
        private async void EMP_INSERT_OK_Click(object sender, EventArgs e)
        {
            if (label22.Visible)
            {
                label22.Visible = false;
            }

            if (!string.IsNullOrEmpty(NameSet.Text) && !string.IsNullOrWhiteSpace(NameSet.Text) &&
                !string.IsNullOrEmpty(PhoneSet.Text) && !string.IsNullOrWhiteSpace(PhoneSet.Text) &&
                !string.IsNullOrEmpty(EmailSet.Text) && !string.IsNullOrWhiteSpace(EmailSet.Text) &&
                Dep_IdSET.Value != 0)
            {
                SqlCommand command = new SqlCommand("INSERT INTO [Employees](Name,Age,Salary,Premium,PhoneNumber,Email,Dep_Id)" +
                                                    "Values(@Name,@Age,@Salary,@Premium,@PhoneNumber,@Email,@Dep_Id)", sqlconnection);

                command.Parameters.AddWithValue("Name", NameSet.Text);
                command.Parameters.AddWithValue("Age", AgeSet.Value);
                command.Parameters.AddWithValue("Salary", SalarySet.Value);
                command.Parameters.AddWithValue("Premium", PremiumSet.Value);
                command.Parameters.AddWithValue("PhoneNumber", PhoneSet.Text);
                command.Parameters.AddWithValue("Email", EmailSet.Text);
                command.Parameters.AddWithValue("Dep_Id", Dep_IdSET.Value);

                await command.ExecuteNonQueryAsync();

                NameSet.Clear();
                AgeSet.Value     = 20;
                SalarySet.Value  = 5000;
                PremiumSet.Value = 0;
                PhoneSet.Clear();
                EmailSet.Clear();
                Dep_IdSET.Value = 0;
            }
            else
            {
                label22.Visible = true;
                label22.Text    = "поля введены не коректно";
            }
        }