public void Eliminar()
        {
            if (DgvGeneral.RowCount > 0 && DgvGeneral.GetFocusedRow() != null)
            {
                int      idGeneral = Convert.ToInt32(DgvGeneral.GetFocusedRowCellValue("Id"));
                Profesor profesor  = new Profesor();
                profesor.Persona.Id = idGeneral;


                if (XtraMessageBox.Show("Si elimina el profesor se perderan todos los datos y registros de este, ingresados en el sistema.\n ¿Desea continuar?", "Advertencia", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    if (XtraMessageBox.Show("¿Esta seguro que desea eliminar el profesor?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        CtrlProfesores.Eliminar(profesor);

                        if (!BkgwBuscar.IsBusy)
                        {
                            PrgBuscar.Visible = true;
                            BkgwBuscar.RunWorkerAsync();
                        }
                    }
                }
            }
            else
            {
                XtraMessageBox.Show("Debe seleccionar un registro.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
        private void CargarDatos(int id)
        {
            Profesor pf = new Profesor();

            pf.Persona.Id = id;
            DataSet ds = CtrlProfesores.GetProfesorOne(pf);
            DataRow dr = ds.Tables[0].Rows[0];

            codProfesor            = dr["CodigoProfesor"].ToString();
            TxtNombre.Text         = dr["Nombre"].ToString();
            TxtPrNombre.Text       = dr["PrimerNombre"].ToString();
            TxtSegNombre.Text      = dr["SegundoNombre"].ToString();
            TxtPrApellido.Text     = dr["PrimerApellido"].ToString();
            TxtSegApellido.Text    = dr["SegundoApellido"].ToString();
            TxtIdentificacion.Text = dr["Identificacion"].ToString();
            TxtDireccion.Text      = dr["Direccion"].ToString();
            TxtEmail.Text          = dr["Email"].ToString();
            TxtTelefono.Text       = dr["Telefono"].ToString();
            if (dr["Sexo"].ToString() == "M")
            {
                CmbSexo.SelectedIndex = 0;
            }
            else
            {
                CmbSexo.SelectedIndex = 1;
            }

            if (dr["Estado"].ToString() == "I")
            {
                CmbEstado.SelectedIndex = 0;
            }
            else
            {
                if (dr["Estado"].ToString() == "A")
                {
                    CmbEstado.SelectedIndex = 1;
                }
                else
                {
                    if (dr["Estado"].ToString() == "R")
                    {
                        CmbEstado.SelectedIndex = 4;
                    }
                }
            }

            if (!BkgwBuscarMat.IsBusy)
            {
                PrgBuscar2.Visible = true;
                BkgwBuscarMat.RunWorkerAsync();
            }
        }
        public void LlenarDsConsulta()
        {
            try
            {
                DataSet ds = CtrlProfesores.GetProfesorAll();

                dtConsulta = ds.Tables[0].Copy();
                dsConsulta.Tables.Clear();
                if (dsConsulta.Tables.Count == 0)
                {
                    dsConsulta.Tables.Add(dtConsulta);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
Example #4
0
        private bool ConsultarIdentificacion()
        {
            string identifi  = "";
            int    idPersona = 0;
            bool   retorno   = true;

            Profesor pf = new Profesor();

            pf.Persona.Identificacion = TxtIdentificacion.Text.Trim();

            DataSet ds = CtrlProfesores.GetPersonaIdentificacion(pf);

            if (ds.Tables[0].Rows.Count > 0)
            {
                identifi  = ds.Tables[0].Rows[0]["Identificacion"].ToString();
                idPersona = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"]);
            }

            if (Modo != "E")
            {
                if (TxtIdentificacion.Text.Trim() == identifi)
                {
                    retorno = false;
                    XtraMessageBox.Show("Ya existe una persona con esa identificación.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                    TxtIdentificacion.Focus();
                }
            }
            else
            {
                if (TxtIdentificacion.Text.Trim() == identifi && idPersona != Id)
                {
                    retorno = false;
                    XtraMessageBox.Show("Ya existe una persona con esa identificación.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                    TxtIdentificacion.Focus();
                }
            }

            return(retorno);
        }
        private void FrmGetRegistroNotas_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dt2 = CtrlProfesores.GetProfesorAll().Tables[0];
                LueProfesor.Properties.DataSource    = dt2;
                LueProfesor.Properties.DisplayMember = "Nombre";
                LueProfesor.Properties.ValueMember   = "CodigoProfesor";

                DevExpress.XtraEditors.Controls.LookUpColumnInfo col1;
                col1 = new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Nombre", "Nombre", 100);
                LueProfesor.Properties.Columns.Add(col1);
                LueProfesor.ItemIndex = -1;

                LueProfesor.EditValue = CodProfe;
                codProfesor           = CodProfe;

                DataTable dt3 = CtrlPeriodos.GetPeriodoAll().Tables[0];
                LuePeriodo.Properties.DataSource    = dt3;
                LuePeriodo.Properties.DisplayMember = "Nombre";
                LuePeriodo.Properties.ValueMember   = "CodigoPeriodo";

                DevExpress.XtraEditors.Controls.LookUpColumnInfo col2;
                col2 = new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Nombre", "Nombre", 100);
                LuePeriodo.Properties.Columns.Add(col2);
                LuePeriodo.ItemIndex = -1;

                LuePeriodo.EditValue = CodPeriodo;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);
                return;
            }

            TxtAño.Text = Año.ToString();
        }
Example #6
0
        private void InsertarActualizar(string modo)
        {
            try
            {
                if (modo == "INSERT")
                {
                    Profesor profesor = new Profesor();
                    profesor.Persona.Nombre          = TxtNombre.Text.Trim();
                    profesor.Persona.PrimerNombre    = TxtPrNombre.Text.Trim();
                    profesor.Persona.SegundoNombre   = TxtSegNombre.Text.Trim();
                    profesor.Persona.PrimerApellido  = TxtPrApellido.Text.Trim();
                    profesor.Persona.SegundoApellido = TxtSegApellido.Text.Trim();
                    profesor.Persona.Identificacion  = TxtIdentificacion.Text.Trim();
                    profesor.Persona.Direccion       = TxtDireccion.Text.Trim();
                    profesor.Persona.Telefono        = TxtTelefono.Text.Trim();
                    profesor.Persona.Email           = TxtEmail.Text.Trim();
                    profesor.Persona.Sexo            = (CmbSexo.SelectedIndex == 0 ? "M" : "F");

                    string est = "I";

                    if (CmbEstado.SelectedIndex == 1)
                    {
                        est = "A";
                    }
                    else
                    {
                        if (CmbEstado.SelectedIndex == 2)
                        {
                            est = "R";
                        }
                    }
                    profesor.Estado = est;

                    profesor.Usuario.Nombre             = TxtUsuario.Text.Trim();
                    profesor.Usuario.Contrasenia        = TxtPass2.Text.Trim();
                    profesor.Usuario.TipoUsuario.Codigo = LueTipoUsuario.EditValue.ToString();

                    DataTable insert = CtrlProfesores.Insertar(profesor).Tables[0];

                    if (insert.Rows.Count > 0)
                    {
                        codProfesor = insert.Rows[0]["CodProfesor"].ToString();
                        InsertarMaterias();

                        XtraMessageBox.Show("Profesor insertado con exito.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                    }
                }
                else
                {
                    Profesor profesor = new Profesor();
                    profesor.Persona.Id              = Id;
                    profesor.Persona.Nombre          = TxtNombre.Text.Trim();
                    profesor.Persona.PrimerNombre    = TxtPrNombre.Text.Trim();
                    profesor.Persona.SegundoNombre   = TxtSegNombre.Text.Trim();
                    profesor.Persona.PrimerApellido  = TxtPrApellido.Text.Trim();
                    profesor.Persona.SegundoApellido = TxtSegApellido.Text.Trim();
                    profesor.Persona.Identificacion  = TxtIdentificacion.Text.Trim();
                    profesor.Persona.Direccion       = TxtDireccion.Text.Trim();
                    profesor.Persona.Telefono        = TxtTelefono.Text.Trim();
                    profesor.Persona.Email           = TxtEmail.Text.Trim();
                    profesor.Persona.Sexo            = (CmbSexo.SelectedIndex == 0 ? "M" : "F");

                    string est = "I";

                    if (CmbEstado.SelectedIndex == 1)
                    {
                        est = "A";
                    }
                    else
                    {
                        if (CmbEstado.SelectedIndex == 2)
                        {
                            est = "R";
                        }
                    }
                    profesor.Estado = est;

                    if (CtrlProfesores.Actualizar(profesor) > 0)
                    {
                        EliminarMaterias();
                        InsertarMaterias();
                        XtraMessageBox.Show("Profesor actualizado con exito.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);
            }
        }