Пример #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();
        }
Пример #2
0
        public void AddPartTimeEmployee(Shared.Entities.PartTimeEmployee emp)
        {
            var    db  = new Model.Practico1TSIEntities();
            String sql = "INSERT INTO EmployeesTPH VALUES(" +
                         emp.Id + ",'" + emp.Name + "','" + emp.StartDate + "'," + null + "," + emp.HourlyRate + ")";

            db.Database.ExecuteSqlCommand(sql);
        }
Пример #3
0
        public Shared.Entities.PartTimeEmployee GetPartTimeEmployee(int id)
        {
            var db = new Practico1TSIEntities();

            Model.PartTimeEmployee           objEmp = db.EmployeesTPH.OfType <Model.PartTimeEmployee>().Where(e => e.EmployeeID == id).FirstOrDefault();
            Shared.Entities.PartTimeEmployee emp    = new Shared.Entities.PartTimeEmployee();
            emp.Id         = objEmp.EmployeeID;
            emp.Name       = objEmp.Name;
            emp.StartDate  = objEmp.StartDate;
            emp.HourlyRate = objEmp.HourlyRate;
            return(emp);
        }
Пример #4
0
        public void AddPartTimeEmployee(Shared.Entities.PartTimeEmployee emp)
        {
            var context = new Practico1TSIEntities();
            var t       = new Model.PartTimeEmployee();

            t.Name = emp.Name;
            //t.EmployeeID = emp.Id;
            t.StartDate  = emp.StartDate;
            t.HourlyRate = emp.HourlyRate;
            context.EmployeesTPH.Add(t);
            context.SaveChanges();
        }
Пример #5
0
        public void UpdatePartTimeEmployee(Shared.Entities.PartTimeEmployee emp)
        {
            var    db  = new Model.Practico1TSIEntities();
            string sql = "UPDATE EmployeeTPH SET " +
                         "  NAME = '" + emp.Name + "'" +
                         ", START_DATE = '" + emp.StartDate + "'" +
                         ", SALARY = null " +
                         ", RATE = " + emp.HourlyRate +
                         ", TYPE = 1 " +
                         " WHERE ID = " + emp.Id;

            db.Database.ExecuteSqlCommand(sql);
        }
Пример #6
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;
        }
Пример #7
0
        public void UpdatePartTimeEmployee(Shared.Entities.PartTimeEmployee emp)
        {
            var db     = new Model.Practico1TSIEntities();
            var objEmp = db.EmployeesTPH.Find(emp.Id);

            Model.PartTimeEmployee empF = new Model.PartTimeEmployee();
            empF.EmployeeID = emp.Id;
            empF.Name       = emp.Name;
            empF.StartDate  = emp.StartDate;
            empF.HourlyRate = emp.HourlyRate;

            db.EmployeesTPH.Remove(objEmp);
            db.EmployeesTPH.Add(empF);
            db.SaveChanges();
        }
Пример #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);
        }
Пример #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";
            }
        }
Пример #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;
 }