Esempio n. 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            ServiceEmployeesClient cliente = new ServiceEmployeesClient();

            if ((Convert.ToInt32(this.txtType.Text)) == 1)
            {
                FullTimeEmployee fte = new FullTimeEmployee();
                fte.Id        = Convert.ToInt32(this.txtId.Text);
                fte.Name      = Convert.ToString(this.txtName.Text);
                fte.StartDate = Convert.ToDateTime(this.txtDate.Text);
                fte.Salary    = Convert.ToInt32(this.txtSalary);
                cliente.UpdateEmployee(fte);
            }
            else
            {
                PartTimeEmployee pte = new PartTimeEmployee();
                pte.Id         = Convert.ToInt32(this.txtId.Text);
                pte.Name       = Convert.ToString(this.txtName.Text);
                pte.StartDate  = Convert.ToDateTime(this.txtDate.Text);
                pte.HourlyRate = Convert.ToInt32(this.txtRate);
                cliente.UpdateEmployee(pte);
            }
            //Editamos los datos de un empleado ya existente (menos el ID)
            //Primero buscamos el empleado en la bd, lo traemos como shared entities (? (todavia no termine de entender :S)

            /*
             * if (Convert.ToInt32(txtType) == 1) //si es full --ACA ME TIRA UNA EXCEPCION AL EDITAR POR UN PROBLEMA CON LA CONVERSION / COMPARACION (tal vez con int.tryparse)
             * {
             *  Shared.Entities.FullTimeEmployee ftEmp = new FullTimeEmployee();
             *  DateTime txtToDate = DateTime.Parse(txtDate.Text);
             *  ftEmp.Name = Convert.ToString(txtName);
             *  ftEmp.StartDate = (txtToDate);
             *  //ftEmp.Salary tiene que mantener el valor que ya tenia, o se vuelve a calcular, ya que el empleado podria cambiar de tipo (?
             * //Luego de setear los valores, tengo que guardar el nuevo empleado (shEmp) en la base
             * //Como se hace esto? No se, no estudie maestra.
             *
             * }
             * else
             * {
             *  Shared.Entities.PartTimeEmployee ptEmp = new PartTimeEmployee();
             *  DateTime txtToDate = DateTime.Parse(txtDate.Text);
             *  ptEmp.Name = Convert.ToString(txtName);
             *  ptEmp.StartDate = (txtToDate);
             *  //Luego de setear los valores, tengo que guardar el nuevo empleado (shEmp) en la base
             * }
             */
        }
Esempio n. 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            //BLEmployees businessLayer = new BLEmployees(new DALEmployeesEF());
            ServiceEmployeesClient client = new ServiceEmployeesClient();

            if (emp.GetType() == typeof(PartTimeEmployee))
            {
                PartTimeEmployee pte = new PartTimeEmployee();
                pte.Name       = textBox1.Text;
                pte.StartDate  = DateTime.Now;
                pte.HourlyRate = Double.Parse(textBox3.Text);
                client.UpdateEmployee(pte);
            }
            else
            {
                FullTimeEmployee fte = new FullTimeEmployee();
                fte.Name      = textBox1.Text;
                fte.StartDate = DateTime.Now;
                fte.Salary    = Int32.Parse(textBox4.Text);
                client.UpdateEmployee(fte);
            }
        }