protected void bot_guardar_adm_Click(object sender, EventArgs e)
 {
     PERSONAL p = new PERSONAL();
     p.RUT_PER = Convert.ToDecimal(rut_admin.Text);
     p.NOMBRE_PER = nom_admin.Text;
     p.APPAT_PER = pat_admin.Text;
     p.APMAT_PER = mat_admin.Text;
     p.ACTIVO = "1";
     p.ID_TIPO_FUNCIONARIO =Convert.ToInt32(listado_categoria.SelectedValue);
     p.DIRECCION_PER = dir_admin.Text;
     p.TELEFONO_PER = tel_admin.Text;
     p.EMAIL_PER = email_admin.Text;
     
     int  newPersonal = NegocioAdministrador.instancia.CrearPersonal(p);
     if (newPersonal == 1)
     {
         Response.Write("<script language=javascript>alert('Los datos han sido guardados exitosamente');</script>");
         rut_admin.Text = "";
         nom_admin.Text = "";
         pat_admin.Text = "";
         mat_admin.Text = "";
         rut_admin.Text = "";
         nom_admin.Text = "";
         pat_admin.Text = "";
         mat_admin.Text = "";
         dir_admin.Text = "";
         tel_admin.Text = "";
         email_admin.Text = "";
     }
     else
         Response.Write("<script language=javascript>alert('Datos no guardados');</script>");
 
 }
        public int CrearPersonal(PERSONAL dto,int tipo)
        {
            if(tipo==1)
                dto.PASSWORD_PER = GeneraMd5.instancia.md5(dto.RUT_PER.ToString().Substring(0,5));

            return DaoPersonal.instancia.CrearPersonal(dto,tipo);
        }
 public int buscarInspector(String rut)
 {
     using (SRI con = new SRI())
     {
         PERSONAL pe = new PERSONAL();
         pe = con.PERSONAL.Where(p => p.RUT_PER == rut).FirstOrDefault();
         return (int)pe.ID_PERSONAL;
     }
 }
Esempio n. 4
0
 public int CrearPersonal(PERSONAL dto)
 {
     try
     {
         using (SRI sri = new SRI())
         {
             dto.ID_PERSONAL =retornarNuevoId();
             sri.PERSONAL.AddObject(dto);
             sri.SaveChanges();
             return 1;
         }
     }
     catch (Exception e)
     {
         return 0;
     }
 }
        public int actualizaClavePropia(String newClave, String rut)
        {
            using (SRI contex = new SRI())
            {
                try
                {
                    PERSONAL lista = new PERSONAL();
                    lista = contex.PERSONAL.Where(a => a.RUT_PER == rut).FirstOrDefault();
                    lista.PASSWORD_PER = newClave;
                    contex.SaveChanges();
                    return 1;
                }
                catch (Exception e)
                {
                    return 0;
                }

            }
        }
Esempio n. 6
0
        public int ReiniciarClave(String clave, int id)
        {
            try
            {
                PERSONAL per = new PERSONAL();
                using (SRI contex = new SRI())
                {
                    per = contex.PERSONAL.Where(p => p.ID_PERSONAL == id).FirstOrDefault();
                    per.PASSWORD_PER = clave;
                    contex.SaveChanges();
                    return 1;
                }

            }
            catch (Exception e)
            {
                return 0;
            }
        }
        public int actualizaDatosPersonales(String email, String telefono, String rut)
        {
            using (SRI contex = new SRI())
            {
                try
                {
                    PERSONAL objInfractor = new PERSONAL();
                    objInfractor = contex.PERSONAL.Where(a => a.RUT_PER == rut).FirstOrDefault();
                    objInfractor.EMAIL_PER = email;
                    objInfractor.TELEFONO_PER = telefono;
                    contex.SaveChanges();
                    return 1;
                }
                catch (Exception e)
                {
                    return 0;
                }

            }
        }
Esempio n. 8
0
 public int CrearPersonal(PERSONAL dto,int tipo)
 {
     try
     {
         using (SRI sri = new SRI())
         {
             if (!existeRut(dto.RUT_PER.ToString()) && tipo ==2)
             {
                 PERSONAL per = new PERSONAL();
                 per = sri.PERSONAL.Where(a => a.RUT_PER == dto.RUT_PER).FirstOrDefault();
                 per.RUT_PER = dto.RUT_PER;
                 per.NOMBRE_PER = dto.NOMBRE_PER;
                 per.ACTIVO = dto.ACTIVO;
                 per.APMAT_PER = dto.APMAT_PER;
                 per.APPAT_PER = dto.APPAT_PER;
                 per.TELEFONO_PER = dto.TELEFONO_PER;
                 per.DIRECCION_PER = dto.DIRECCION_PER;
                 per.EMAIL_PER = per.EMAIL_PER;
                 per.ID_TIPO_FUNCIONARIO = dto.ID_TIPO_FUNCIONARIO;
                 sri.SaveChanges();
                 return 2;
             }
             else
             {
                 if (tipo == 1)
                 {
                     dto.ID_PERSONAL = retornarNuevoId();
                     sri.PERSONAL.AddObject(dto);
                     sri.SaveChanges();
                     return 1;
                 }
                 else
                     return 0;
             }
         }
     }
     catch (Exception e)
     {
         return 0;
     }
 }
 /// <summary>
 /// Método desusado para agregar un nuevo objeto al EntitySet PERSONAL. Considere la posibilidad de usar el método .Add de la propiedad ObjectSet&lt;T&gt; asociada.
 /// </summary>
 public void AddToPERSONAL(PERSONAL pERSONAL)
 {
     base.AddObject("PERSONAL", pERSONAL);
 }
 /// <summary>
 /// Crear un nuevo objeto PERSONAL.
 /// </summary>
 /// <param name="iD_PERSONAL">Valor inicial de la propiedad ID_PERSONAL.</param>
 /// <param name="nOMBRE_PER">Valor inicial de la propiedad NOMBRE_PER.</param>
 /// <param name="aPPAT_PER">Valor inicial de la propiedad APPAT_PER.</param>
 /// <param name="aPMAT_PER">Valor inicial de la propiedad APMAT_PER.</param>
 /// <param name="pASSWORD_PER">Valor inicial de la propiedad PASSWORD_PER.</param>
 /// <param name="iD_TIPO_FUNCIONARIO">Valor inicial de la propiedad ID_TIPO_FUNCIONARIO.</param>
 public static PERSONAL CreatePERSONAL(global::System.Decimal iD_PERSONAL, global::System.String nOMBRE_PER, global::System.String aPPAT_PER, global::System.String aPMAT_PER, global::System.String pASSWORD_PER, global::System.Decimal iD_TIPO_FUNCIONARIO)
 {
     PERSONAL pERSONAL = new PERSONAL();
     pERSONAL.ID_PERSONAL = iD_PERSONAL;
     pERSONAL.NOMBRE_PER = nOMBRE_PER;
     pERSONAL.APPAT_PER = aPPAT_PER;
     pERSONAL.APMAT_PER = aPMAT_PER;
     pERSONAL.PASSWORD_PER = pASSWORD_PER;
     pERSONAL.ID_TIPO_FUNCIONARIO = iD_TIPO_FUNCIONARIO;
     return pERSONAL;
 }
        protected void btnGuardarAU_Click(object sender, EventArgs e)
        {
            if (ValidaRut.instancia.VerificaRut(txtRutAU.Text))
            {
                if (NegocioAdministrador.instancia.existeRut2(txtRutAU.Text))
                {

                    PERSONAL p = new PERSONAL();
                    p.RUT_PER = txtRutAU.Text;
                    p.NOMBRE_PER = txtNomAU.Text;
                    p.APPAT_PER = txtAppatAU.Text;
                    p.APMAT_PER = txtApmatAU.Text;
                    p.DIRECCION_PER = txtDireccion.Text;
                    p.TELEFONO_PER = txtTelefono.Text;
                    p.EMAIL_PER = txtEmail.Text;
                    p.ID_TIPO_FUNCIONARIO = Convert.ToDecimal(ddlistCategoria.SelectedValue);

                    if (chkActivoAU.Checked)
                        p.ACTIVO = "1";
                    else
                        p.ACTIVO = "0";

                    p.ID_TIPO_FUNCIONARIO = Convert.ToDecimal(ddlistCategoria.SelectedValue);

                    int newPersonal = NegocioAdministrador.instancia.CrearPersonal(p, 1);
                    if (newPersonal == 1)
                    {
                        txtRutAU.Text = "";
                        txtNomAU.Text = "";
                        txtAppatAU.Text = "";
                        txtApmatAU.Text = "";
                        txtDireccion.Text = "";
                        txtTelefono.Text = "";
                        txtEmail.Text = "";
                        chkActivoAU.Checked = true;
                        ddlistCategoria.SelectedIndex = 0;
                        lblInfoAU.Text = "Los Datos han sido guardados exitosamente";
                        lblInfoAU.Visible = true;
                        lblInfoAU.ForeColor = System.Drawing.Color.Gray;


                    }
                    else

                        lblInfoAU.Text = "Los Datos no han sido guardados";
                    lblInfoAU.Visible = true;
                    lblInfoAU.ForeColor = System.Drawing.Color.Red;

                }
                else
                    lblInfoAU.Text = "El Usuario ya existe";
            }
            else
            {
                int n = 0;
                if (txtRutAU.Text == "" || txtRutAU.Text == null)
                {
                    txtRutAU.BorderColor = System.Drawing.Color.Red;
                    txtRutAU.BorderWidth = 1;
                    n = 1;
                }
                else
                {
                    txtRutAU.BorderColor = System.Drawing.Color.LightGray;
                    txtRutAU.BorderWidth = 1;
                    n = 0;
                }

                if (txtNomAU.Text == "" || txtNomAU.Text == null)
                {
                    txtNomAU.BorderColor = System.Drawing.Color.Red;
                    txtNomAU.BorderWidth = 1;
                    n = 1;
                }
                else
                {
                    txtNomAU.BorderColor = System.Drawing.Color.LightGray;
                    txtNomAU.BorderWidth = 1;
                    n = 0;
                }
                if (txtAppatAU.Text == "" || txtAppatAU.Text == null)
                {

                    txtAppatAU.BorderColor = System.Drawing.Color.Red;
                    txtAppatAU.BorderWidth = 1;
                    n = 1;
                }
                else
                {
                    txtAppatAU.BorderColor = System.Drawing.Color.LightGray;
                    txtAppatAU.BorderWidth = 1;
                    n = 0;
                }
                if (txtApmatAU.Text == "" || txtApmatAU.Text == null)
                {
                    txtApmatAU.BorderColor = System.Drawing.Color.Red;
                    txtApmatAU.BorderWidth = 1;
                    n = 1;
                }
                else
                {
                    txtApmatAU.BorderColor = System.Drawing.Color.LightGray;
                    txtApmatAU.BorderWidth = 1;
                    n = 0;
                }
                if (txtDireccion.Text == "" || txtDireccion.Text == null)
                {

                    txtDireccion.BorderColor = System.Drawing.Color.Red;
                    txtDireccion.BorderWidth = 1;
                    n = 1;
                }
                else
                {
                    txtDireccion.BorderColor = System.Drawing.Color.LightGray;
                    txtDireccion.BorderWidth = 1;
                    n = 0;
                }
                if (ddlistCategoria.SelectedIndex == 0)
                {

                    ddlistCategoria.BorderColor = System.Drawing.Color.Red;
                    n = 1;
                }
                else
                {
                    ddlistCategoria.BorderColor = System.Drawing.Color.LightGray;
                    ddlistCategoria.BorderWidth = 1;
                    n = 0;
                }

                if (n == 1)
                {
                    lblInfoAU.Visible = true;
                    lblInfoAU.Text = "Los campos en Rojo son obligatorios";
                    lblInfoAU.ForeColor = System.Drawing.Color.Red;


                }
            }

        }
        protected void btnActualizarAU_Click(object sender, EventArgs e)
        {


            int n = 0;
            if (txtRutAU.Text == "" || txtRutAU.Text == null)
            {
                txtRutAU.BorderColor = System.Drawing.Color.Red;
                txtRutAU.BorderWidth = 1;
                n = n + 1;
            }
            else
            {
                txtRutAU.BorderColor = System.Drawing.Color.LightGray;
                txtRutAU.BorderWidth = 1;



                if (txtNomAU.Text == "" || txtNomAU.Text == null)
                {
                    txtNomAU.BorderColor = System.Drawing.Color.Red;
                    txtNomAU.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    txtNomAU.BorderColor = System.Drawing.Color.LightGray;
                    txtNomAU.BorderWidth = 1;

                }
                if (txtAppatAU.Text == "" || txtAppatAU.Text == null)
                {

                    txtAppatAU.BorderColor = System.Drawing.Color.Red;
                    txtAppatAU.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    txtAppatAU.BorderColor = System.Drawing.Color.LightGray;
                    txtAppatAU.BorderWidth = 1;

                }
                if (txtApmatAU.Text == "" || txtApmatAU.Text == null)
                {
                    txtApmatAU.BorderColor = System.Drawing.Color.Red;
                    txtApmatAU.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    txtApmatAU.BorderColor = System.Drawing.Color.LightGray;
                    txtApmatAU.BorderWidth = 1;

                }
                if (txtDireccion.Text == "" || txtDireccion.Text == null)
                {

                    txtDireccion.BorderColor = System.Drawing.Color.Red;
                    txtDireccion.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    txtDireccion.BorderColor = System.Drawing.Color.LightGray;
                    txtDireccion.BorderWidth = 1;

                }
                if (txtTelefono.Text == "" || txtTelefono.Text == null)
                {
                    txtTelefono.BorderColor = System.Drawing.Color.Red;
                    txtTelefono.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    txtTelefono.BorderColor = System.Drawing.Color.LightGray;
                    txtTelefono.BorderWidth = 1;

                }
                if (txtEmail.Text == "" || txtEmail.Text == null)
                {
                    txtEmail.BorderColor = System.Drawing.Color.Red;
                    txtEmail.BorderWidth = 1;
                    n = n + 1;
                }
                else
                {
                    if (!ValidaCorreo.instancia.email_bien_escrito(txtEmail.Text))
                    {
                        txtEmail.BorderColor = System.Drawing.Color.Red;
                        txtEmail.BorderWidth = 1;
                        n = n + 1;
                    }
                    else
                    {
                        txtEmail.BorderColor = System.Drawing.Color.LightGray;
                        txtEmail.BorderWidth = 1;

                    }

                }
                if (ddlistCategoria.SelectedIndex == 0)
                {

                    ddlistCategoria.BorderColor = System.Drawing.Color.Red;
                    n = n + 1;
                }
                else
                {
                    ddlistCategoria.BorderColor = System.Drawing.Color.LightGray;
                    ddlistCategoria.BorderWidth = 1;

                }
                if (n > 0)
                {

                    lblInfoAU.ForeColor = System.Drawing.Color.Red;
                    lblInfoAU.Text = "Los campos en Rojo son obligatorios.";
                    lblInfoAU.Visible = true;

                }
                else
                {
                    PERSONAL p = new PERSONAL();
                    p.RUT_PER = txtRutAU.Text.ToUpper();
                    p.NOMBRE_PER = txtNomAU.Text.ToUpper();
                    p.APPAT_PER = txtAppatAU.Text.ToUpper();
                    p.APMAT_PER = txtApmatAU.Text.ToUpper();
                    p.DIRECCION_PER = txtDireccion.Text.ToUpper();
                    p.TELEFONO_PER = txtTelefono.Text.ToUpper();
                    p.EMAIL_PER = txtEmail.Text.ToUpper();
                    p.ID_TIPO_FUNCIONARIO = Convert.ToDecimal(ddlistCategoria.SelectedValue);
                    if (chkActivoAU.Checked)
                        p.ACTIVO = "1";
                    else
                        p.ACTIVO = "0";

                    int actualizar = NegocioAdministrador.instancia.CrearPersonal(p, 2);
                    lblInfoAU.ForeColor = System.Drawing.Color.Gray;
                    lblInfoAU.Text = "Los datos guardados correctamente.";
                    lblInfoAU.Visible = true;
                }

            }


        }
Esempio n. 13
0
 /// <summary>
 /// Crear un nuevo objeto PERSONAL.
 /// </summary>
 /// <param name="iD_PERSONAL">Valor inicial de la propiedad ID_PERSONAL.</param>
 /// <param name="iD_TIPO_FUNCIONARIO">Valor inicial de la propiedad ID_TIPO_FUNCIONARIO.</param>
 public static PERSONAL CreatePERSONAL(global::System.Decimal iD_PERSONAL, global::System.Decimal iD_TIPO_FUNCIONARIO)
 {
     PERSONAL pERSONAL = new PERSONAL();
     pERSONAL.ID_PERSONAL = iD_PERSONAL;
     pERSONAL.ID_TIPO_FUNCIONARIO = iD_TIPO_FUNCIONARIO;
     return pERSONAL;
 }
 public int CrearPersonal(PERSONAL dto)
 {
     dto.PASSWORD_PER = MetodosGenericos.instancia.md5(dto.RUT_PER.ToString().Substring(0,5));
     return DaoPersonal.instancia.CrearPersonal(dto);
 }