Exemplo n.º 1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Controlador c = new Controlador();

            if (Form1.tipo_e == "FullTimeEmployee")
            {
                Shared.Entities.FullTimeEmployee flte = new Shared.Entities.FullTimeEmployee()
                {
                    Id        = Form1.id_e,
                    Name      = Name.Text,
                    StartDate = date.Value,
                    Salary    = Int32.Parse(atr.Text)
                };
                c.UpdateEmployee(flte);
            }
            else
            {
                Shared.Entities.PartTimeEmployee flte = new Shared.Entities.PartTimeEmployee()
                {
                    Id         = Form1.id_e,
                    Name       = Name.Text,
                    StartDate  = date.Value,
                    HourlyRate = Int32.Parse(atr.Text)
                };
                c.UpdateEmployee(flte);
            }
            this.Close();
        }
Exemplo n.º 2
0
        public void AddFullTimeEmployee(Shared.Entities.FullTimeEmployee emp)
        {
            var    db  = new Model.Practico1TSIEntities();
            String sql = "INSERT INTO EmployeesTPH VALUES(" +
                         emp.Id + ",'" + emp.Name + "','" + emp.StartDate + "'," + emp.Salary + "," + null + ",1)";

            db.Database.ExecuteSqlCommand(sql);
        }
Exemplo n.º 3
0
        public void UpdateFullTimeEmployee(Shared.Entities.FullTimeEmployee emp)
        {
            var    db  = new Model.Practico1TSIEntities();
            string sql = "UPDATE EmployeeTPH SET " +
                         "  NAME = '" + emp.Name + "'" +
                         ", START_DATE = '" + emp.StartDate + "'" +
                         ", SALARY = " + emp.Salary +
                         ", RATE = null " +
                         ", TYPE = 2 " +
                         " WHERE ID = " + emp.Id;

            db.Database.ExecuteSqlCommand(sql);
        }
Exemplo n.º 4
0
        public void AddFullTimeEmployee(Shared.Entities.FullTimeEmployee emp)
        {
            var bd = new Model.Practico1TSIEntities();
            var t  = new Model.FullTimeEmployee();


            t.Name       = emp.Name;
            t.EmployeeID = emp.Id;
            t.StartDate  = emp.StartDate;
            t.Salary     = (Int16)emp.Salary;
            bd.EmployeesTPH.Add(t);
            bd.SaveChanges();
        }
Exemplo n.º 5
0
        private void ButtonModificar_Click(object sender, EventArgs e)
        {
            String nombre = textNombre.Text, tipo = comboTipo.Text;

            Shared.Entities.Employee nuevoEmp;

            if (nombre.Equals("") || tipo.Equals("") || textId.Text.Equals("") || textSalario.Text.Equals(""))
            {
                labelMensaje.Text = "Faltan datos";
            }
            else
            {
                try
                {
                    int id = int.Parse(textId.Text), salario = int.Parse(textSalario.Text);
                    if (tipo.Equals("Jornalero"))
                    {
                        nuevoEmp = new Shared.Entities.PartTimeEmployee()
                        {
                            Id         = id,
                            HourlyRate = salario,
                            Name       = nombre,
                            StartDate  = new DateTime()
                        };
                    }
                    else
                    {
                        nuevoEmp = new Shared.Entities.FullTimeEmployee()
                        {
                            Id        = id,
                            Salary    = salario,
                            Name      = nombre,
                            StartDate = new DateTime()
                        };
                    }
                    IEmp.UpdateEmployee(nuevoEmp);
                    this.Button1_Click(sender, e);
                }
                catch (Shared.Exception.EntidadDuplicada ex)
                {
                    labelMensaje.Text = ex.Message;
                }
            }
            textId.Text             = "";
            textNombre.Text         = "";
            textSalario.Text        = "";
            comboTipo.Text          = "";
            buttonAgregar.Visible   = true;
            buttonCancelar.Visible  = false;
            buttonModificar.Visible = false;
        }
Exemplo n.º 6
0
        public Shared.Entities.FullTimeEmployee GetFullTimeEmployee(int id)
        {
            var db = new Practico1TSIEntities();

            Model.FullTimeEmployee objEmp = db.EmployeesTPH.OfType <Model.FullTimeEmployee>().Where(e => e.EmployeeID == id).FirstOrDefault();

            var retorno = new Shared.Entities.FullTimeEmployee();

            retorno.Id        = objEmp.EmployeeID;
            retorno.Name      = objEmp.Name;
            retorno.StartDate = objEmp.StartDate;
            retorno.Salary    = objEmp.Salary;
            return(retorno);
        }
Exemplo n.º 7
0
        public void UpdateFullTimeEmployee(Shared.Entities.FullTimeEmployee emp)
        {
            var db     = new Model.Practico1TSIEntities();
            var objEmp = db.EmployeesTPH.Find(emp.Id);

            Model.FullTimeEmployee empF = new Model.FullTimeEmployee();
            empF.EmployeeID = emp.Id;
            empF.Name       = emp.Name;
            empF.StartDate  = emp.StartDate;
            empF.Salary     = (short)emp.Salary;

            db.EmployeesTPH.Remove(objEmp);
            db.EmployeesTPH.Add(empF);
            db.SaveChanges();
        }
Exemplo n.º 8
0
        public List <Employee> GetAllEmployees()
        {
            Console.WriteLine("Entre a listar Empleados de DataAcces");
            //creo lista vacia de tipo shared para retornar
            List <Employee> empList = new List <Employee>();

            var db = new Practico1TSIEntities();
            List <Model.PartTimeEmployee> empQuery = db.EmployeesTPH.OfType <Model.PartTimeEmployee>().ToList();

            Console.WriteLine("Me conecte a la base");


            foreach (var emp in empQuery)
            {
                Console.WriteLine("Entre al Foreach");
                var objEmp = new Shared.Entities.PartTimeEmployee();
                objEmp.Id         = emp.EmployeeID;
                objEmp.Name       = emp.Name;
                objEmp.StartDate  = emp.StartDate;
                objEmp.HourlyRate = emp.HourlyRate;
                empList.Add(objEmp);
            }

            var empQueryF = from empF in db.EmployeesTPH.OfType <Model.FullTimeEmployee>()
                            select empF;

            foreach (var empF in empQueryF)
            {
                var objEmp2 = new Shared.Entities.FullTimeEmployee();
                objEmp2.Id        = empF.EmployeeID;
                objEmp2.Name      = empF.Name;
                objEmp2.StartDate = empF.StartDate;
                objEmp2.Salary    = empF.Salary;
                empList.Add(objEmp2);
            }
            return(empList);
        }
Exemplo n.º 9
0
        private void datos()
        {
            Controlador c       = new Controlador();
            Employee    empEdit = c.GetEmployee(Form1.id_e);

            if (empEdit.GetType().Name == "FullTimeEmployee")
            {
                Atributo.Text = "Salary:";
                Shared.Entities.FullTimeEmployee edit = (Shared.Entities.FullTimeEmployee)empEdit;
                Name.Text  = edit.Name;
                date.Value = edit.StartDate;
                atr.Text   = edit.Salary.ToString();
                Tipo.Text  = "FullTimeEmployee";
            }
            else
            {
                Atributo.Text = "Hourly Rate:";
                Shared.Entities.PartTimeEmployee edit = (Shared.Entities.PartTimeEmployee)empEdit;
                Name.Text  = edit.Name;
                date.Value = edit.StartDate;
                atr.Text   = edit.HourlyRate.ToString();
                Tipo.Text  = "PartTimeEmployee";
            }
        }
Exemplo n.º 10
0
 private void ListView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (ListViewItem itemSeleccionado in listView1.SelectedItems)
     {
         Shared.Entities.Employee emp = IEmp.GetEmployee(int.Parse(itemSeleccionado.Text));
         textId.Text     = emp.Id.ToString();
         textNombre.Text = emp.Name;
         if (emp.GetType() == typeof(Shared.Entities.FullTimeEmployee))
         {
             Shared.Entities.FullTimeEmployee empFull = (Shared.Entities.FullTimeEmployee)emp;
             textSalario.Text = empFull.Salary.ToString();
             comboTipo.Text   = "Mensual";
         }
         else
         {
             Shared.Entities.PartTimeEmployee empPart = (Shared.Entities.PartTimeEmployee)emp;
             textSalario.Text = empPart.HourlyRate.ToString();
             comboTipo.Text   = "Jornalero";
         }
     }
     buttonAgregar.Visible   = false;
     buttonCancelar.Visible  = true;
     buttonModificar.Visible = true;
 }