Exemplo n.º 1
0
        public static bool AgregarCarrito(string id_inventario, string id_aux, string caja, string tipo)
        {
            string strSQL = "INSERT INTO TMP_CARRITO (ID_INVENTARIO_GENERAL_FK, ID_AUX_FK, ID_USUARIO_FK, TIPO, NUMERO_CAJA) VALUES (" + id_inventario + ", " + id_aux + ", " + Globals.IdUsername + ", '" + tipo + "', '" + caja + "')";

            try
            {
                if (!Conexion.conectar())
                {
                    return(false);
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();

                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 2
0
        public static int CantidadCarrito(string tipo)
        {
            int    n;
            string strSQL;

            if (!Conexion.conectar())
            {
                return(0);
            }

            strSQL = "SELECT COUNT(*) FROM TMP_CARRITO WHERE TIPO = '" + tipo + "' AND ID_USUARIO_FK = " + Globals.IdUsername;
            try
            {
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(0);
                }

                n = Convert.ToInt32(Conexion.ejecutarQueryEscalar());
                Conexion.cerrar();
                return(n);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(0);
            }
        }
Exemplo n.º 3
0
        public static int pendienteConfirmarRecepcion()
        {
            int    n      = -1;
            string strSQL = "";

            try
            {
                strSQL = "SELECT COUNT(*) FROM INVENTARIO_HISTORICO WHERE RECIBIDO = 0 AND ANULADO = 0 AND ID_USUARIO_RECIBE_FK = " + Globals.IdUsername;
                if (!Conexion.conectar())
                {
                    return(-1);
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    Conexion.cerrar();
                    return(-1);
                }

                n = Conexion.ejecutarQueryEscalar();
                Conexion.cerrar();
                return(n);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(-1);
            }
        }
Exemplo n.º 4
0
        public static void limpiarTodoCarrito()
        {
            string strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername;

            try
            {
                if (!Conexion.conectar())
                {
                    Conexion.cerrar();
                    return;
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    Conexion.cerrar();
                    return;
                }

                if (!Conexion.ejecutarQuery())
                {
                    Conexion.cerrar();
                    return;
                }

                Conexion.cerrar();

                return;
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return;
            }
        }
Exemplo n.º 5
0
        public static bool LimpiarCarrito(string tipo)
        {
            string strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername + " AND TIPO = '" + tipo + "'";

            try
            {
                if (!Conexion.conectar())
                {
                    return(false);
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }

                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();

                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 6
0
        public static void ExportarDataTableCSV(System.Data.DataTable dt, string fileName, string nombre_cargo = "", Boolean cabecera = false)
        {
            LoadingScreen.iniciarLoading();

            if (!Directory.Exists(Globals.ExportarPath))
            {
                Directory.CreateDirectory(Globals.ExportarPath);
            }
            if (fileName is null)
            {
                fileName = Globals.ExportarPath + "EXPORTAR_" + Globals.Username + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv";
            }

            try
            {
                string[] outputCsv   = new string[dt.Rows.Count + 1];
                string   columnNames = "";
                int      offset      = 0;
                if (nombre_cargo != "" && cabecera)
                {
                    outputCsv    = new string[dt.Rows.Count + 4];
                    outputCsv[0] = "";
                    outputCsv[1] = nombre_cargo + ",,,FECHA," + DateTime.Now.ToString("yyyy-MM-dd") + ",";
                    outputCsv[2] = "";
                    offset       = 3;
                }
                else
                {
                    outputCsv = new string[dt.Rows.Count + 1];
                }
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    columnNames += dt.Columns[i].ColumnName + System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                }
                outputCsv[0 + offset] += columnNames;

                //Recorremos el DataTable rellenando la hoja de trabajo
                for (int i = 1; (i - 1) <= dt.Rows.Count - 1; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        if (dt.Rows[i - 1][j] != null)
                        {
                            outputCsv[i + offset] += dt.Rows[i - 1][j].ToString() + System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                        }
                    }
                }
                File.WriteAllLines(fileName, outputCsv, Encoding.UTF8);

                Process.Start(fileName);

                LoadingScreen.cerrarLoading();
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "");
                return;
            }
        }
Exemplo n.º 7
0
 public static int ejecutarQueryReturn()
 {
     try
     {
         return(command.ExecuteNonQuery());
     }
     catch (Exception ex)
     {
         GlobalFunctions.casoError(ex, command.CommandText);
         return(0);
     }
 }
Exemplo n.º 8
0
 public static int ejecutarQueryEscalar()
 {
     try
     {
         return(Convert.ToInt32(command.ExecuteScalar()));
     }
     catch (Exception ex)
     {
         GlobalFunctions.casoError(ex, command.CommandText);
         return(-1);
     }
 }
Exemplo n.º 9
0
 public static bool ejecutarQuery()
 {
     try
     {
         command.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         GlobalFunctions.casoError(ex, command.CommandText);
         return(false);
     }
 }
Exemplo n.º 10
0
 public static bool iniciaCommand(string strSQL)
 {
     try
     {
         command = new SqlCommand(strSQL, connection);
         return(true);
     }
     catch (Exception ex)
     {
         GlobalFunctions.casoError(ex, strSQL);
         return(false);
     }
 }
Exemplo n.º 11
0
 public static bool agregarParametroCommand(string nombre, string valor)
 {
     try
     {
         command.Parameters.AddWithValue(nombre, valor);
         return(true);
     }
     catch (Exception ex)
     {
         GlobalFunctions.casoError(ex, "(" + nombre + ", " + valor + ")");
         return(false);
     }
 }
Exemplo n.º 12
0
        public static int lastIdInsert()
        {
            SqlCommand cmd2 = new SqlCommand("SELECT @@IDENTITY", connection);

            try
            {
                return(Convert.ToInt32(cmd2.ExecuteScalar()));
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "SELECT @@IDENTITY");
                return(-1);
            }
        }
Exemplo n.º 13
0
        public static void ExportarDataGridViewCSV(DataGridView dgv, string fileName)
        {
            LoadingScreen.iniciarLoading();

            if (!Directory.Exists(Globals.ExportarPath))
            {
                Directory.CreateDirectory(Globals.ExportarPath);
            }
            if (fileName is null)
            {
                fileName = Globals.ExportarPath + "EXPORTAR_" + Globals.Username + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv";
            }

            try
            {
                string[] outputCsv   = new string[dgv.Rows.Count + 1];
                string   columnNames = "";
                outputCsv = new string[dgv.Rows.Count + 1];

                for (int i = 0; i < dgv.Columns.Count; i++)
                {
                    columnNames += dgv.Columns[i].HeaderText.ToString() + System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                }
                outputCsv[0] += columnNames;

                //Recorremos el DataTable rellenando la hoja de trabajo
                for (int i = 1; (i - 1) <= dgv.Rows.Count - 1; i++)
                {
                    for (int j = 0; j < dgv.Columns.Count; j++)
                    {
                        if (dgv.Rows[i - 1].Cells[j] != null)
                        {
                            outputCsv[i] += dgv.Rows[i - 1].Cells[j].Value.ToString() + System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                        }
                    }
                }
                File.WriteAllLines(fileName, outputCsv, Encoding.UTF8);

                Process.Start(fileName);

                LoadingScreen.cerrarLoading();
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "");
                return;
            }
        }
Exemplo n.º 14
0
        public static DataTable llenarDataTable()
        {
            DataTable dt = new DataTable();

            try
            {
                reader = command.ExecuteReader();
                dt.Load(reader);
                return(dt);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, command.CommandText);
                return(null);
            }
        }
Exemplo n.º 15
0
        public static bool conectar()
        {
            try
            {
                ConnString connString = new ConnString();
                string     conexion;
                if (ConfigurationManager.AppSettings["customConnection"].ToString() != "")
                {
                    conexion = ConfigurationManager.AppSettings["customConnection"].ToString();
                }
                else
                {
                    conexion = connString.GetString(ConfigurationManager.AppSettings["ambiente"].ToString());
                }
                conexion = conexion.Replace("@USER@", Globals.user);
                conexion = conexion.Replace("@PASS@", Globals.pass);

                if (connection != null)
                {
                    if (connection.State == ConnectionState.Open)
                    {
                        return(true);
                    }
                    else
                    {
                        connection = new SqlConnection(conexion);
                    }
                }
                else
                {
                    connection = new SqlConnection(conexion);
                }

                connection.Open();
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "");
                return(false);
            }
        }
Exemplo n.º 16
0
        private void entrar()
        {
            if (tbPassword.Text != "" && tbUsername.Text != "")
            {
                Globals.user = tbUsername.Text;
                Globals.pass = tbPassword.Text;

                try
                {
                    DataTable dt     = new DataTable("Password");
                    String    strSQL = "SELECT ID_USUARIO, NOMBRE_USUARIO, ID_AREA_FK, CAMBIAR_PASSWORD, ACCESO_PERMITIDO FROM USUARIO WHERE NOMBRE_USUARIO = @username AND REAL = 1";

                    if (!Conexion.conectar())
                    {
                        return;
                    }

                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return;
                    }
                    if (!Conexion.agregarParametroCommand("@username", tbUsername.Text))
                    {
                        return;
                    }

                    if (!Conexion.ejecutarQuery())
                    {
                        return;
                    }

                    dt = Conexion.llenarDataTable();
                    if (dt is null)
                    {
                        return;
                    }

                    Conexion.cerrar();


                    Globals.Username   = tbUsername.Text;
                    Globals.IdUsername = Int32.Parse(dt.Rows[0]["ID_USUARIO"].ToString());
                    Globals.IdArea     = Int32.Parse(dt.Rows[0]["ID_AREA_FK"].ToString());

                    //Cambiar Password
                    if (Boolean.Parse(dt.Rows[0]["CAMBIAR_PASSWORD"].ToString()) == true)
                    {
                        CambiarPasswordForm vCambiar = new CambiarPasswordForm();
                        vCambiar.ShowDialog();
                        SimpleLog.Info(tbUsername.Text + " cambió su contraseña");
                        tbPassword.Text      = "";
                        Globals.pass         = "";
                        Globals.loginsuccess = 0;
                    }
                    else
                    {
                        //Acceso Permitido
                        if (Boolean.Parse(dt.Rows[0]["ACCESO_PERMITIDO"].ToString()) == true)
                        {
                            SimpleLog.Info(tbUsername.Text + " inicio Session Exitosamente");
                            Globals.loginsuccess = 1;
                            GlobalFunctions.leerPermisos();

                            this.Close();
                        }
                        else
                        {
                            Globals.loginsuccess = 0;
                            MessageBox.Show("Acceso no permitido\nContactarse con el Administrador");
                            this.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobalFunctions.casoError(ex, "Error Login");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Usuario/Contraseña vacio");
            }
        }
Exemplo n.º 17
0
        public static bool ConfirmarCarrito(string observacion)
        {
            string fecha  = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            string strSQL = "";

            try
            {
                DataTable dt = new DataTable();
                strSQL = "SELECT ID_INVENTARIO_GENERAL_FK AS ID FROM TMP_CARRITO WHERE TIPO = '" + Globals.strRecibirConfirmar + "' AND ID_USUARIO_FK = " + Globals.IdUsername;
                if (!Conexion.conectar())
                {
                    return(false);
                }
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                if (!Conexion.conectar())
                {
                    return(false);
                }

                foreach (DataRow row in dt.Rows)
                {
                    strSQL = "UPDATE INVENTARIO_HISTORICO SET [FECHA_FIN] = " + fecha + ", [RECIBIDO] = 1, [OBSERVACION_RECIBE] = '" + GlobalFunctions.lCadena(observacion) + "' WHERE ID_INVENTARIO_GENERAL_FK = " + row["ID"].ToString() + " AND FECHA_FIN IS NULL AND RECIBIDO = 0 AND ANULADO = 0";

                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }

                    strSQL = "UPDATE INVENTARIO_GENERAL SET [ID_USUARIO_POSEE] = " + Globals.IdUsername + ", [FECHA_POSEE] = " + fecha + " WHERE ID_INVENTARIO_GENERAL = " + row["ID"].ToString();

                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                }

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername + " AND TIPO = '" + Globals.strRecibirConfirmar + "'";
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();

                MessageBox.Show("Recibido");
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 18
0
        public static bool ReingresoCarrito(int entrega, string observacion)
        {
            string strSQL = "";

            try
            {
                DataTable dt = new DataTable();

                string fecha = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                strSQL = "SELECT ID_INVENTARIO_GENERAL_FK AS ID FROM TMP_CARRITO WHERE TIPO = '" + Globals.strRecibirReingreso + "' AND ID_USUARIO_FK = " + Globals.IdUsername;
                if (!Conexion.conectar())
                {
                    return(false);
                }
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                //MODIFICAR CUANDO TODOS TENGAN CUENTA
                foreach (DataRow row in dt.Rows)
                {
                    strSQL = "INSERT INTO INVENTARIO_HISTORICO (ID_INVENTARIO_GENERAL_FK, ID_USUARIO_ENTREGA_FK, ID_USUARIO_RECIBE_FK, ID_AREA_ENTREGA_FK, ID_AREA_RECIBE_FK, FECHA_INICIO, FECHA_FIN, OBSERVACION, RECIBIDO, ANULADO) VALUES (" + row["ID"].ToString() + ", " + entrega + ", " + Globals.IdUsername + ", " + Globals.IdArea + ", " + Globals.IdAreaSelect + ", " + fecha + ", " + fecha + ", '" + observacion + "', 1, 0)";
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                    strSQL = "UPDATE INVENTARIO_GENERAL SET ID_ESTADO_FK = " + Globals.IdCustodiado + ", ID_USUARIO_POSEE = " + Globals.IdUsername + ", FECHA_POSEE = " + fecha + " WHERE ID_INVENTARIO_GENERAL = " + row[0].ToString() + "";
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                }

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername + " AND TIPO = '" + Globals.strRecibirReingreso + "'";
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();

                MessageBox.Show("Proceso Finalizado");
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 19
0
        public static void ExportarDataGridViewExcel(DataGridView dgv, string fileName)
        {
            if (dgv.Rows.Count > 3000)
            {
                DialogResult dialogResult = MessageBox.Show("Tabla tiene mas de 3000 filas\nDesea Continuar", "Muchas Filas", MessageBoxButtons.YesNo);
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
            }

            LoadingScreen.iniciarLoading();
            if (!Directory.Exists(Globals.ExportarPath))
            {
                Directory.CreateDirectory(Globals.ExportarPath);
            }
            if (fileName is null)
            {
                fileName = Globals.ExportarPath + "EXPORTAR_" + Globals.Username + "_" + DateTime.Now.ToString("yyyyMMddhhmmss");
            }
            else
            {
                fileName = Globals.ExportarPath + fileName;
            }

            try
            {
                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
                Workbook  xlWorkBook  = xlApp.Workbooks.Add(Type.Missing);
                Worksheet xlWorkSheet = null;

                xlWorkSheet.EnableCalculation = false;

                xlApp.ScreenUpdating = false;
                xlApp.Calculation    = XlCalculation.xlCalculationManual;

                xlWorkSheet = xlWorkBook.Sheets[1];
                //xlWorkSheet = xlWorkBook.ActiveSheet;

                xlWorkSheet.Name = "Mica1";

                for (int i = 1; i < dgv.Columns.Count + 1; i++)
                {
                    xlWorkSheet.Cells[1, i] = dgv.Columns[i - 1].HeaderText;
                }
                // storing Each row and column value to excel sheet
                for (int i = 0; i < dgv.Rows.Count - 1; i++)
                {
                    for (int j = 0; j < dgv.Columns.Count; j++)
                    {
                        xlWorkSheet.Cells[i + 2, j + 1] = dgv.Rows[i].Cells[j].Value.ToString();
                    }
                }
                xlWorkSheet.EnableCalculation = true;
                // save the application
                xlWorkBook.SaveAs(fileName, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                xlApp.ScreenUpdating = true;
                xlApp.Calculation    = XlCalculation.xlCalculationAutomatic;
                xlApp.Visible        = true;
                LoadingScreen.cerrarLoading();
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "");
                return;
            }
        }
Exemplo n.º 20
0
        public static bool RecibirCajasCarrito()
        {
            string strSQL = "";

            try
            {
                DataTable dt    = new DataTable();
                string    fecha = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";

                strSQL = "SELECT DISTINCT NUMERO_CAJA FROM TMP_CARRITO WHERE TIPO = '" + Globals.strIronMountainRecibir + "' AND ID_USUARIO_FK = " + Globals.IdUsername;
                if (!Conexion.conectar())
                {
                    return(false);
                }
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }
                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                foreach (DataRow row in dt.Rows)
                {
                    strSQL = "UPDATE INVENTARIO_GENERAL SET [ID_ESTADO_FK] = " + Globals.IdCustodiado + ", [ID_USUARIO_POSEE] = " + Globals.IdUsername + ", [FECHA_POSEE] = " + fecha + " WHERE NUMERO_DE_CAJA = '" + row["NUMERO_CAJA"].ToString() + "' AND ID_ESTADO_FK = " + Globals.IdTransito;
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }

                    strSQL = "UPDATE INVENTARIO_HISTORICO SET [ID_USUARIO_RECIBE_FK] = " + Globals.IdUsername + ", [FECHA_FIN] = " + fecha + ", [RECIBIDO] = 1 WHERE NUMERO_CAJA = '" + row["NUMERO_CAJA"].ToString() + "' AND RECIBIDO = 0 AND FECHA_FIN IS NULL AND ID_USUARIO_ENTREGA_FK = " + Globals.IdIM;
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                }

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername + " AND TIPO = '" + Globals.strIronMountainRecibir + "'";
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();
                LoadingScreen.cerrarLoading();
                MessageBox.Show("Recibido");
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 21
0
        public static void leerPermisos()
        {
            string strSQL = "SELECT * FROM PERMISO WHERE ID_USUARIO_FK = " + Globals.IdUsername;

            System.Data.DataTable dt;
            try
            {
                Conexion.conectar();

                if (!Conexion.iniciaCommand(strSQL))
                {
                    Conexion.cerrar();
                }
                if (!Conexion.ejecutarQuery())
                {
                    Conexion.cerrar();
                }

                dt = Conexion.llenarDataTable();

                Conexion.cerrar();

                if (!(dt is null))
                {
                    Globals.auBusqueda           = bool.Parse(dt.Rows[0]["BUSQUEDA"].ToString());
                    Globals.auBusquedaHistorico  = bool.Parse(dt.Rows[0]["BUSQUEDA_HISTORICO"].ToString());
                    Globals.auBusquedaEditar     = bool.Parse(dt.Rows[0]["BUSQUEDA_EDITAR"].ToString());
                    Globals.auEntregar           = bool.Parse(dt.Rows[0]["ENTREGAR"].ToString());
                    Globals.auEntregarExpediente = bool.Parse(dt.Rows[0]["ENTREGAR_EXPEDIENTE"].ToString());
                    Globals.auEntregarDocumento  = bool.Parse(dt.Rows[0]["ENTRAGAR_DOCUMENTO"].ToString());
                    Globals.auRecibir            = bool.Parse(dt.Rows[0]["RECIBIR"].ToString());
                    Globals.auRecibirNuevo       = bool.Parse(dt.Rows[0]["RECIBIR_NUEVO"].ToString());
                    Globals.auRecibirReingreso   = bool.Parse(dt.Rows[0]["RECIBIR_REINGRESO"].ToString());
                    Globals.auRecibirConfirmar   = bool.Parse(dt.Rows[0]["RECIBIR_CONFIRMAR"].ToString());
                    Globals.auRecibirManual      = bool.Parse(dt.Rows[0]["RECIBIR_MANUAL"].ToString());
                    Globals.auPagare             = bool.Parse(dt.Rows[0]["PAGARE"].ToString());
                    Globals.auPagareBuscar       = bool.Parse(dt.Rows[0]["PAGARE_BUSCAR"].ToString());
                    Globals.auPagareRecibir      = bool.Parse(dt.Rows[0]["PAGARE_RECIBIR"].ToString());
                    Globals.auPagareEntregar     = bool.Parse(dt.Rows[0]["PAGARE_ENTREGAR"].ToString());
                    Globals.auLetra                  = bool.Parse(dt.Rows[0]["PAGARE_BUSCAR"].ToString());
                    Globals.auLetraNuevo             = bool.Parse(dt.Rows[0]["LETRA_NUEVO"].ToString());
                    Globals.auLetraEntregar          = bool.Parse(dt.Rows[0]["LETRA_ENTREGAR"].ToString());
                    Globals.auLetraReingreso         = bool.Parse(dt.Rows[0]["LETRA_REINGRESO"].ToString());
                    Globals.auLetraBuscar            = bool.Parse(dt.Rows[0]["LETRA_BUSCAR"].ToString());
                    Globals.auIronMountain           = bool.Parse(dt.Rows[0]["IRONMOUNTAIN"].ToString());
                    Globals.auIronMountainSolicitar  = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_SOLICITAR"].ToString());
                    Globals.auIronMountainRecibir    = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_RECIBIR"].ToString());
                    Globals.auIronMountainArmar      = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_ARMAR"].ToString());
                    Globals.auIronMountainEnviar     = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_ENVIAR"].ToString());
                    Globals.auIronMountainEntregar   = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_ENTREGAR"].ToString());
                    Globals.auIronMountainCargo      = bool.Parse(dt.Rows[0]["IRONMOUNTAIN_CARGO"].ToString());
                    Globals.auBoveda                 = bool.Parse(dt.Rows[0]["BOVEDA"].ToString());
                    Globals.auBovedaCajaRetirar      = bool.Parse(dt.Rows[0]["BOVEDA_CAJA_RETIRAR"].ToString());
                    Globals.auBovedaCajaGuardar      = bool.Parse(dt.Rows[0]["BOVEDA_CAJA_GUARDAR"].ToString());
                    Globals.auBovedaDocumentoRetirar = bool.Parse(dt.Rows[0]["BOVEDA_DOCUMENTO_RETIRAR"].ToString());
                    Globals.auBovedaDocumentoGuardar = bool.Parse(dt.Rows[0]["BOVEDA_DOCUMENTO_GUARDAR"].ToString());
                }
            }
            catch (Exception ex)
            {
                Globals.loginsuccess = 0;
                SimpleLog.Info("Error Permisos " + Globals.Username);
                GlobalFunctions.casoError(ex, strSQL);
            }
        }
Exemplo n.º 22
0
        public static bool verificarSesion(int id)
        {
            System.Data.DataTable dt;
            string strSQL = "";

            try
            {
                if (!Conexion.conectar())
                {
                    Conexion.cerrar();
                    return(false);
                }

                strSQL = "UPDATE USUARIO SET ULTIMA_ACTIVIDAD = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE ID_USUARIO = " + id;

                if (!Conexion.iniciaCommand(strSQL))
                {
                    Conexion.cerrar();
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    Conexion.cerrar();
                    return(false);
                }

                strSQL = "SELECT CERRAR_SESION FROM USUARIO WHERE ID_USUARIO = " + id;

                if (!Conexion.iniciaCommand(strSQL))
                {
                    Conexion.cerrar();
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    Conexion.cerrar();
                    return(false);
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    Conexion.cerrar();
                    return(false);
                }

                Conexion.cerrar();

                if (dt.Rows[0]["CERRAR_SESION"].ToString() == "1")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(true);
            }
        }
Exemplo n.º 23
0
        public static bool EntregarExpedientesCarrito(string observacion)
        {
            DataTable dt = new DataTable();

            string fecha  = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            string strSQL = "";
            int    j      = 0;

            strSQL  = "SELECT TC.ID_INVENTARIO_GENERAL_FK AS ID, ROW_NUMBER() OVER(ORDER BY ID_INVENTARIO_GENERAL) AS NRO, DESCRIPCION_1 AS DEFINICION, DESCRIPCION_2 AS SOLICITUD, DESCRIPCION_3 AS COD_PRESTAMO, DESCRIPCION_4 AS NOMBRE_SOCIO";
            strSQL += " FROM TMP_CARRITO TC LEFT JOIN INVENTARIO_GENERAL IG ON TC.ID_INVENTARIO_GENERAL_FK = IG.ID_INVENTARIO_GENERAL";
            strSQL += " WHERE TIPO = '" + Globals.strEntregarExpediente + "' AND ID_USUARIO_FK = " + Globals.IdUsername;
            try
            {
                if (!Conexion.conectar())
                {
                    return(false);
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }

                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    strSQL = @"INSERT INTO INVENTARIO_HISTORICO (ID_USUARIO_ENTREGA_FK, ID_USUARIO_RECIBE_FK, ID_INVENTARIO_GENERAL_FK, FECHA_INICIO, OBSERVACION, FECHA_FIN, RECIBIDO, ANULADO)
                            VALUES (" + Globals.IdUsername + ", " + Globals.IdUsernameSelect + ", " + row["ID"].ToString() + ", " + fecha + ", '" + observacion + "',";


                    if (!Globals.EntregarConfirmacion)
                    {
                        strSQL += fecha + ", 1, 0)";
                    }
                    else
                    {
                        strSQL += "NULL, 0, 0)";
                    }
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }


                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }


                    if (!Globals.EntregarConfirmacion)
                    {
                        strSQL = "UPDATE INVENTARIO_GENERAL SET [ID_ESTADO_FK] = " + Globals.IdPrestado + ", [ID_USUARIO_POSEE] = " + Globals.IdUsernameSelect + ", [FECHA_POSEE] = " + fecha + " WHERE ID_INVENTARIO_GENERAL = " + row["ID"].ToString() + "";

                        if (!Conexion.iniciaCommand(strSQL))
                        {
                            return(false);
                        }
                        if (!Conexion.agregarParametroCommand("@estado", Globals.IdPrestado.ToString()))
                        {
                            return(false);
                        }
                        if (!Conexion.ejecutarQuery())
                        {
                            return(false);
                        }
                    }
                    j++;
                }

                dt.Columns.Remove("ID");

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = @username_select AND TIPO = @tipo_carrito";

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }

                if (!Conexion.agregarParametroCommand("@username_select", Globals.IdUsername.ToString()))
                {
                    return(false);
                }
                if (!Conexion.agregarParametroCommand("@tipo_carrito", Globals.strEntregarExpediente))
                {
                    return(false);
                }

                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                GlobalFunctions.ExportarDataTableCSV(dt, Globals.ExportarPath + "CARGO_EXP_" + DateTime.Now.ToString("yyyymmddhhmmss") + "_" + Globals.Username + ".csv", "CARGO DE EXPEDIENTES", true);

                Conexion.cerrar();
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 24
0
        public static bool EntregarDocumentosCarrito(string observacion)
        {
            string    fecha  = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            string    strSQL = "";
            int       j      = 0;
            DataTable dt     = new DataTable();

            try
            {
                strSQL  = "SELECT ID_INVENTARIO_GENERAL AS ID, ROW_NUMBER() OVER(ORDER BY ID_INVENTARIO_GENERAL) AS NRO, FORMAT(FECHA_DESDE, 'dd/MM/yyyy') AS DESDE, FORMAT(FECHA_HASTA, 'dd/MM/yyyy') AS HASTA, DESCRIPCION_1, DESCRIPCION_2, DESCRIPCION_3, DESCRIPCION_4, DESCRIPCION_5";
                strSQL += " FROM TMP_CARRITO TC LEFT JOIN INVENTARIO_GENERAL IG ON TC.ID_INVENTARIO_GENERAL_FK = IG.ID_INVENTARIO_GENERAL";
                strSQL += " WHERE TIPO = @tipo_carrito AND ID_USUARIO_FK = @id_usuario";

                if (!Conexion.conectar())
                {
                    return(false);
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }

                if (!Conexion.agregarParametroCommand("@tipo_carrito", Globals.strEntregarDocumento))
                {
                    return(false);
                }
                if (!Conexion.agregarParametroCommand("@id_usuario", Globals.IdUsername.ToString()))
                {
                    return(false);
                }

                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                foreach (DataRow row in dt.Rows)
                {
                    strSQL = @"INSERT INTO INVENTARIO_HISTORICO (ID_USUARIO_ENTREGA_FK, ID_USUARIO_RECIBE_FK, ID_AREA_ENTREGA_FK, ID_AREA_RECIBE_FK, ID_INVENTARIO_GENERAL_FK, FECHA_INICIO, OBSERVACION, FECHA_FIN, RECIBIDO, ANULADO) 
                            VALUES (" + Globals.IdUsername + ", " + Globals.IdUsernameSelect + ", " + Globals.IdArea + ", " + Globals.IdAreaSelect + ", " + row["ID"].ToString() + ", " + fecha + ", '" + observacion + "', ";


                    if (!Globals.EntregarConfirmacion)
                    {
                        strSQL += fecha + ", 1, 0)";
                    }
                    else
                    {
                        strSQL += " NULL, 0, 0)";
                    }

                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }

                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }

                    if (!Globals.EntregarConfirmacion)
                    {
                        strSQL = @"UPDATE INVENTARIO_GENERAL SET [ID_ESTADO_FK] = " + Globals.IdPrestado + ", [ID_USUARIO_POSEE] = '" + Globals.IdUsernameSelect + "', [FECHA_POSEE] = " + fecha
                                 + " WHERE ID_INVENTARIO_GENERAL = " + row["ID"].ToString() + "";

                        if (!Conexion.iniciaCommand(strSQL))
                        {
                            return(false);
                        }

                        if (!Conexion.ejecutarQuery())
                        {
                            return(false);
                        }
                    }
                    j++;
                }

                dt.Columns.Remove("ID");

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = @username_select AND TIPO = @tipo_carrito";

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }

                if (!Conexion.agregarParametroCommand("@username_select", Globals.IdUsername.ToString()))
                {
                    return(false);
                }
                if (!Conexion.agregarParametroCommand("@tipo_carrito", Globals.strEntregarDocumento))
                {
                    return(false);
                }

                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();

                GlobalFunctions.ExportarDataTableCSV(dt, Globals.ExportarPath + "CARGO_DOC_" + DateTime.Now.ToString("yyyymmddhhmmss") + "_" + Globals.Username + ".csv", "CARGO DE DOCUMENTOS", true);

                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 25
0
        public static System.Data.DataTable ConvertExcelToDataTable(string FileName, int index)
        {
            try
            {
                if (!File.Exists(FileName))
                {
                    return(null);
                }

                FileInfo fi       = new FileInfo(FileName);
                long     filesize = fi.Length;

                Microsoft.Office.Interop.Excel.Application xlApp;
                Workbook  xlWorkBook;
                Worksheet xlWorkSheet;
                Range     range;
                var       misValue = Type.Missing;

                // abrir el documento
                xlApp      = new Microsoft.Office.Interop.Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(FileName, misValue, misValue,
                                                  misValue, misValue, misValue, misValue, misValue, misValue,
                                                  misValue, misValue, misValue, misValue, misValue, misValue);

                // seleccion de la hoja de calculo
                // get_item() devuelve object y numera las hojas a partir de 1
                xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(index);

                // seleccion rango activo
                range = xlWorkSheet.UsedRange;

                int rows = range.Rows.Count;

                System.Data.DataTable dt = new System.Data.DataTable();

                int i = 1;

                //no mas de 50 columnas
                while (i < 50 && xlWorkSheet.Cells[1, i].Text != "")
                {
                    dt.Columns.Add(Convert.ToString(xlWorkSheet.Cells[1, i].Text));
                    ++i;
                }
                --i;

                for (int row = 2; row <= rows; row++)
                {
                    DataRow newrow = dt.NewRow();
                    for (int col = 1; col <= i; col++)
                    {
                        // lectura como cadena
                        string cellText = xlWorkSheet.Cells[row, col].Text;
                        cellText = Convert.ToString(cellText);
                        //cellText = cellText.Replace("'", ""); // Comillas simples no pueden pasar en el Texto

                        newrow[col - 1] = cellText;
                    }
                    dt.Rows.Add(newrow);
                }

                xlWorkBook.Close(false, Type.Missing, Type.Missing);
                xlApp.Quit();

                // liberar
                ReleaseObject(xlWorkSheet);
                ReleaseObject(xlWorkBook);
                ReleaseObject(xlApp);

                return(dt);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, "");
                return(null);
            }
        }
Exemplo n.º 26
0
        public static bool SolicitarCajasCarrito()
        {
            string strSQL = "";

            try
            {
                DataTable dt    = new DataTable();
                string    fecha = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                strSQL = "SELECT DISTINCT NUMERO_CAJA FROM TMP_CARRITO WHERE TIPO = '" + Globals.strIronMountainSolicitar + "' AND ID_USUARIO_FK = " + Globals.IdUsername;

                if (!Conexion.conectar())
                {
                    return(false);
                }
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }
                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                foreach (DataRow row in dt.Rows)
                {
                    //TRANSITO
                    strSQL = "UPDATE INVENTARIO_GENERAL SET [ID_ESTADO_FK] = " + Globals.IdTransito + " WHERE NUMERO_DE_CAJA = '" + row["NUMERO_CAJA"].ToString() + "'";
                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                }

                dt      = new DataTable();
                strSQL  = "SELECT DISTINCT NUMERO_CAJA FROM INVENTARIO_GENERAL IG LEFT JOIN (SELECT DISTINCT NUMERO_CAJA FROM TMP_CARRITO WHERE TIPO = '" + Globals.strIronMountainSolicitar + "' AND ID_USUARIO_FK = " + Globals.IdUsername + ") CAJAS";
                strSQL += " ON IG.NUMERO_DE_CAJA = CAJAS.NUMERO_CAJA WHERE CAJAS.NUMERO_CAJA IS NOT NULL";

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }
                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return(false);
                }

                foreach (DataRow row in dt.Rows)
                {
                    strSQL  = "INSERT INTO INVENTARIO_HISTORICO (ID_USUARIO_ENTREGA_FK, FECHA_INICIO, NUMERO_CAJA, OBSERVACION, RECIBIDO, ANULADO) VALUES (";
                    strSQL += Globals.IdIM;
                    strSQL += ", " + fecha + "";
                    strSQL += ", '" + row["NUMERO_CAJA"].ToString() + "'";
                    strSQL += ", '" + Globals.Username + "'";
                    strSQL += ", 0";
                    strSQL += ", 0)";

                    if (!Conexion.iniciaCommand(strSQL))
                    {
                        return(false);
                    }
                    if (!Conexion.ejecutarQuery())
                    {
                        return(false);
                    }
                }

                strSQL = "DELETE FROM TMP_CARRITO WHERE ID_USUARIO_FK = " + Globals.IdUsername + " AND TIPO = '" + Globals.strIronMountainSolicitar + "'";
                if (!Conexion.iniciaCommand(strSQL))
                {
                    return(false);
                }
                if (!Conexion.ejecutarQuery())
                {
                    return(false);
                }

                Conexion.cerrar();
                LoadingScreen.cerrarLoading();
                MessageBox.Show("Solicitado");
                return(true);
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
                return(false);
            }
        }
Exemplo n.º 27
0
        private void btBuscar_Click(object sender, EventArgs e)
        {
            string strSQL = "";
            string fecha;

            try
            {
                LoadingScreen.iniciarLoading();

                if (cbFecha.Checked)
                {
                    fecha = dtpFecha.Value.ToString("yyyy-MM-dd");
                }
                else
                {
                    fecha = "";
                }
                DataTable dt = new DataTable("INVENTARIO_GENERAL");

                strSQL  = @"SELECT ID_INVENTARIO_GENERAL AS ID, TRIM(NUMERO_DE_CAJA) AS CAJA, TRIM(DEP.NOMBRE_DEPARTAMENTO) AS DEPART, TRIM(DOC.NOMBRE_DOCUMENTO) AS DOC, 
                        FORMAT(FECHA_DESDE, 'dd/MM/yyyy') AS DESDE, FORMAT(FECHA_HASTA, 'dd/MM/yyyy') AS HASTA, TRIM(DESCRIPCION_1) AS DESC_1, TRIM(DESCRIPCION_2) AS DESC_2,
                        TRIM(DESCRIPCION_3) AS DESC_3, TRIM(DESCRIPCION_4) AS DESC_4, TRIM(DESCRIPCION_5) AS DESC_5, TRIM(LE.NOMBRE_ESTADO) AS CUSTODIADO, TRIM(U.NOMBRE_USUARIO) AS POSEE, FORMAT(FECHA_POSEE, 'dd/MM/yyyy hh:mm:ss') AS FECHA
                        FROM (((INVENTARIO_GENERAL IG
                        LEFT JOIN LDEPARTAMENTO DEP ON IG.ID_DEPARTAMENTO_FK = DEP.ID_DEPARTAMENTO)
                        LEFT JOIN LDOCUMENTO DOC ON IG.ID_DOCUMENTO_FK = DOC.ID_DOCUMENTO)
                        LEFT JOIN USUARIO U ON U.ID_USUARIO = IG.ID_USUARIO_POSEE)
                        LEFT JOIN LESTADO LE ON LE.ID_ESTADO = IG.ID_ESTADO_FK";
                strSQL += " WHERE 1 = 1";
                if (tbBusquedaLibre.Text != "")
                {
                    strSQL += " AND DESC_CONCAT LIKE '%" + tbBusquedaLibre.Text + "%'";
                }
                if (tbCaja.Text != "")
                {
                    strSQL += " AND NUMERO_DE_CAJA LIKE '%" + tbCaja.Text + "%'";
                }
                if (fecha != "")
                {
                    strSQL += " AND FECHA_DESDE <= @fecha_desde AND FECHA_HASTA >= @fecha_hasta";
                }
                if (tbUsuario.Text != "")
                {
                    strSQL += " AND U.NOMBRE_USUARIO LIKE '%" + tbUsuario.Text + "%'";
                }
                //strSQL += " ORDER BY CODIGO_DOCUMENTO";

                if (!Conexion.conectar())
                {
                    return;
                }

                if (!Conexion.iniciaCommand(strSQL))
                {
                    return;
                }

                if (fecha != "")
                {
                    if (!Conexion.agregarParametroCommand("@fecha_desde", fecha))
                    {
                        return;
                    }
                    if (!Conexion.agregarParametroCommand("@fecha_hasta", fecha))
                    {
                        return;
                    }
                }

                if (!Conexion.ejecutarQuery())
                {
                    return;
                }

                dt = Conexion.llenarDataTable();
                if (dt is null)
                {
                    return;
                }

                Conexion.cerrar();

                dgvBusqueda.DataSource              = dt;
                dgvBusqueda.Columns[0].Visible      = false;
                dgvBusqueda.Columns["DESC_1"].Width = 250;

                LoadingScreen.cerrarLoading();
            }
            catch (Exception ex)
            {
                GlobalFunctions.casoError(ex, strSQL);
            }
        }