public IActionResult CreateNewEmployee(Employee newEmployee)
        {
            EmployeeRepo er = new EmployeeRepo();

            er.CreateEmployee(newEmployee);
            return(RedirectToAction("Index"));
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.CheckIfFieldEmpty();

                PersonRepo p = new PersonRepo();
                p.Name       = this.txtFullName.Text;
                p.Age        = Convert.ToInt32(this.txtAge.Text);
                p.Gender     = this.cmbGender.Text;
                p.BloodGroup = this.cmbBloodGrp.Text;
                p.Phone      = this.txtPhoneNumber.Text;


                EmployeeRepo e1 = new EmployeeRepo();

                e1.Salary      = Convert.ToInt32(this.txtSalary.Text);
                e1.Designation = this.cmbDesignation.Text;
                //e1.PersonIdOfEmp = Convert.ToInt32(this.txtId.Text);

                DoctorRepo dr = new DoctorRepo();
                dr.Specialty     = this.txtSpecialty.Text;
                dr.AvailableDays = this.cmbAvailableDays.Text;
                //dr.EmployeeIdOfDoctor = Convert.ToInt32(this.txtEmpId.Text);

                //person created
                p.CreatePerson(p.Name, p.Age, p.Gender, p.BloodGroup, p.Phone);
                this.PopulatePersonTable();
                //refrsh

                //get last person
                DataTable lastperson = p.GetLastPerson();

                //DataTable lastperson = p.GetLastPerson();
                this.personID = Convert.ToInt32(lastperson.Rows[0]["personid"].ToString());

                //getpersonid
                //this.personID = Convert.ToInt32(lastperson.Rows[0]["personid"].ToString());
                //create emplyee
                e1.CreateEmployee(e1.Designation, e1.Salary, this.personID);
                if (this.cmbDesignation.Text == "Doctor")
                {
                    DataTable lastemp = e1.GetLastEmployee();
                    this.empID = Convert.ToInt32(lastemp.Rows[0]["empid"].ToString());

                    //create doctor
                    dr.CreateDoctor(dr.Specialty, dr.AvailableDays, empID);
                }

                MessageBox.Show("Successfully added!");
                this.PopulatePersonTable();
                this.ClearAll();
            }
            catch (Exception exc)
            {
                MessageBox.Show("error!" + exc);
            }
        }
예제 #3
0
        private async Task Create()
        {
            await EmployeeRepo.CreateEmployee(_employee);

            //Toaster notifications
            ToastService.ShowSuccess($"Action successful." +
                                     $"Employee \"{_employee.Name}\" successfully added.");
            _employee = new Employee();
            _editContext.OnValidationStateChanged += ValidationChanged;
            _editContext.NotifyValidationStateChanged();
        }