Ejemplo n.º 1
0
        //no entiendo por que me pone button1 al nombre del metodo, si en las propiedades le puse que se llamara edit :S
        //PD: ESTE METODO QUE ES EL QUE CREARIA EL OBJETO PARA SETEARLO EN LA BD, Y EL CODIGO QUE ESTA COMENTADO EN EMPLOEYEE LIST, EL OTRO FORMULARIO,
        //EVIDENTEMENTE ES TODO FRUTA, CREO QUE LA IDEA VIENE POR AHI PERO HAY QUE METERLE, EN ESPECIAL A TODO LO QUE TIENE QUE VER LEVANTAR DATOS DE LA BD
        //Y LLAMAR A LOS METODOS, DE AHI EN ADELANTE CAGUE..
        //DE TODOS MODOS EL FUNCIONAMIENTO DE LOS FORMULARIOS QUEDO PRONTO, HACE LO QUE TIENE QUE HACER CON LOS DATOS DE PRUEBA.
        private void button1_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.AddEmployee(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.AddEmployee(pte);
            }

            MessageBox.Show("Empleado creado con éxito cabrón, a tomar por culo!");
        }
Ejemplo n.º 2
0
        public ActionResult Create(Model emp)
        {
            try
            {
                // TODO: Add insert logic here
                ServiceEmployeesClient client = new ServiceEmployeesClient();

                string name = emp.Name;

                if (emp.isFullTime)
                {
                    FullTimeEmployee e = new FullTimeEmployee();
                    e.Name      = name;
                    e.StartDate = DateTime.Now;
                    e.Salary    = emp.Salary;
                    client.AddEmployee(e);
                }
                else
                {
                    PartTimeEmployee e = new PartTimeEmployee();
                    e.Name       = name;
                    e.StartDate  = DateTime.Now;
                    e.HourlyRate = emp.Hourly;
                    client.AddEmployee(e);
                }

                return(Json(new { success = true, responseText = "User correct!" }, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Home");
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: '{0}'", e);
                return(Json(new { success = false, responseText = "User wrong!" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            //BLEmployees businessLayer = new BLEmployees(new DALEmployeesEF());
            ServiceEmployeesClient client = new ServiceEmployeesClient();

            if (radioButton1.Checked)
            {
                PartTimeEmployee employee = new PartTimeEmployee();
                employee.Name       = textBox1.Text;
                employee.StartDate  = DateTime.Now;
                employee.Id         = client.GetAllEmployees().Count() + 1;
                employee.HourlyRate = Int32.Parse(textBox3.Text);
                client.AddEmployee(employee);
            }
            else
            {
                FullTimeEmployee employee = new FullTimeEmployee();
                employee.Name      = textBox1.Text;
                employee.StartDate = DateTime.Now;
                employee.Id        = client.GetAllEmployees().Count() + 1;
                employee.Salary    = Int32.Parse(textBox4.Text);
                client.AddEmployee(employee);
            }
        }