Beispiel #1
0
        private static void Imprimir(string Funcion, string Reporte)
        {
            try
            {
                string returnValue = null;

                // Look for the name in the connectionStrings section.
                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                // If found, return the connection string.
                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
                SqlConnection sqlConn = new SqlConnection(returnValue);

                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = Funcion;

                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    var filtros = context.Filtros.Where(f => f.cod_rep == Reporte).ToList();
                    foreach (var item in filtros)
                    {
                        switch (item.tipo.Trim())
                        {
                        case "Char":
                            comd.Parameters.Add(item.nombre_par, SqlDbType.Char);
                            //comd.Parameters[comd.Parameters.Count-1].Value = Identificador;
                            break;
                        }
                    }
                }



                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, "pRepResumenVentasGerencial");

                FrmRep Fr = new FrmRep(ds, "RepResumenVentasGerencial.rpt", false);
                Fr.ShowDialog();
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                string returnValue = null;

                // Look for the name in the connectionStrings section.
                ConnectionStringSettings settings =
                    ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                // If found, return the connection string.
                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
                SqlConnection sqlConn = new SqlConnection(returnValue);


                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = "pRepResumenMetasVentas";

                comd.Parameters.Add("@Grupo", SqlDbType.NChar);
                comd.Parameters[0].Value = cboGrupo.Text.Trim();
                comd.Parameters.Add("@Desde", SqlDbType.DateTime);
                comd.Parameters[1].Value = txtDesde.Value;
                comd.Parameters.Add("@Hasta", SqlDbType.DateTime);
                comd.Parameters[2].Value = txtHasta.Value;


                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, "pRepResumenMetasVentas");

                FrmRep Fr = new FrmRep(ds, "RepResumenMetasVtas.rpt", false);
                Fr.Show();
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Programacion del Reporte: RepAutorizacion
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonItem3_Click(object sender, EventArgs e)
        {
            try
            {
                string returnValue = null;

                // Look for the name in the connectionStrings section.
                ConnectionStringSettings settings =
                    ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                // If found, return the connection string.
                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
                SqlConnection sqlConn = new SqlConnection(returnValue);


                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = "pSeleccionarEmpleadobyActivo";

                comd.Parameters.Add("@id_activo", SqlDbType.NChar);
                comd.Parameters[0].Value = txtCo_activo.Text.Trim();



                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, "pSeleccionarEmpleadobyActivo");

                FrmRep Fr = new FrmRep(ds, "RepAutorizacion.rpt", false);
                Fr.Show();
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                string returnValue = null;

                // Look for the name in the connectionStrings section.
                ConnectionStringSettings settings =
                    ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                // If found, return the connection string.
                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                //SqlConnection sqlConn = new SqlConnection("Server=192.168.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
                SqlConnection sqlConn = new SqlConnection(returnValue);


                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = "pRepEmbarque";
                comd.Parameters.Add("@Nro_viaje", SqlDbType.Int);
                comd.Parameters[0].Value = Convert.ToInt32(txtViaje.Text);
                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, "pRepEmbarque");

                FrmRep Fr = new FrmRep(ds, "RepEmbarques.rpt");
                Fr.Show();
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        void GenerarArchivo(Boolean GenerarArchivo)
        {
            try
            {
                string Co_lin   = cboLinea.SelectedIndex == -1 ? null : cboLinea.SelectedValue.ToString().Trim();
                string Co_subl  = cboSub_lin.SelectedIndex == -1 ? null : cboSub_lin.SelectedValue.ToString().Trim();
                string Co_col   = cboColores.SelectedIndex == -1 ? null : cboColores.SelectedValue.ToString().Trim();
                string Co_cat   = cboCat_art.SelectedIndex == -1 ? null : cboCat_art.SelectedValue.ToString().Trim();
                string Cod_proc = cboProce.SelectedIndex == -1 ? null : cboProce.SelectedValue.ToString().Trim();
                string Grupo;
                string Archivo;

                pSeleccionarParametros_Result p = new pSeleccionarParametros_Result();
                //Programa e = new Programa();
                pSeleccionarReportes_Result r = new pSeleccionarReportes_Result();
                //List<pSeleccionarValores_prog_Result> v = new List<pSeleccionarValores_prog_Result>();
                //string returnValue = null;

                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    p     = context.pSeleccionarParametros().FirstOrDefault();
                    r     = context.pSeleccionarReportes("006").FirstOrDefault();
                    Grupo = context.pObtenerGrupo(txtCo_empresa.Text.Trim()).AsParallel().FirstOrDefault().grupo.Trim();
                }

                DataSet ds = new DataSet();
                ds.Tables.Add("pAnalisisCompras");
                ds.Tables[0].Columns.Add("A", typeof(string));
                ds.Tables[0].Columns.Add("co_art", typeof(string));
                ds.Tables[0].Columns.Add("art_des", typeof(string));
                ds.Tables[0].Columns.Add("referencia", typeof(string));
                ds.Tables[0].Columns.Add("comentario", typeof(string));
                ds.Tables[0].Columns.Add("lc_descrip2", typeof(string));
                ds.Tables[0].Columns.Add("ene", typeof(decimal));
                ds.Tables[0].Columns.Add("feb", typeof(decimal));
                ds.Tables[0].Columns.Add("mar", typeof(decimal));
                ds.Tables[0].Columns.Add("abr", typeof(decimal));
                ds.Tables[0].Columns.Add("may", typeof(decimal));
                ds.Tables[0].Columns.Add("jun", typeof(decimal));
                ds.Tables[0].Columns.Add("jul", typeof(decimal));
                ds.Tables[0].Columns.Add("ago", typeof(decimal));
                ds.Tables[0].Columns.Add("sep", typeof(decimal));
                ds.Tables[0].Columns.Add("oct", typeof(decimal));
                ds.Tables[0].Columns.Add("nov", typeof(decimal));
                ds.Tables[0].Columns.Add("dic", typeof(decimal));
                ds.Tables[0].Columns.Add("uni_ventas", typeof(decimal));
                ds.Tables[0].Columns.Add("sugerido", typeof(decimal));
                ds.Tables[0].Columns.Add("orden", typeof(Int32));
                ds.Tables[0].Columns.Add("costo", typeof(decimal));
                ds.Tables[0].Columns.Add("comprar", typeof(decimal));
                ds.Tables[0].Columns.Add("total", typeof(decimal));

                ds.Tables[0].Clear();

                List <Acom> ListaAc = Ac.Where(a => a.comprar > 0).ToList();

                if (ListaAc.Count == 0)
                {
                    MessageBox.Show("Sin datos para mostrar.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    for (int i = 0; i < ListaAc.Count; i++)
                    {
                        DataRow row = ds.Tables[0].NewRow();
                        row["co_art"]      = ListaAc[i].co_art;
                        row["art_des"]     = ListaAc[i].art_des;
                        row["referencia"]  = ListaAc[i].referencia;
                        row["comentario"]  = ListaAc[i].comentario;
                        row["LC_DESCRIP2"] = ListaAc[i].lc_descrip2;
                        row["Costo"]       = ListaAc[i].costo;
                        row["Comprar"]     = ListaAc[i].comprar;
                        row["Total"]       = ListaAc[i].costo * ListaAc[i].comprar;

                        ds.Tables[0].Rows.Add(row);
                        ds.Tables[0].AcceptChanges();
                    }

                    string Filename = r.ruta + @"\" + r.Archivo;
                    CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    oRpt.Load(@Filename);
                    oRpt.SetDataSource(ds);

                    if (GenerarArchivo == false)
                    {
                        FrmRep Fr = new FrmRep(ds, r.Archivo, false);
                        Fr.ShowDialog();
                    }
                    else
                    {
                        Archivo = "";
                        Archivo = @p.ruta_pdf + @"\" + r.Archivo.Replace(".rpt", "").Trim() + " " + System.DateTime.Now.ToFileTime() + ".pdf";
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Archivo.TrimEnd());
                    }
                    oRpt.Close();
                    oRpt.Dispose();
                }
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SqlException ex0)
            {
                MessageBox.Show(ex0.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        void GenerarArchivo(Int32 Id_evento, Boolean GenerarArchivo)
        {
            try
            {
                pSeleccionarParametros_Result p = new pSeleccionarParametros_Result();
                Programa e = new Programa();
                pSeleccionarReportes_Result            r = new pSeleccionarReportes_Result();
                List <pSeleccionarValores_prog_Result> v = new List <pSeleccionarValores_prog_Result>();
                string returnValue = null;

                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    p = context.pSeleccionarParametros().FirstOrDefault();
                    e = context.Programas.Where(ev => ev.id_evento == Id_evento).FirstOrDefault();
                    r = context.pSeleccionarReportes(e.cod_rep.Trim()).FirstOrDefault();
                    v = context.pSeleccionarValores_prog(e.id_evento).ToList();
                }

                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                SqlConnection sqlConn = new SqlConnection(returnValue);

                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = r.funcion.Trim();

                foreach (var item in v)
                {
                    switch (item.tipo.Trim())
                    {
                    case "Char":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Char);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_char;
                        break;

                    case "Int":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Int);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_int;
                        break;

                    case "Decimal":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Decimal);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_dec;
                        break;

                    case "DateTime":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.DateTime);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_date;
                        break;

                    case "Time":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Time);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_time;
                        break;

                    case "Bit":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Bit);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_bit;
                        break;
                    }
                }

                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, r.funcion.Trim());

                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Sin datos para mostrar.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    string Filename = r.ruta + @"\" + r.Archivo;
                    CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    oRpt.Load(@Filename);
                    oRpt.SetDataSource(ds);

                    if (GenerarArchivo == false)
                    {
                        FrmRep Fr = new FrmRep(ds, r.Archivo, false);
                        Fr.ShowDialog();
                    }
                    else
                    {
                        Archivo = "";

                        //string Fecha = ((DateTime.Now.Day < 10) ? "0" : "") + DateTime.Now.Day.ToString() +
                        //      ((DateTime.Now.Month < 10) ? "0" : "") + DateTime.Now.Month.ToString() +
                        //      (DateTime.Now.Year.ToString());

                        //string Hora = ((DateTime.Now.Hour < 10) ? "0" : "") + DateTime.Now.Hour.ToString() +
                        //              ((DateTime.Now.Minute < 10) ? "0" : "") + DateTime.Now.Minute.ToString() +
                        //              ((DateTime.Now.Second < 10) ? "0" : "") + DateTime.Now.Second.ToString();

                        switch (e.Tipo.Trim())
                        {
                        case "PDF":
                            //Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + " F[" + Fecha + "] H[" + Hora + "].pdf";
                            Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + ".pdf";
                            oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Archivo.TrimEnd());
                            break;

                        case "XLS":
                            Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + ".xls";
                            oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Archivo.TrimEnd());
                            break;
                        }
                    }
                    oRpt.Close();
                    oRpt.Dispose();
                }
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SqlException ex0)
            {
                MessageBox.Show(ex0.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }