示例#1
0
        private void CargarDatos()
        {
            cls_Usuarios_BLL obj_User_BLL = new cls_Usuarios_BLL();
            string           sMsjError    = string.Empty;
            DataTable        DT           = new DataTable();

            if (txtFiltro.Text == string.Empty)
            {
                DT = obj_User_BLL.ListarUsuarios(ref sMsjError);
            }
            else
            {
                DT = obj_User_BLL.FiltrarUsuarios(ref sMsjError, txtFiltro.Text.Trim());
            }

            if (sMsjError == string.Empty)
            {
                dgv_Usuarios.DataSource = null;
                dgv_Usuarios.DataSource = DT;
            }
            else
            {
                dgv_Usuarios.DataSource = null;

                MessageBox.Show("Se presento un error a la hora de listar los estados.\n\nDetalle Error : [" + sMsjError + "]",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnGuardar_Click_1(object sender, EventArgs e)
        {
            cls_Usuarios_BLL Obj_ManteniUsuarios_BLL = new cls_Usuarios_BLL();

            if (txt_Username.Text == "" || txt_Password.Text == "" || cmb_IdEmpleado.Text == "--- Selecione un Estado ---" || cmb_IdEmpleado.Text == "" || cmb_IdEstado.Text == "--- Selecione un Estado ---")
            {
                MessageBox.Show("Alguno de lo campos esta vacido favor de verificar", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                toolStripLabel1.Text = "Modificar";
                string sMsjError = string.Empty;
                Obj_Usuarios_Dal.sUsername = txt_Username.Text;
                Obj_Usuarios_Dal.sPassword = txt_Password.Text;

                Obj_Usuarios_Dal.sIdEmpleado = Convert.ToString(cmb_IdEmpleado.SelectedValue);

                Obj_Usuarios_Dal.cIdEstado = Convert.ToChar(cmb_IdEstado.SelectedValue);

                if (Obj_Usuarios_Dal.cBandAX == 'I')
                {
                    Obj_ManteniUsuarios_BLL.Insertar_Usuarios(ref sMsjError, ref Obj_Usuarios_Dal);

                    if (sMsjError == string.Empty)
                    {
                        MessageBox.Show("Se han ingresado los datos correctamente", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        toolStripLabel1.Text = "Modificar";
                    }
                    else
                    {
                        MessageBox.Show("Hubo un error al ingresar los datos a la base de datos:" + "[" + sMsjError + "]", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    Obj_ManteniUsuarios_BLL.Modificar_Usuarios(ref sMsjError, ref Obj_Usuarios_Dal);
                    if (sMsjError == string.Empty)
                    {
                        MessageBox.Show("Se han ingresado los datos correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(sMsjError.ToString());
                    }
                }
            }
        }
示例#3
0
        private void tls_btn_Eliminar_Click(object sender, EventArgs e)
        {
            string           sMsjError    = string.Empty;
            cls_Usuarios_BLL obj_User_BLL = new cls_Usuarios_BLL();
            DataTable        DT           = new DataTable();

            DT = obj_User_BLL.ListarUsuarios(ref sMsjError);
            cls_Empleados_BLL objBLL = new cls_Empleados_BLL();

            if (dgv_Empleados.Rows.Count > 0)
            {
                if (DT.Rows[0][2].ToString() == dgv_Empleados.SelectedRows[0].Cells[0].Value.ToString())
                {
                    MessageBox.Show("Este usuario es el administrador, no se puede eliminar.\nContacte con soporte para eliminarlo ");
                }
                else
                {
                    if (MessageBox.Show("Realmente desea eliminar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        objBLL.Eliminar_Empleados(ref sMsjError, dgv_Empleados.SelectedRows[0].Cells[0].Value.ToString());
                        if (sMsjError != string.Empty)
                        {
                            MessageBox.Show("Se presento un error a la hora de eliminar : [ " + sMsjError + " ]", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Registro eliminado correctamente", "Listo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Cargar();
                        }
                        tls_txt_Filtro.Text = string.Empty;
                    }
                }
            }

            else
            {
                MessageBox.Show("No hay registros para eliminar");
            }
        }
示例#4
0
        private void CargarDatos()
        {
            cls_Usuarios_BLL obj_User_BLL = new cls_Usuarios_BLL();
            string           sMsjError    = string.Empty;
            DataTable        DT           = new DataTable();
            char             cUser        = '******';

            DT = obj_User_BLL.ListarUsuarios(ref sMsjError);


            if (sMsjError == string.Empty)
            {
                int i = 0;
                foreach (DataRow row in DT.Rows)
                {
                    if (DT.Rows[i][0].ToString() == txt_Usuario.Text.ToString())
                    {
                        if (DT.Rows[i][1].ToString() == txt_Contraseña.Text.ToString())
                        {
                            if (DT.Rows[i][3].ToString() == "A" || DT.Rows[i][3].ToString() == "a")
                            {
                                frm_Ventana_Principal Pantalla = new frm_Ventana_Principal();
                                Pantalla.User(txt_Usuario.Text);
                                Pantalla.Show();
                                Hide();
                                cUser = '******';
                            }
                            else
                            {
                                MessageBox.Show("Este usuario tine restricciones ala hora de ingresar  .\n\n Contacte al Administarador   ",
                                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                cUser = '******';
                                txt_Contraseña.Text = "";
                                txt_Contraseña.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("La contraseña que digito es incorrecta  ",
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            cUser = '******';
                            txt_Contraseña.Text = "";
                            txt_Contraseña.Focus();
                        }
                    }

                    ++i;
                }
            }
            else
            {
                MessageBox.Show("Se presento un error  favor de comunicarse con soporte   .\n\nDetalle Error : [" + sMsjError + "]",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cUser = '******';
                Application.Exit();
            }

            if (cUser == 'E')
            {
                MessageBox.Show("El Usuario que digito es incorrecto  " + txt_Usuario.Text,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_Usuario.Text = "";
                txt_Usuario.Focus();
            }
        }