Exemple #1
0
        public void CargaUsuario()
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible Conectar");
                return;
            }
            string strComando = "select usuarioID from usuarios where Tipo='T'";

            SqlDataReader lector = UsoDB.Consulta(strComando, conn);

            if (lector == null)
            {
                MessageBox.Show("Error En La Consulta");
                conn.Close();
                return;
            }
            if (lector.HasRows)
            {
                while (lector.Read())
                {
                    cmbClaveUsuario.Items.Add(lector.GetValue(0).ToString());
                }
            }
            conn.Close();
        }
Exemple #2
0
        private void frmCab_Load(object sender, EventArgs e)
        {
            string clave  = cmbClave.SelectedIndex.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible Conectar");
            }
            string        strcomand = "select rfcId from rfc where estatus = 'recibido'";
            SqlDataReader Lector    = UsoDB.Consulta(strcomand, conn);

            if (Lector == null)
            {
                MessageBox.Show("Error en la Consulta");
                conn.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    cmbClave.Items.Add(Lector.GetValue(0).ToString());
                }
            }
            conn.Close();
        }
Exemple #3
0
        private void btnDiagnosticar_Click(object sender, EventArgs e)
        {
            string clave  = cmbClave.Text.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtTiempo.Text == "")
            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string tiempoEstimado = txtTiempo.Text;

                string     strComando = "update incidencias set tiempoEstimado=@tiempoEstimado where incidenciaID='" + clave + "'";
                SqlCommand cmd        = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@tiempoEstimado", tiempoEstimado);
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("INCIDENCIA DIAGNOSTICADA", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                limpiar();
            }
        }
Exemple #4
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtDescripcion.Text == "" || txtDispositivo.Text == "")
            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string descripcion = txtDescripcion.Text;
                string prioridad   = "";


                string tipo = "";
                if (rdSoftware.Checked)
                {
                    tipo = "SOFTWARE";
                }
                if (rdHardware.Checked)
                {
                    tipo = "HARDWARE";
                }
                string estatus = "";
                if (btnRegistrar.Enabled == true)
                {
                    estatus = "EN ESPERA";
                }
                DateTime fechaIncidencia = mcFecha.TodayDate.Date;
                string   dispositivo     = txtDispositivo.Text;
                string   strComando      = "insert into incidencias(usuario,fecha,tipo, prioridad, estatus, descripcion, departamento, dispositivo)";
                strComando += "values (@usuario,@fecha,@tipo, @prioridad, @estatus, @descripcion, @departamento, @dispositivo)";
                SqlCommand cmd = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@usuario", cmbUsuario.Text.ToString());
                cmd.Parameters.AddWithValue("@fecha", fechaIncidencia);
                cmd.Parameters.AddWithValue("@tipo", tipo);
                cmd.Parameters.AddWithValue("@prioridad", prioridad);
                cmd.Parameters.AddWithValue("@estatus", estatus);
                cmd.Parameters.AddWithValue("@descripcion", descripcion);
                cmd.Parameters.AddWithValue("@departamento", txtDepartamento.Text);
                cmd.Parameters.AddWithValue("@dispositivo", dispositivo);



                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("INCIDENCIA AGREGADO", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                Limpiar();
            }
        }
Exemple #5
0
        private void btnAsignar_Click(object sender, EventArgs e)
        {
            string clave  = cmbClave.SelectedText.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (cmbClave.SelectedIndex < 0 || cmbClaveUsuario.SelectedIndex < 0 && (rbBaja.Checked == false && rdAlta.Checked == false && rdMedia.Checked == false))
            {
                MessageBox.Show("SELECCIONE UNA OPCION", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string prioridad = " ";
                if (rdAlta.Checked)
                {
                    prioridad = "ALTA";
                }
                if (rdMedia.Checked)
                {
                    prioridad = "MEDIA";
                }
                if (rbBaja.Checked)
                {
                    prioridad = "BAJA";
                }
                string estatus = "ASIGNADA";
                if (btnAsignar.Enabled == true)
                {
                    estatus = "ASIGNADA";
                }

                string     strComando = "update incidencias set tecnico=@tecnico,  estatus=@estatus, prioridad=@prioridad where incidenciaID='" + cmbClave.Text.ToString() + "'";
                SqlCommand cmd        = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@tecnico", txtNombre.Text);
                cmd.Parameters.AddWithValue("@estatus", estatus);
                cmd.Parameters.AddWithValue("@prioridad", prioridad);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("INCIDENCIA ASIGNADA", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                limpiar();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtDispositivo.Text == "" || cmbDepartamento.SelectedIndex <= 0 || txtGarantia.Text == "" || txtMarca.Text == "" || txtModelo.Text == "" || txtProveedor.Text == "" || txtTipo.Text == "")

            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string   departamento = cmbDepartamento.SelectedText.ToString();
                string   dispositivo  = txtDispositivo.Text;
                string   tipo         = txtTipo.Text;
                string   marca        = txtMarca.Text;
                string   proveedor    = txtProveedor.Text;
                string   modelo       = txtModelo.Text;
                string   garantia     = txtGarantia.Text;
                int      cantidad     = 1;
                DateTime FechaCompra  = mcFecha.TodayDate.Date;
                string   strComando   = "insert into equipo(departamento, dispositivo, tipo, marca, fecha, garantia, proveedor, modelo, cantidad)";
                strComando += "values (@departamento, @dispositivo, @tipo, @marca, @fecha, @garantia, @proveedor, @modelo, @cantidad)";
                SqlCommand cmd = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@fecha", FechaCompra);
                cmd.Parameters.AddWithValue("@tipo", tipo);
                cmd.Parameters.AddWithValue("@dispositivo", dispositivo);
                cmd.Parameters.AddWithValue("@marca", marca);
                cmd.Parameters.AddWithValue("@garantia", garantia);
                cmd.Parameters.AddWithValue("@departamento", cmbDepartamento.Text.ToString());
                cmd.Parameters.AddWithValue("@proveedor", proveedor);
                cmd.Parameters.AddWithValue("@modelo", modelo);
                cmd.Parameters.AddWithValue("@cantidad", cantidad);


                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("EQUIPO REGISTRADO", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                Limpiar();
            }
        }
        private void btnEvaluar_Click(object sender, EventArgs e)
        {
            string clave  = cmbClave.SelectedText.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (cmbClave.SelectedIndex < 0 || txtDescripcion.Text == "" || txtTecnico.Text == "" || txtFechaF.Text == "" | txtFechaI.Text == "" || txtTiempo.Text == "" /*|| txtTiempoR.Text == ""*/ || txtUsuario.Text == "")
            {
                MessageBox.Show("HAY ALGUN CAMPO VACÍO", "EXCLAMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DateTime fechaI  = Convert.ToDateTime(txtFechaI.Text);
                DateTime fechaF  = Convert.ToDateTime(txtFechaF.Text);
                TimeSpan tiempor = fechaF.Subtract(fechaI);
                txtTiempoR.Text += tiempor.Days;


                int evaluacion = 0;
                if (rdBueno.Checked)
                {
                    evaluacion = 10;
                }
                if (rdMalo.Checked)
                {
                    evaluacion = 5;
                }

                string     strComando = "update incidencias set evaluacion=@evaluacion where incidenciaID='" + clave + "'";
                SqlCommand cmd        = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@evaluacion", evaluacion);
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("INCIDENCIA EVALUADA", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                limpiar();
            }
        }
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtNuevo.Text == "" || comboBox1.SelectedIndex <= -1 || txtGarantia.Text == "" || txtMarca.Text == "" || txtModelo.Text == "" || txtProveedor.Text == "" || txtTipo.Text == "")

            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string     dispositivo = txtNuevo.Text;
                string     tipo        = txtTipo.Text;
                string     marca       = txtMarca.Text;
                string     proveedor   = txtProveedor.Text;
                string     modelo      = txtModelo.Text;
                string     garantia    = txtGarantia.Text;
                int        cantidad    = 1;
                DateTime   FechaCompra = mcFecha.TodayDate.Date;
                string     strComando  = "update equipo set dispositivo=@dispositivo, tipo=@tipo, marca=@marca, fecha=@fecha, garantia=@garantia, proveedor=@proveedor, modelo=@modelo where dispositivo='" + txtActual.Text.ToString() + "'";
                SqlCommand cmd         = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@fecha", FechaCompra);
                cmd.Parameters.AddWithValue("@tipo", tipo);
                cmd.Parameters.AddWithValue("@dispositivo", dispositivo);
                cmd.Parameters.AddWithValue("@marca", marca);
                cmd.Parameters.AddWithValue("@garantia", garantia);
                cmd.Parameters.AddWithValue("@proveedor", proveedor);
                cmd.Parameters.AddWithValue("@modelo", modelo);
                cmd.Parameters.AddWithValue("@cantidad", cantidad);


                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("EQUIPO REGISTRADO", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
            }
        }
Exemple #9
0
        private void btnResponder_Click(object sender, EventArgs e)
        {
            string clave  = cmbClave.SelectedText.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (cmbClave.SelectedIndex < 0)
            {
                MessageBox.Show("SELECCIONE UNA OPCION", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string justificacion = txtJustificacion.Text;
                string estatus       = " ";
                if (rdAprobado.Checked)
                {
                    estatus = "APROBADO";
                }
                if (rbRechazado.Checked)
                {
                    estatus = "RECHAZADO";
                }


                string     strComando = "update rfc set estatus=@estatus,  justificacion=@justificacion where rfcId='" + cmbClave.Text.ToString() + "'";
                SqlCommand cmd        = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@justificacion", justificacion);
                cmd.Parameters.AddWithValue("@estatus", estatus);


                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("SOLICITUD", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
            }
        }
Exemple #10
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (cmbDepartamento.Text == "" || cmbUsuario.SelectedIndex == -1 || txtFecha.Text == "" || txtDescripcion.Text == "")

            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string fecha       = txtFecha.Text;
                string descripcion = txtDescripcion.Text;
                string estatus     = "";
                if (btnEnviar.Enabled == true)
                {
                    estatus = "RECIBIDO";
                }
                string strComando = "insert into rfc (nombre, descripcion, fecha, nomDepartamento,dispositivo,estatus)";
                strComando += "values (@nombre, @descripcion, @fecha, @nomDepartamento,@dispositivo,@estatus)";
                SqlCommand cmd = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@nomDepartamento", cmbDepartamento.Text);
                cmd.Parameters.AddWithValue("@nombre", cmbUsuario.Text);
                cmd.Parameters.AddWithValue("@descripcion", descripcion);
                cmd.Parameters.AddWithValue("@fecha", fecha);
                cmd.Parameters.AddWithValue("@dispositivo", cmbDispositivo.Text);
                cmd.Parameters.AddWithValue("@estatus", estatus);
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("SOLICITUD ENVIADA", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                Limpiar();
            }
        }
Exemple #11
0
        public String obtenerTipoUsuario()
        {
            String tipo       = "";
            string usuario    = txtUsuario.Text;
            string contrasena = txtContrasena.Text;
            //string clave = cmbClave.SelectedItem.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible Conectar");
                return(null);
            }
            string        strcomand = "select tipo from usuarios where usuario = '" + usuario + "' and contrasena = '" + contrasena + "'";
            SqlDataReader Lector    = UsoDB.Consulta(strcomand, conn);

            if (Lector == null)
            {
                MessageBox.Show("Error en la Consulta");
                conn.Close();
                return(null);
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    //cmbDepartamento.Items.Add(Lector.GetValue(0).ToString());
                    tipo = Lector.GetValue(0).ToString();
                    return(tipo);
                }
            }
            else
            {
                return(null);
            }
            conn.Close();
            return(tipo);
        }
Exemple #12
0
        private void btnLiberar_Click(object sender, EventArgs e)
        {
            string clave  = cmbClave.SelectedText.ToString();
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (cmbClave.SelectedIndex < 0 || txtDescripcion.Text == "" || txtTecnico.Text == "")
            {
                MessageBox.Show("HAY ALGUN CAMPO VACÍO", "EXCLAMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DateTime fechaLiberacion = mcFecha.TodayDate.Date;
                string   estatus         = "";
                if (btnLiberar.Enabled == true)
                {
                    estatus = "LIBERADA";
                }

                string     strComando = "update incidencias set fechaLiberacion=@fechaLiberacion,  estatus=@estatus where incidenciaID='" + cmbClave.Text.ToString() + "'";
                SqlCommand cmd        = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@fechaLiberacion", fechaLiberacion);
                cmd.Parameters.AddWithValue("@estatus", estatus);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("INCIDENCIA LIBERADA", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                conn.Close();
                limpiar();
            }
        }
Exemple #13
0
        public bool BuscaUsuario(string user)
        {
            bool   bandera = false;
            string strCon  = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible conectar con BD");
                return(false);
            }
            SqlDataReader lector        = null;
            string        strComandoSQL = "select usuario from usuarios where usuario='" + user + "'";
            SqlCommand    cmd           = new SqlCommand(strComandoSQL, conn);

            try
            {
                lector = cmd.ExecuteReader();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error en consulta");
                foreach (SqlError err in ex.Errors)
                {
                    MessageBox.Show(err.Message);
                    return(false);
                }
            }
            if (lector.HasRows)
            {
                bandera = true;
            }
            conn.Close();
            return(bandera);
        }
        private void btnAlta_Click(object sender, EventArgs e)
        {
            //string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            string        strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn   = UsoDB.ConectaBD(strCon);

            if (txtIncidencia.Text == "" || txtSolucion1.Text == "" || txtTiempo.Text == "")
            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string incidencia = txtIncidencia.Text;
                string solucion1  = txtSolucion1.Text;
                string solucion2  = txtSolucion2.Text;
                string tiempo     = txtTiempo.Text;
                string strComando = "insert into catalogo(incidencia,solucion1,solucion2,tiemposolucion)";
                strComando += "values (@incidencia, @solucion1,@solucion2, @tiemposolucion)";
                SqlCommand cmd = new SqlCommand(strComando, conn);
                cmd.Parameters.AddWithValue("@incidencia", incidencia);
                cmd.Parameters.AddWithValue("@solucion1", solucion1);
                cmd.Parameters.AddWithValue("@solucion2", solucion2);
                cmd.Parameters.AddWithValue("@tiemposolucion", tiempo);
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("CATALOGO ACTUALIZADO", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Limpiar();
                conn.Close();
            }
        }
Exemple #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtUsuario.Text == "" || txtContrasena.Text == "")
            {
                MessageBox.Show("Datos vacios", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string usuario    = txtUsuario.Text;
                string contrasena = txtContrasena.Text;

                if (BuscaUsuario(usuario) == false || (BuscaClave(contrasena) == false))

                {
                    MessageBox.Show("USUARIO Y/O CONTRASEÑA INCORRECTA", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Limpiar();
                }
                else
                {
                    String tipo = obtenerTipoUsuario();
                    if (tipo.Equals("") || tipo == null)
                    {
                        MessageBox.Show("ERROR AL OBTENER TIPO DE USUARIO", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        if (tipo.Equals("U"))
                        {
                            tipoUsuario = true;
                        }
                        else if (tipo.Equals("A"))
                        {
                            tipoAdministrador = true;
                        }
                        else if (tipo.Equals("T"))
                        {
                            tipoTecnico = true;
                        }
                        else if (tipo.Equals("C"))
                        {
                            tipoCab = true;
                        }
                    }
                    string     strComando = "select @usuario, @contrasena from usuarios";
                    SqlCommand cmd        = new SqlCommand(strComando, conn);
                    cmd.Parameters.AddWithValue("@usuario", usuario);
                    cmd.Parameters.AddWithValue("@contrasena", contrasena);
                    Menu menu = new Menu();
                    menu.Show();
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    conn.Close();
                }
            }
        }
Exemple #16
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True";
            SqlConnection conn = UsoDB.ConectaBD(strCon);

            if (txtNombre.Text == "" || txtNombreUsuario.Text == "" || txtClave.Text == "" || txtEspecialidad.Text == "" || cmbDepartamento.SelectedIndex <= 0)
            {
                MessageBox.Show("Datos vacios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string usuario = txtNombreUsuario.Text;
                if (BuscaUSuario(usuario) == true)
                {
                    MessageBox.Show("NOMBRE DE USUARIO REPETIDO, FAVOR DE PONER OTRO", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    string nombre     = txtNombre.Text;
                    string contrasena = txtClave.Text;
                    txtClave.MaxLength       = 16;
                    txtClave.PasswordChar    = '*';
                    txtClave.CharacterCasing = CharacterCasing.Lower;
                    string especialidad = txtEspecialidad.Text;
                    string tipo         = "";
                    if (rdAdmin.Checked)
                    {
                        tipo = "A";
                    }
                    if (rdTecnico.Checked)
                    {
                        tipo = "T";
                    }
                    if (rdUsuario.Checked)
                    {
                        tipo = "U";
                    }
                    if (rbCab.Checked)
                    {
                        tipo = "C";
                    }
                    string strComando = "insert into usuarios(nombre, usuario, contrasena, tipo, especialidad,departamento)";
                    strComando += "values (@nombre, @usuario, @contrasena, @tipo, @especialidad,@departamento)";
                    SqlCommand cmd = new SqlCommand(strComando, conn);
                    cmd.Parameters.AddWithValue("@nombre", nombre);
                    cmd.Parameters.AddWithValue("@usuario", usuario);
                    cmd.Parameters.AddWithValue("@contrasena", contrasena);
                    cmd.Parameters.AddWithValue("@tipo", tipo);
                    cmd.Parameters.AddWithValue("@especialidad", especialidad);
                    cmd.Parameters.AddWithValue("@departamento", cmbDepartamento.Text);

                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    MessageBox.Show("USUARIO AGREGADO", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    conn.Close();
                    Limpiar();
                }
            }
        }