Ejemplo n.º 1
0
 public void Button1_Click(object sender, EventArgs e)
 {
     if ((user_text.Text == emp1.name || user_text.Text == emp2.name || user_text.Text == emp3.name || user_text.Text == emp4.name ||
          user_text.Text == emp5.name) && Password.Text == "123")
     {
         if (user_text.Text == emp1.name)
         {
             Employee_form frm2 = new Employee_form(emp1.name, emp1.sex, emp1.age, emp1.workposition, emp1.salary, emp1.monthlyovertime,
                                                    emp1.workdurationincomp);
             this.Hide();
             frm2.ShowDialog();
             this.Close();
         }
         if (user_text.Text == emp2.name)
         {
             Employee_form frm2 = new Employee_form(emp2.name, emp2.sex, emp2.age, emp2.workposition, emp2.salary, emp2.monthlyovertime,
                                                    emp2.workdurationincomp);
             this.Hide();
             frm2.ShowDialog();
             this.Close();
         }
         if (user_text.Text == emp3.name)
         {
             Employee_form frm2 = new Employee_form(emp3.name, emp3.sex, emp3.age, emp3.workposition, emp3.salary, emp3.monthlyovertime,
                                                    emp3.workdurationincomp);
             this.Hide();
             frm2.ShowDialog();
             this.Close();
         }
         if (user_text.Text == emp4.name)
         {
             Employee_form frm2 = new Employee_form(emp4.name, emp4.sex, emp4.age, emp4.workposition, emp4.salary, emp4.monthlyovertime,
                                                    emp4.workdurationincomp);
             this.Hide();
             frm2.ShowDialog();
             this.Close();
         }
         if (user_text.Text == emp5.name)
         {
             Employee_form frm2 = new Employee_form(emp5.name, emp5.sex, emp5.age, emp5.workposition, emp5.salary, emp5.monthlyovertime,
                                                    emp5.workdurationincomp);
             this.Hide();
             frm2.ShowDialog();
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Invalid credentials, please enter the right username or password", "Login error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int c = 0;

            foreach (var control in this.Controls.OfType <TextBox>())
            {
                var textBox = control as TextBox;
                if (textBox.Text != "")
                {
                    c++;
                }
            }

            if (c == 0)
            {
                MessageBox.Show("You didn't insert any data to edit!");
                this.Refresh();
            }

            if ((name_edit.Text == "" || sex_edit.Text == "") && c != 0)
            {
                if (age_edit.Text != "")
                {
                    new_age = age_edit.Text;
                }
                if (work_pos_edit.Text != "")
                {
                    new_workposition = work_pos_edit.Text;
                }
                if (salary_edit.Text != "")
                {
                    new_salary = Convert.ToDouble(salary_edit.Text);
                }
                if (month_overtime_edit.Text != "")
                {
                    new_monthlyovertime = Convert.ToDouble(month_overtime_edit.Text);
                }
                if (work_dur_edit.Text != "")
                {
                    new_workdurationincomp = work_dur_edit.Text;
                }
                Employee_form frm2 = new Employee_form(new_name, new_sex, new_age, new_workposition, new_salary,
                                                       new_monthlyovertime, new_workdurationincomp);
                this.Hide();
                frm2.ShowDialog();
                this.Close();
            }
            else if (name_edit.Text != "" || sex_edit.Text != "")
            {
                new_name               = name_edit.Text;
                new_sex                = sex_edit.Text;
                new_age                = age_edit.Text;
                new_workposition       = work_pos_edit.Text;
                new_salary             = Convert.ToDouble(salary_edit.Text);
                new_monthlyovertime    = Convert.ToDouble(month_overtime_edit.Text);
                new_workdurationincomp = work_dur_edit.Text;
                Employee_form frm2 = new Employee_form(new_name, new_sex, new_age, new_workposition, Convert.ToDouble(new_salary),
                                                       Convert.ToDouble(new_monthlyovertime), new_workdurationincomp);
                this.Hide();
                frm2.ShowDialog();
                this.Close();
            }
        }