Esempio n. 1
0
 public DsiHeader CreateReply(Afp.Protocol.AfpResultCode resultCode, uint resultPayloadLength)
 {
     DsiHeader newHeader = this;
     newHeader.flags = DsiFlags.Reply;
     newHeader.errorCodeOrWriteOffset = (uint)resultCode;
     newHeader.totalDataLength = resultPayloadLength;
     return newHeader;
 }
 public ActionResult Edit([Bind(Include = "Afp_Id,Afp_Nom,Afp_Registro")] Afp afp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(afp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(afp));
 }
        public ActionResult Create([Bind(Include = "Afp_Id,Afp_Nom,Afp_Registro")] Afp afp)
        {
            if (ModelState.IsValid)
            {
                db.Tb_Afp.Add(afp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(afp));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Afp afp = db.Tb_Afp.Find(id);

            if (afp == null)
            {
                return(HttpNotFound());
            }
            return(View(afp));
        }
Esempio n. 5
0
        private static string Format(Afp a)
        {
            string s = "[" + a.GetType().Name + "]";

            if (a.list == null)
            {
                return(s + " null");
            }
            s += " " + a.list.Count;
            foreach (var b in a.list)
            {
                s += "\n\t" + Format(b);
            }
            return(s);
        }
Esempio n. 6
0
 public ActionResult Grab_AFP(Afp afp)
 {
     try  {
         using (var ManAfp = new EmpleadosEntities())
         {
             var GrabaAfp = ManAfp.Sp_Ins_Afp(afp.Nom_Afp, afp.Porc_Desc);
             return(Json(GrabaAfp));
         }
     } catch (Exception ex) {
         Logger.Error("Error On:", ex);
         Response.StatusCode        = 500;
         Response.StatusDescription = ex.Message;
         return(Json(Response));
     }
 }
Esempio n. 7
0
        private static void Deserialize(byte[] b, TextWriter dest)
        {
            MemoryStream mspp = new MemoryStream(b);
            MemoryStream mspf = new MemoryStream(b);
            MemoryStream msfp = new MemoryStream(b);
            MemoryStream msff = new MemoryStream(b);
            App          app  = Serializer.Deserialize <App>(mspp);
            Apf          apf  = Serializer.Deserialize <Apf>(mspf);
            Afp          afp  = Serializer.Deserialize <Afp>(msfp);
            Aff          aff  = Serializer.Deserialize <Aff>(msff);

            dest.WriteLine(Format(app));
            dest.WriteLine(Format(apf));
            dest.WriteLine(Format(afp));
            dest.WriteLine(Format(aff));
        }
Esempio n. 8
0
        public static void Deserialize(TypeModel model, byte[] b, TextWriter dest)
        {
            MemoryStream mspp = new MemoryStream(b);
            MemoryStream mspf = new MemoryStream(b);
            MemoryStream msfp = new MemoryStream(b);
            MemoryStream msff = new MemoryStream(b);
            App          app  = model.Deserialize <App>(mspp);
            Apf          apf  = model.Deserialize <Apf>(mspf);
            Afp          afp  = model.Deserialize <Afp>(msfp);
            Aff          aff  = model.Deserialize <Aff>(msff);

            dest.WriteLine(Format(app));
            dest.WriteLine(Format(apf));
            dest.WriteLine(Format(afp));
            dest.WriteLine(Format(aff));
        }
Esempio n. 9
0
 public ActionResult ModAFP(Afp afp)
 {
     try
     {
         using (var ManAfp = new EmpleadosEntities())
         {
             var ActAfp = ManAfp.Sp_UPD_Afp(afp.Cod_Afp, afp.Nom_Afp, afp.Porc_Desc);
         }
         return(RedirectToAction("Index"));
     }  catch (Exception ex) {
         Logger.Error("Error On:", ex);
         Response.StatusCode        = 500;
         Response.StatusDescription = ex.Message;
         return(Json(Response));
     }
 }
Esempio n. 10
0
        public Afp BuscarDatosDelAfp_PorCodigo(int codigo)
        {
            Afp    afp         = null;
            string consultaSQL = "select * from AFP where idAfp = '" + codigo + "'";

            try
            {
                SqlDataReader resultadoSQL = gestorSQL.EjecutarConsulta(consultaSQL);
                if (resultadoSQL.Read())
                {
                    afp = ObtenerDatosAfp(resultadoSQL);
                }
                else
                {
                    MessageBox.Show("No existe el AFP.");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error al buscar datos del AFP" + e);
                throw;
            }
            return(afp);
        }
Esempio n. 11
0
        private bool mostrarContrato()
        {
            GestionarContratos servicio = new GestionarContratos();

            contrato = servicio.MostrarContratos(int.Parse(textIDResultado.Text.Trim()));
            if (contrato != null)
            {
                auxIdContrato = contrato.Id_contrato;
                Afp afp = servicio.BuscarAFPCodigo(contrato.Afp.Id_afp);
                if (afp != null)
                {
                    cbAFP.Text            = afp.Nombre;
                    TextCargo.Text        = contrato.Cargo;
                    fechaInicio.Value     = contrato.FechaInicio;
                    fechaFinal.Value      = contrato.FechaFin;
                    textTotalDeHoras.Text = contrato.HorasContratadasPorSemana.ToString();
                    textValorHora.Text    = contrato.ValorHora.ToString();
                    AsignacionSI.Checked  = contrato.AsignacionFamiliar;
                    AsignacionNO.Checked  = !contrato.AsignacionFamiliar;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 12
0
        public void Execute()
        {
            //Test Data
            App app = new App();
            Apf apf = new Apf();
            Afp afp = new Afp();
            Aff aff = new Aff();
            Bp  bp1 = new Bp()
            {
                a = "b1"
            };
            Bp bp2 = new Bp()
            {
                a = "b2"
            };
            Bf bf1 = new Bf()
            {
                a = "b1"
            };
            Bf bf2 = new Bf()
            {
                a = "b2"
            };

            bp1.b = new List <string>();
            bp2.b = new List <string>();
            bf1.b = new List <string>();
            bf2.b = new List <string>();
            bp1.b.Add("a");
            bp2.b.Add("b");
            bf1.b.Add("a");
            bf2.b.Add("b");
            app.list.Add(bp1);
            app.list.Add(bp2);
            apf.list.Add(bf1);
            apf.list.Add(bf2);
            afp.list.Add(bp1);
            afp.list.Add(bp2);
            aff.list.Add(bf1);
            aff.list.Add(bf2);

            using StringWriter before = new StringWriter();
            before.WriteLine(Format(app));
            before.WriteLine(Format(apf));
            before.WriteLine(Format(afp));
            before.WriteLine(Format(aff));

            //Serialize
            MemoryStream mspp = new MemoryStream();
            MemoryStream mspf = new MemoryStream();
            MemoryStream msfp = new MemoryStream();
            MemoryStream msff = new MemoryStream();

            Serializer.Serialize(mspp, app);
            Serializer.Serialize(mspf, apf);
            Serializer.Serialize(msfp, afp);
            Serializer.Serialize(msff, aff);

            //Compare binary data
            byte[] bpp = mspp.ToArray();
            byte[] bpf = mspf.ToArray();
            byte[] bfp = msfp.ToArray();
            byte[] bff = msff.ToArray();

            Assert.Equal(18, bpp.Length);

            if (bpp.Length != bpf.Length)
            {
                throw new InvalidDataException("Length does not match");
            }
            if (bpf.Length != bff.Length)
            {
                throw new InvalidDataException("Length does not match");
            }
            if (bff.Length != bfp.Length)
            {
                throw new InvalidDataException("Length does not match");
            }
            for (int n = 0; n < bpp.Length; n++)
            {
                if (bpp[n] != bpf[n] || bpf[n] != bff[n] || bff[n] != bfp[n])
                {
                    throw new InvalidDataException("Data does not match");
                }
            }

            //Deserialize
            StringWriter after = new StringWriter();

            Deserialize(bpp, after);

            Assert.Equal(before.ToString(), after.ToString());
        }
Esempio n. 13
0
        public void Execute()
        {
            //Test Data
            App app = new App();
            Apf apf = new Apf();
            Afp afp = new Afp();
            Aff aff = new Aff();
            Bp bp1 = new Bp() { a = "b1" };
            Bp bp2 = new Bp() { a = "b2" };
            Bf bf1 = new Bf() { a = "b1" };
            Bf bf2 = new Bf() { a = "b2" };
            bp1.b = new List<string>();
            bp2.b = new List<string>();
            bf1.b = new List<string>();
            bf2.b = new List<string>();
            bp1.b.Add("a");
            bp2.b.Add("b");
            bf1.b.Add("a");
            bf2.b.Add("b");
            app.list.Add(bp1);
            app.list.Add(bp2);
            apf.list.Add(bf1);
            apf.list.Add(bf2);
            afp.list.Add(bp1);
            afp.list.Add(bp2);
            aff.list.Add(bf1);
            aff.list.Add(bf2);

            StringWriter before = new StringWriter();
            before.WriteLine(Format(app));
            before.WriteLine(Format(apf));
            before.WriteLine(Format(afp));
            before.WriteLine(Format(aff));

            //Serialize
            MemoryStream mspp = new MemoryStream();
            MemoryStream mspf = new MemoryStream();
            MemoryStream msfp = new MemoryStream();
            MemoryStream msff = new MemoryStream();
            Serializer.Serialize(mspp, app);
            Serializer.Serialize(mspf, apf);
            Serializer.Serialize(msfp, afp);
            Serializer.Serialize(msff, aff);

            //Compare binary data
            byte[] bpp = mspp.ToArray();
            byte[] bpf = mspf.ToArray();
            byte[] bfp = msfp.ToArray();
            byte[] bff = msff.ToArray();

            Assert.AreEqual(18, bpp.Length);

            if (bpp.Length != bpf.Length)
                throw new InvalidDataException("Length does not match");
            if (bpf.Length != bff.Length)
                throw new InvalidDataException("Length does not match");
            if (bff.Length != bfp.Length)
                throw new InvalidDataException("Length does not match");
            for (int n = 0; n < bpp.Length; n++)
            {
                if (bpp[n] != bpf[n] || bpf[n] != bff[n] || bff[n] != bfp[n])
                    throw new InvalidDataException("Data does not match");
            }

            //Deserialize
            StringWriter after = new StringWriter();
            Deserialize(bpp, after);

            Assert.AreEqual(before.ToString(), after.ToString());

        }
Esempio n. 14
0
 private static string Format(Afp a)
 {
     string s = "[" + a.GetType().Name + "]";
     if (a.list == null)
         return s + " null";
     s += " " + a.list.Count;
     foreach (var b in a.list)
         s += "\n\t" + Format(b);
     return s;
 }
Esempio n. 15
0
        private void btnGuardarContrato_Click(object sender, EventArgs e)
        {
            GestionarContratos servicio = new GestionarContratos();

            Contrato nuevoContrato = new Contrato();

            nuevoContrato.Id_contrato        = auxIdContrato;
            nuevoContrato.AsignacionFamiliar = AsignacionSI.Checked;


            try
            {
                nuevoContrato.Cargo       = TextCargo.Text.Trim();
                nuevoContrato.FechaInicio = fechaInicio.Value.Date;
                nuevoContrato.FechaFin    = fechaFinal.Value.Date;
                nuevoContrato.HorasContratadasPorSemana = int.Parse(textTotalDeHoras.Text.Trim());
                nuevoContrato.ValorHora = int.Parse(textValorHora.Text.Trim());
                nuevoContrato.Estado    = true;
                Afp afp = servicio.BuscarAFP(cbAFP.Text.Trim());
                if (afp != null)
                {
                    nuevoContrato.Afp = afp;

                    Empleado empleadoContrato = servicio.BuscarEmpleado(textDniBuscar.Text.Trim());
                    if (empleadoContrato != null)
                    {
                        nuevoContrato.Empleado = empleadoContrato;
                    }
                }
            }
            catch (Exception)
            {
                showError("Campos invalidos");
                return;
            }
            if (!nuevoContrato.ValidarVigenciaContrato())
            {
                showError("Contrato no vigente");
                return;
            }
            if (!nuevoContrato.ValidarFechaInicioContrato())
            {
                showError("El contrato anterior es aún vigente");
                return;
            }
            if (!nuevoContrato.ValidarFechaFinContrato())
            {
                showError("Fecha final no valida");
                return;
            }
            if (!nuevoContrato.ValidarHoras())
            {
                showError("El valor de horas por semana no es válido");
                return;
            }
            if (!nuevoContrato.ValidarValorHoras())
            {
                showError("El valor de hora no es válido");
                return;
            }


            try
            {
                if (EDITAR)
                {
                    servicio.EditarContratos(nuevoContrato, int.Parse(textIDResultado.Text.Trim()));
                }
                else
                {
                    servicio.GuardarContratos(nuevoContrato);
                    Contrato contratoInsertado     = servicio.MostrarContratos(empleado.Id_empleado);
                    Periodo  periodo               = servicio.GetPeriodoActivo();
                    bool     insertPeriodoContrato = servicio.InsertarContratoPeriodo(contratoInsertado.Id_contrato, periodo.Id_periodo);
                    if (insertPeriodoContrato)
                    {
                        MessageBox.Show("Periodo_Contrato Insertado");
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(this, err.Message, "Sistema NominaSoft", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            configuracionInternaDeDatosContrato();
            btnCrearContrato.Enabled  = true;
            btnAnularContrato.Enabled = true;
            btnEditarContrato.Enabled = true;
        }