Example #1
0
        public void EliminarPersonal(clsPersonal Per)
        {
            con.Open();
            MySqlCommand mcRegPersonal;

            try
            {
                if (Per != null)
                {
                    mcRegPersonal             = new MySqlCommand("eliminarpersonal", con);
                    mcRegPersonal.CommandType = CommandType.StoredProcedure;
                    mcRegPersonal.Parameters.AddWithValue("@codigo", Per.CodigoPersonal);
                    mcRegPersonal.ExecuteNonQuery();
                    MessageBox.Show("LOS DATOS SE ELIMINARON EXITOSAMENTE", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("ERROR AL ELIMINAR", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Example #2
0
        public void RegistrarPersonal(clsPersonal Per)
        {
            con.Open();
            MySqlCommand mcRegPersonal;

            try
            {
                if (Per != null)
                {
                    mcRegPersonal             = new MySqlCommand("registrarpersonal", con);
                    mcRegPersonal.CommandType = CommandType.StoredProcedure;
                    mcRegPersonal.Parameters.AddWithValue("@codigo", Per.CodigoPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@nombre", Per.NombrePersonal);
                    mcRegPersonal.Parameters.AddWithValue("@paterno", Per.ApePatPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@materno", Per.ApeMatPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@mail", Per.EMailPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@fono", Per.FonoPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@estado", Per.EstadoPersonal);
                    mcRegPersonal.Parameters.AddWithValue("@cargo", Per.IdCargoPersonal);
                    mcRegPersonal.ExecuteNonQuery();
                    MessageBox.Show("EL PERSONAL " + Per.NombrePersonal + " " + Per.ApePatPersonal + " " + Per.ApeMatPersonal + " SE REGISTRO EXITOSAMENTE", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("ERROR EN EL REGISTRO", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
        public int RegistrarPersonal([FromBody] Personal objPersonal)
        {
            clsPersonal objClsPersonal;

            Abm.PersonalV objValidarPersonal;

            try
            {
                objClsPersonal     = new clsPersonal();
                objValidarPersonal = new Abm.PersonalV();
                objValidarPersonal = objClsPersonal.ValidarPersonal(objPersonal.per_dni);

                if (objValidarPersonal == null)
                {
                    objClsPersonal = new clsPersonal();
                    return(objClsPersonal.RegistrarPersonal(objPersonal));
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                objClsPersonal     = null;
                objValidarPersonal = null;
            }
        }
Example #4
0
        private void btneliminar_Click(object sender, EventArgs e)
        {
            clsPersonal       Per = new clsPersonal();
            clsAccesoPersonal BD  = new clsAccesoPersonal();

            Per.CodigoPersonal = int.Parse(txtcodpersonal.Text);
            BD.EliminarPersonal(Per);
        }
Example #5
0
        public clsPersonal BuscarPersonal(int codigo)
        {
            con.Open();
            clsPersonal  Per = new clsPersonal();
            MySqlCommand mcBusPersonal;

            try
            {
                mcBusPersonal             = new MySqlCommand("buscarpersonal", con);
                mcBusPersonal.CommandType = CommandType.StoredProcedure;
                mcBusPersonal.Parameters.AddWithValue("@codigo", codigo);
                MySqlDataReader mdrPersonal = mcBusPersonal.ExecuteReader();
                if (mdrPersonal.HasRows)
                {
                    while (mdrPersonal.Read())
                    {
                        Per.NombrePersonal = mdrPersonal.GetString(0);
                        Per.ApePatPersonal = mdrPersonal.GetString(1);
                        Per.ApeMatPersonal = mdrPersonal.GetString(2);
                        int email = mdrPersonal.GetOrdinal("EmailPersonal");
                        if (mdrPersonal.IsDBNull(email))
                        {
                            MessageBox.Show("NO EXISTE EMAIL PARA ESTE PERSONAL", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            Per.EMailPersonal = string.Empty;
                        }
                        else
                        {
                            Per.EMailPersonal = mdrPersonal.GetString(3);
                        }
                        //Per.EMailPersonal = mdrPersonal.IsDBNull(email) ? string.Empty : mdrPersonal.GetString(3);
                        int fono = mdrPersonal.GetOrdinal("FonoPersonal");
                        if (mdrPersonal.IsDBNull(fono))
                        {
                            MessageBox.Show("NO EXISTE TELEFONO PARA ESTE PERSONAL", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            Per.FonoPersonal = string.Empty;
                        }
                        else
                        {
                            Per.FonoPersonal = mdrPersonal.GetString(4);
                        }
                        //Per.FonoPersonal = mdrPersonal.IsDBNull(fono) ? string.Empty : mdrPersonal.GetString(4);
                        Per.EstadoPersonal  = mdrPersonal.GetString(5);
                        Per.IdCargoPersonal = mdrPersonal.GetInt32(6);
                    }
                    MessageBox.Show("DATOS ENCONTRADOS", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("NO EXISTEN DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                mdrPersonal.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            return(Per);
        }
Example #6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            clsPersonal nuevo;

            nuevo          = new clsPersonal(22, txtDNIPersonal.Text, txtNombres.Text, txtApPaterno.Text, txtApMaterno.Text, txtDireccionPers.Text, Convert.ToBoolean(rbMasculino.Checked), txtIniSesionPer.Text, txtContraseniaPers.Text, Convert.ToString(cmbCargo.SelectedItem), System.DateTime.Now);
            nuevo.Telefono = txtTelefonoPers.Text;
            nuevo.Insertar();
            MessageBox.Show("personal insertada yupiiii");
        }
        public void CargarVendedores()
        {
            clsPersonal lstPersonal = new clsPersonal();
            var lstVendedores = lstPersonal.GetPersonalPorTipo(2);

            ddlListaVendedores.DataSource = lstVendedores;
            ddlListaVendedores.DataBind();
            ddlListaVendedores.Items.Insert(0, new ListItem("Todos", "0"));
        }
        public void CargarVendedor()
        {
            clsPersonal lstTrabajadores = new clsPersonal();

            ddlVendedor.DataSource = lstTrabajadores.GetList(0);
            ddlVendedor.DataBind();
            ddlVendedor.Items.Insert(0, new ListItem("", "000"));

            lstTrabajadores = null;
        }
Example #9
0
        private void CargarCargos()
        {
            clsPersonal  pers = new clsPersonal();
            List <Cargo> lst  = pers.LeerListado();

            foreach (Cargo item in lst)
            {
                dtgvCargo.Rows.Add(item.Id_Cargo, item.Nombre, item.Descripcion, item.Estado);
            }
        }
Example #10
0
        public static bool enviarCorreo(string strDestinatario, clsPersonal objPersonal)
        {
            try
            {
                MailMessage correo = new MailMessage();

                string asunto = "Contraseña Biblioteca Virtual";
                string cuerpo = "";

                correo.From = new MailAddress("*****@*****.**", "Sistema Centro de Salud", System.Text.Encoding.UTF8);
                correo.To.Add(strDestinatario);
                correo.Subject         = asunto;
                correo.SubjectEncoding = System.Text.Encoding.UTF8;

                cuerpo += "Estimado(a):\n";
                cuerpo += objPersonal.StrApellidoPaterno + " " + objPersonal.StrApellidoMaterno + ", " + objPersonal.StrNombres + "\n\n";

                cuerpo += "Sus datos de acceso al Sistema son:\n";
                cuerpo += "=====================================\n";
                cuerpo += "Usuario: " + objPersonal.StrUsuario + "\n";
                cuerpo += "Contraseña: " + objPersonal.StrContrasena + "\n\n";
                cuerpo += "*Recuerde que puede cambiar su contraseña\n";
                cuerpo += "\n";


                correo.Body         = cuerpo;
                correo.BodyEncoding = System.Text.Encoding.UTF8;
                correo.IsBodyHtml   = false;
                correo.Priority     = MailPriority.High;

                SmtpClient smtp = new SmtpClient();
                smtp.Host        = "smtp.gmail.com";
                smtp.Port        = 587;
                smtp.EnableSsl   = true;
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "tesispucp");
                try
                {
                    smtp.Send(correo);
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    registrarErrorLog(ex.ToString());
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                registrarErrorLog(ex.ToString());
                return(false);
            }
        }
Example #11
0
        private void CargaPersonal()
        {
            clsPersonal     pers = new clsPersonal();
            Personal        per  = new Personal();
            List <Personal> lst  = pers.LeerListadoPersonalDisponible();

            foreach (Personal item in lst)
            {
                dtgvPersonal.Rows.Add(item.Id_Pers, item.Id_Cargo, item.Cargo.Nombre, item.Nombre, item.Apellido, item.Dni, item.Fecha_Nacimiento /*item.Telefono*/,
                                      item.Sueldo, item.Detalle, item.Nick, item.Clave);
            }
        }
Example #12
0
        public void codigobusqueda(int codigo)
        {
            txtcodpersonal.Text = codigo.ToString();
            clsAccesoPersonal BD  = new clsAccesoPersonal();
            clsPersonal       Per = new clsPersonal();

            Per                            = BD.BuscarPersonal(codigo);
            txtnombres.Text                = Per.NombrePersonal;
            txtapepaterno.Text             = Per.ApePatPersonal;
            txtapematerno.Text             = Per.ApeMatPersonal;
            txtmail.Text                   = Per.EMailPersonal;
            cboEstado.SelectedItem         = Per.EstadoPersonal;
            cbocargopersonal.SelectedIndex = (Per.IdCargoPersonal - 1);
        }
        protected void gvwPersonal_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //presiona BOTON MODIFICAR EN GRILLA
            if (e.CommandName == "SeleccionaPersonal")
            {

                int linPerCodigo;
                linPerCodigo = Convert.ToInt32(e.CommandArgument);

                AgregarVariableSession("perCod", linPerCodigo);

                Personal oPersonal = new Personal();
                clsPersonal lstPersonal = new clsPersonal();

                oPersonal = lstPersonal.GetPersonal(linPerCodigo);
                if (oPersonal != null)
                {
                    txtCodigo.Text = linPerCodigo.ToString();
                    txtNombres.Text = oPersonal.perNombres;
                    txtApellidoPat.Text = oPersonal.perApellidoPat;
                    txtApellidoMat.Text = oPersonal.perApellidoMat;
                    txtDireccion.Text = oPersonal.perDireccion;
                    txtTelefono.Text = oPersonal.perTelefono;

                    ListItem liElegido;
                    //si DropDownList está visible
                    if (ddlTipoPersonal.Items.Count > 0)
                    {
                        liElegido = ddlTipoPersonal.Items.FindByValue(oPersonal.tpecod.ToString());
                        ddlTipoPersonal.SelectedIndex = ddlTipoPersonal.Items.IndexOf(liElegido);
                    }

                    //MODIFICAR , se guarda en variable cache
                    AgregarVariableSession("operacion", 2);
                    pnlEditPersonal.Visible = true;
                    pnlPersonal.Visible = false;
                    lblMensajes.Visible = false;
                }

            }
            //presiona BOTON ELIMINAR EN GRILLA
            if (e.CommandName == "EliminaPersonal")
            {
                int linPerCodigo;

                linPerCodigo = Convert.ToInt32(e.CommandArgument);
                EventoEliminar(linPerCodigo);

            }
        }
Example #14
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            clsPersonal       Per = new clsPersonal();
            clsAccesoPersonal BD  = new clsAccesoPersonal();

            Per.CodigoPersonal  = int.Parse(txtcodpersonal.Text);
            Per.NombrePersonal  = txtnombres.Text;
            Per.ApePatPersonal  = txtapepaterno.Text;
            Per.ApeMatPersonal  = txtapematerno.Text;
            Per.EMailPersonal   = txtmail.Text;
            Per.FonoPersonal    = txtTelefono.Text;
            Per.EstadoPersonal  = cboEstado.SelectedItem.ToString();
            Per.IdCargoPersonal = (cbocargopersonal.SelectedIndex + 1);
            BD.ActualizarPersonal(Per);
        }
Example #15
0
        private void CargaCargo()
        {
            clsPersonal  pers = new clsPersonal();
            Cargo        c    = new Cargo();
            List <Cargo> lst  = pers.LeerListadoDisponibles();

            lst.Add(new Cargo {
                Id_Cargo = 0, Nombre = ""
            });

            cmbCargo.ValueMember   = "Id_Cargo";
            cmbCargo.DisplayMember = "Nombre";
            cmbCargo.DataSource    = lst;

            cmbCargo.SelectedIndex = lst.Count - 1;
        }
        public int ActualizarPersonal([FromBody] Personal objPersonal)
        {
            clsPersonal objClsPersonal;

            try
            {
                objClsPersonal = new clsPersonal();
                return(objClsPersonal.ActualizarPersonal(objPersonal));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                objClsPersonal = null;
            }
        }
        public string SelectPersonal(string stObj)
        {
            JObject     Jobj;
            clsPersonal objClsPersonal;

            try
            {
                Jobj           = JObject.Parse(stObj);
                objClsPersonal = new clsPersonal();
                return(JsonConvert.SerializeObject(objClsPersonal.ListarPersonal(Convert.ToInt32(Jobj["per_IDAreaServicio"]))));
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
            finally
            {
                objClsPersonal = null;
            }
        }
        public string SelectDataPersonal(string stObj)
        {
            JObject     Jobj;
            clsPersonal objClsPersonal;

            try
            {
                Jobj           = JObject.Parse(stObj);
                objClsPersonal = new clsPersonal();
                return(JsonConvert.SerializeObject(objClsPersonal.SelectDataPersonal(Convert.ToInt64(Jobj["per_IDPersonal"]))));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Jobj           = null;
                objClsPersonal = null;
            }
        }
        protected void gvwPersonal_RowCommand1(object sender, GridViewCommandEventArgs e)
        {
            //presiona BOTON MODIFICAR EN GRILLA
            if (e.CommandName == "SeleccionaPersonal")
            {

                int linPerCodigo;
                linPerCodigo = Convert.ToInt32(e.CommandArgument);

                AgregarVariableSession("perCod", linPerCodigo);

                Personal oPersonal = new Personal();
                clsPersonal lstPersonal = new clsPersonal();

                oPersonal = lstPersonal.GetPersonal(linPerCodigo);
                if (oPersonal != null)
                {
                    txtCodigoPersonal.Text = linPerCodigo.ToString();
                    txtNombre.Text = oPersonal.perNombres;
                    txtApePaterno.Text = oPersonal.perApellidoPat;
                    txtApeMaterno.Text = oPersonal.perApellidoMat;

                    pnlEditUsuarios.Visible = true;
                    pnlPersonal.Visible = false;
                    pnlUsuarios.Visible = false;
                    lblMensajes.Visible = false;
                }

            }
        }
        private void EventoActualizaGrillaPersonal()
        {
            clsPersonal lstPersonal = new clsPersonal();
            DataTable dtPersonal = lstPersonal.GetList();

            gvwPersonal.DataSource = dtPersonal;
            gvwPersonal.DataBind();
        }
Example #21
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!editar)
                {
                    clsPersonal pers = new clsPersonal();
                    Personal    p    = new Personal();

                    p.Nombre   = txtNombre.Text;
                    p.Apellido = txtApellido.Text;
                    p.Dni      = txtDni.Text;
                    p.Nick     = txtNick.Text;
                    p.Detalle  = txtDetalle.Text;
                    //p.Telefono = txtTelefono.Text;
                    p.Sueldo           = Convert.ToInt32(txtSueldo.Text);
                    p.Clave            = txtContraseña.Text;
                    p.Fecha_Nacimiento = Convert.ToDateTime(dtmFechaNac.Value.ToShortDateString());
                    p.Estado           = "Disponible";
                    p.Id_Cargo         = Convert.ToInt32(cmbCargo.SelectedValue);
                    p.Fecha_Ingreso    = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                    int crearcli = pers.CrearPersonal(p);

                    if (crearcli == 1)
                    {
                        dtgvPersonal.Rows.Clear();
                        CargaPersonal();
                        ReseteoTexto();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrió un error, por favor vuelva a intentarlo o comuníquese con el soporte técnico.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ReseteoTexto();
                    }
                }
            }
            catch (DbUpdateException)
            {
                MessageBox.Show("Se ha producido un error al enviar actualizaciones a la base de datos.");
            }
            catch (DbEntityValidationException)
            {
                MessageBox.Show("La operación de guardar se anuló debido a que la validación de los valores de propiedad de la entidad falló.");
            }
            catch (NotSupportedException)
            {
                MessageBox.Show("Se intentó utilizar un comportamiento no compatible, como ejecutar varios comandos asíncronos simultáneamente en la misma instancia de contexto.");
            }
            catch (ObjectDisposedException)
            {
                MessageBox.Show("El contexto o la conexión han sido eliminados.");
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Se produjo un error al intentar procesar las entidades en el contexto antes o después de enviar comandos a la base de datos.");
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error número: " + ex.Number + " - " + ex.Message);
            }
            catch (FormatException)
            {
                MessageBox.Show("El formato de un dato no corresponde con sus especificaciones");
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("No hay suficiente espacio de memoria para crear un objeto");
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Error al intentar acceder a una celda de un arreglo cuyo índice está fuera de rango");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void CargarVendedores()
        {
            Usuarios objUsuario = (Usuarios)(LeerVariableSesion("oUsuario"));
            clsPersonal lstPersonal = new clsPersonal();
            var lstVendedores = lstPersonal.GetPersonalPorTipo(2);

            ddlVendedores.DataSource = lstVendedores;
            ddlVendedores.DataBind();

            ddlListaVendedores.DataSource = lstVendedores;
            ddlListaVendedores.DataBind();

            if (ddlVendedores.Items.Count == 0)
                ddlVendedores.Items.Insert(0, new ListItem("Sin Vendedores", "000"));

            if (ddlListaVendedores.Items.Count == 0)
            {
                ddlListaVendedores.Enabled = false;
                ddlListaVendedores.Items.Insert(0, new ListItem("Sin Vendedores", "000"));
            }

            if (objUsuario != null)
                ddlListaVendedores.Enabled = (objUsuario.Roles.rolDescripcion != "Vendedor");
            else
                ddlListaVendedores.Enabled = true;

            lstPersonal = null;
        }
        private void EventoGuardar()
        {
            int linOperacion = (int)LeerVariableSesion("operacion");

            Personal oPersonal = new Personal();
            clsPersonal lstPersonal = new clsPersonal();

            if (linOperacion == 1)        //NUEVO
            {
                oPersonal.perCod = lstPersonal.MaxpnPerCod() + 1;
                oPersonal.perNombres = txtNombres.Text.ToUpper();
                oPersonal.perApellidoPat = txtApellidoPat.Text.ToUpper();
                oPersonal.perApellidoMat = txtApellidoMat.Text.ToUpper();
                oPersonal.perDireccion = txtDireccion.Text;
                oPersonal.perTelefono = txtTelefono.Text;
                oPersonal.tpecod = Convert.ToInt32( ddlTipoPersonal.SelectedItem.Value);

                lstPersonal.Add(oPersonal);
            }
            else                        // MODIFICAR
            {
                int linPerCodigo = (int)LeerVariableSesion("perCod");
                oPersonal = lstPersonal.GetPersonal(linPerCodigo);
                oPersonal.perNombres = txtNombres.Text.ToUpper();
                oPersonal.perApellidoPat = txtApellidoPat.Text.ToUpper();
                oPersonal.perApellidoMat = txtApellidoMat.Text.ToUpper();
                oPersonal.perDireccion = txtDireccion.Text;
                oPersonal.perTelefono = txtTelefono.Text;
                oPersonal.tpecod = Convert.ToInt32(ddlTipoPersonal.SelectedItem.Value);

                lstPersonal.Update(oPersonal);
            }

            try
            {
                lstPersonal.SaveChanges();
                lblMensajes.Visible = true;
                lblMensajes.Text = "El registro se Grabo Satisfactoriamente.";
                pnlEditPersonal.Visible = false;
                pnlPersonal.Visible = true;
                this.MessageBox("El registro se Grabo Satisfactoriamente.");
                EventoActualizaGrilla();
            }
            catch (Exception ex)
            {

                lblMensajes.Visible = true;
                lblMensajes.Text = ex.Message;
                this.MessageBox(ex.Message);
            }
        }
        private void EventoEliminar(int perCodigo)
        {
            clsPersonal lstPersonal = new clsPersonal();

            try
            {
                lstPersonal.DeletePersonal(perCodigo);
                lstPersonal.SaveChanges();
                lblMensajes.Visible = true;
                lblMensajes.Text = "El registro se Eliminó Satisfactoriamente.";
                this.MessageBox("El registro se Eliminó Satisfactoriamente.");

                EventoActualizaGrilla();
            }
            catch (Exception ex)
            {
                lblMensajes.Visible = true;
                lblMensajes.Text = ex.Message;
                this.MessageBox(ex.Message);
            }
        }
        public void CargarClientes()
        {
            clsClientes lstClientes = new clsClientes();

            if (lblTipoDoc.Value != "7")
            {
                ddlClientes.DataTextField = "CliNombre";
                ddlClientes.DataValueField = "CliCod";
                ddlClientes.DataSource = lstClientes.GetAll();
                ddlClientes.DataBind();
                ddlClientes.Items.Add(new ListItem("[NUEVO CLIENTE]", "999"));
            }
            else
            {
                clsPersonal lstPersonal = new clsPersonal();
                var lstVendedores = lstPersonal.GetPersonalPorTipo(1);
                ddlClientes.DataTextField = "VenNombre";
                ddlClientes.DataValueField = "PerCod";
                ddlClientes.DataSource = lstPersonal.GetVendedores();
                ddlClientes.DataBind();
            }
            ddlClientes.Items.Insert(0, new ListItem("", "000"));

            ddlClienteFiltro.DataSource = lstClientes.GetAll();
            ddlClienteFiltro.DataBind();

            lstClientes = null;
        }
 protected void ddlListaVendedores_SelectedIndexChanged(object sender, EventArgs e)
 {
     int nVenCod = 0;
     nVenCod  = int.Parse(ddlListaVendedores.SelectedValue);
     if (nVenCod > 0)
     {
         HabilitarBtn(btnNuevo, true);
         clsPersonal form = new clsPersonal();
         Personal obj = new Personal();
         obj = form.GetPersonal(Convert.ToInt32(ddlListaVendedores.SelectedValue));
         lblnomVen.Text = obj.perNombres + " " + obj.perApellidoPat + " " + obj.perApellidoMat;
         lblOpeCodigo.Value = ddlListaVendedores.SelectedValue;
     }
     else
     {
         HabilitarBtn(btnNuevo, false);
     }
 }
Example #27
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                clsPersonal pers = new clsPersonal();
                Cargo       c    = new Cargo();

                c.Nombre      = txtNombre.Text;
                c.Descripcion = txtDescripcion.Text;
                c.Estado      = "Disponible";

                int crearcli = pers.Crear(c);

                if (crearcli == 1)
                {
                    dtgvCargo.Rows.Clear();
                    CargarCargos();

                    txtDescripcion.Text = "Descripción";
                    txtEstado.Text      = "Estado";
                    txtNombre.Text      = "Nombre";
                }
                else
                {
                    MessageBox.Show("Ocurrió un error, por favor vuelva a intentarlo o comuníquese con el soporte técnico.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (DbUpdateException)
            {
                MessageBox.Show("Se ha producido un error al enviar actualizaciones a la base de datos.");
            }
            catch (DbEntityValidationException)
            {
                MessageBox.Show("La operación de guardar se anuló debido a que la validación de los valores de propiedad de la entidad falló.");
            }
            catch (NotSupportedException)
            {
                MessageBox.Show("Se intentó utilizar un comportamiento no compatible, como ejecutar varios comandos asíncronos simultáneamente en la misma instancia de contexto.");
            }
            catch (ObjectDisposedException)
            {
                MessageBox.Show("El contexto o la conexión han sido eliminados.");
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Se produjo un error al intentar procesar las entidades en el contexto antes o después de enviar comandos a la base de datos.");
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error número: " + ex.Number + " - " + ex.Message);
            }
            catch (FormatException)
            {
                MessageBox.Show("El formato de un dato no corresponde con sus especificaciones");
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("No hay suficiente espacio de memoria para crear un objeto");
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Error al intentar acceder a una celda de un arreglo cuyo índice está fuera de rango");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        protected void ddlClientes_SelectedIndexChanged(object sender, EventArgs e)
        {
            int nCliCod = 0;
            nCliCod = int.Parse(ddlClientes.SelectedValue);

            if (nCliCod == 999)
            {
                txtCliente.Text = "";
                ModalPopupNuevoCli.Show();
                IniciarCamposCliente();
                btnNuevoCliente_Click(sender, e);
            }
            else if (nCliCod == 0)
            {
                txtDocCli.Text = "";
                txtDireccion.Text = "";
                txtTelefono.Text = "";
            }
            else
            {
                if (lblTipoDoc.Value == "7")
                {
                    clsPersonal lstPersonal = new clsPersonal();
                    Personal oVendedor = lstPersonal.GetPersonal(nCliCod);

                    txtCliente.Text = oVendedor.perNombres + " " + oVendedor.perApellidoPat + " " + oVendedor.perApellidoMat;
                    txtDocCli.Text = "";
                    txtDireccion.Text = oVendedor.perDireccion == null? "" : oVendedor.perDireccion.ToString();
                    txtTelefono.Text = oVendedor.perTelefono == null ? "" : oVendedor.perTelefono.ToString();

                    lstPersonal = null;
                    oVendedor = null;
                }
                else
                {
                    clsClientes lstClientes = new clsClientes();
                    Clientes Cliente = new Clientes();

                    Cliente = lstClientes.GetCliente(nCliCod);

                    txtCliente.Text = Cliente.CliNombre.ToString();
                    txtDocCli.Text = Cliente.CliNumDoc.ToString();
                    txtDireccion.Text = Cliente.CliDireccion.ToString();
                    txtTelefono.Text = Cliente.CliTelefono.ToString();

                    lstClientes = null;
                    Cliente = null;
                    ////////////////////silvia/////////////////
                    clsListNotas lstNota = new clsListNotas();
                    nota_list nota_lista = new nota_list();
                    DataTable dtOpeNotas;
                    dtOpeNotas= lstNota.GetLista("1212111","0", "N",
                        "PEN",nCliCod  , Convert.ToDateTime("1990-01-01"),
                        Convert.ToDateTime("1990-01-01") ,"V",0);
                    dgvNotas.DataSource = dtOpeNotas;
                    dgvNotas.DataBind();
                    pnNotas.Visible = true;

                    ///////////////////////////////////////////
                }
            }
        }