示例#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_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    = "поля введены не коректно";
            }
        }