Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox2.Text != "" && textBox7.Text != "" && textBox8.Text != "")
                {
                    if (checkBox1.Checked != false)
                    {
                        checkBox1.Checked = true;
                    }
                    else
                    {
                        checkBox1.Checked = false;
                    }
                    var c = new DEmpleado();
                    c.Id_Empleado     = Convert.ToInt32(textBox1.Text);
                    c.Nombre          = textBox2.Text.ToUpper();
                    c.Direccion       = textBox3.Text;
                    c.Telefono        = int.Parse(maskedTextBox1.Text);
                    c.Usuario         = textBox7.Text;
                    c.Contrase_a      = textBox8.Text;
                    c.Estado_Empleado = Convert.ToByte(checkBox1.Checked);
                    c.Id_Puesto       = int.Parse(puesto);
                    c.Id_Centro       = int.Parse(centro);


                    if (NEmpleado.Agregar(c))
                    {
                        MessageBox.Show("Datos guardados correctamente", "Aviso");
                        idempleado();
                        limpiar();
                        Listacentros();
                        ListaPuestos();
                        ListaEmpleados();
                    }
                    else
                    {
                        MessageBox.Show("Error", "Aviso");
                    }
                }

                else
                {
                    MessageBox.Show("Error", "Aviso");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void Guardar()
        {
            DateTime? fechnac = string.IsNullOrWhiteSpace(DtpFechaNacimiento.Text) ? (DateTime?)null : Convert.ToDateTime(DtpFechaNacimiento.Text);
            EEmpleado be      = new EEmpleado
            {
                Cargo           = Convert.ToInt32(CbxCargo.SelectedValue),
                TipoDocumento   = CbxTipoDocumento.SelectedValue.ToString(),
                NumeroDocumento = TxtNumeroDocumento.Text,
                Nombre          = TxtNombres.Text,
                Apellido        = TxtApellidos.Text,
                FechaNacimiento = fechnac,
                Pais            = TxtPais.Text,
                Ciudad          = TxtCiudad.Text,
                Direccion       = TxtDireccion.Text,
                Email           = TxtEmail.Text,
                Telefono        = TxtTelefono.Text,
                Estado          = 1
            };
            NEmpleado bo = new NEmpleado();

            if (modificar == 0)
            {
                if (bo.Agregar(be))
                {
                    Frm_Buscar_Empleado frm = Owner as Frm_Buscar_Empleado;
                    frm.Listar();
                    Close();
                    Frm_Principal.Main.ChangeMessage("Empleado agregado correctamente", "Success");
                }
                else
                {
                    Frm_Principal.Main.ChangeMessage("Algo salio mal, Intente de nuevo", "Failed");
                }
            }
            else if (modificar == 1)
            {
                if (bo.Modificar(be))
                {
                    Frm_Buscar_Empleado frm = Owner as Frm_Buscar_Empleado;
                    frm.Listar();
                    Close();
                    Frm_Principal.Main.ChangeMessage("Empleado modificado correctamente", "Success");
                }
                else
                {
                    Frm_Principal.Main.ChangeMessage("Algo salio mal, Intente de nuevo", "Failed");
                }
            }
        }