コード例 #1
0
        protected void Exportar(string Opcion)
        {
            Page.Title = ViewState["PageTit"].ToString().Trim();
            Idioma     = (DataTable)ViewState["TablaIdioma"];
            string VbNomRpt = "";
            CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
            string VbTxtSql = "";

            if (Opcion.Equals("VENTA"))
            {
                CursorIdioma.Alimentar("CurExportPPTVenta", Session["77IDM"].ToString().Trim());
                VbTxtSql = "EXEC SP_PANTALLA_Propuesta 28,@ICC,'','CurExportPPTVenta','WEB',0,0,0,@ICC,'01-1-2009','01-01-1900','01-01-1900'";
                VbNomRpt = "Sales_Quotation";
            }
            else
            {
                CursorIdioma.Alimentar("CurExportPPTRepa", Session["77IDM"].ToString().Trim());
                VbTxtSql = "EXEC SP_TablasMRO 14, '','','','','','','','CurExportPPTRepa','WEB',0,0,0,0,0,@ICC,'01-01-1','02-01-1','03-01-1'";
                VbNomRpt = "Repair_Quotation";
            }
            Cnx.SelecBD();
            using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
            {
                using (SqlCommand SC = new SqlCommand(VbTxtSql, con))
                {
                    SC.CommandTimeout = 90000000;
                    SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        SC.Connection     = con;
                        sda.SelectCommand = SC;
                        using (DataSet ds = new DataSet())
                        {
                            sda.Fill(ds);

                            ds.Tables[0].TableName = "77NeoWeb";
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                foreach (DataTable dt in ds.Tables)
                                {
                                    wb.Worksheets.Add(dt);
                                }
                                Response.Clear();
                                Response.Buffer      = true;
                                Response.ContentType = "application/ms-excel";
                                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomRpt));
                                Response.Charset = "";
                                using (MemoryStream MyMemoryStream = new MemoryStream())
                                {
                                    wb.SaveAs(MyMemoryStream);
                                    MyMemoryStream.WriteTo(Response.OutputStream);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected void BtnExpor_Click(object sender, EventArgs e)
        {
            try
            {
                string StSql, VbNomRpt = "";
                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurExportAeronave", Session["77IDM"].ToString().Trim());
                StSql  = "EXEC SP_PANTALLA_Aeronave 4,'','','','CurExportAeronave',0,0,0,@ICC,'01/01/01','01/01/01','01/01/01'";
                Idioma = (DataTable)ViewState["TablaIdioma"];
                DataRow[] Result = Idioma.Select("Objeto= 'Caption'");
                foreach (DataRow row in Result)
                {
                    VbNomRpt = row["Texto"].ToString().Trim();
                }                                             // Aeronaves
                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand SC = new SqlCommand(StSql, con))
                    {
                        SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        SC.CommandTimeout = 90000000;
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            SC.Connection     = con;
                            sda.SelectCommand = SC;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);

                                ds.Tables[0].TableName = "77NeoWeb";
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomRpt));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Excel Aeronaves", Ex.StackTrace.Substring(Ex.StackTrace.Length > 300 ? Ex.StackTrace.Length - 300 : 0, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }
コード例 #3
0
        protected void IbnExcel_Click(object sender, ImageClickEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            try
            {
                string query = "", VbNomArchivo = "";

                VbNomArchivo = "Incoming";
                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurExpIncoming", Session["77IDM"].ToString().Trim());
                query = "EXEC SP_PANTALLA_Incoming 1,'','','','CurExpIncoming',0,0,0,@ICC,'01-1-2009','01-01-1900','01-01-1900'";
                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        cmd.CommandTimeout = 90000000;
                        cmd.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);

                                int VbLog = VbNomArchivo.Length > 30 ? 30 : VbNomArchivo.Length;
                                ds.Tables[0].TableName = VbNomArchivo.Trim().Substring(0, VbLog);
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
                Page.Title = ViewState["PageTit"].ToString();
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Incoming", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }
コード例 #4
0
        protected void IbtExpExcel_Click(object sender, ImageClickEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            string VbNomRpt = "";

            DataRow[] Result = Idioma.Select("Objeto= 'TitExportar'");
            foreach (DataRow row in Result)
            {
                VbNomRpt = row["Texto"].ToString().Trim();
            }
            CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();

            CursorIdioma.Alimentar("CurTaller", Session["77IDM"].ToString().Trim());
            string VbTxtSql = "EXEC SP_Pantalla_Parametros 13,@TL,'','','','CurTaller',0,0,0,@ICC,'01-01-1','02-01-1','03-01-1'";

            Cnx.SelecBD();
            using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
            {
                using (SqlCommand SC = new SqlCommand(VbTxtSql, con))
                {
                    SC.CommandTimeout = 90000000;
                    SC.Parameters.AddWithValue("@TL", TxtBusqueda.Text.Trim());
                    SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        SC.Connection     = con;
                        sda.SelectCommand = SC;
                        using (DataSet ds = new DataSet())
                        {
                            sda.Fill(ds);

                            ds.Tables[0].TableName = "77NeoWeb";
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                foreach (DataTable dt in ds.Tables)
                                {
                                    wb.Worksheets.Add(dt);
                                }
                                Response.Clear();
                                Response.Buffer      = true;
                                Response.ContentType = "application/ms-excel";
                                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomRpt));
                                Response.Charset = "";
                                using (MemoryStream MyMemoryStream = new MemoryStream())
                                {
                                    wb.SaveAs(MyMemoryStream);
                                    MyMemoryStream.WriteTo(Response.OutputStream);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        // ********************************** Segunda opcion ejecutar proceso  *******************************************/
        protected void BtnExportar2_Click(object sender, EventArgs e)
        {
            CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();

            CursorIdioma.Alimentar("CURRESERVA", "5");


            ViewState["NomBtnExp"] = TxtNombreArchivo.Text.Trim();
            string VbNumProces = TxtNumProc.Text.Trim();
            string StSql       = "EXEC ProyectoUsa @NumProc, @Cia";

            Cnx.SelecBD();
            using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
            {
                using (SqlCommand SC = new SqlCommand(StSql, con))
                {
                    SC.CommandTimeout = 90000000;
                    SC.Parameters.AddWithValue("@NumProc", VbNumProces);
                    SC.Parameters.AddWithValue("@Cia", Session["!dC!@"]);
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        SC.Connection     = con;
                        sda.SelectCommand = SC;
                        using (DataSet ds = new DataSet())
                        {
                            sda.Fill(ds);

                            ds.Tables[0].TableName = ViewState["NomBtnExp"].ToString();
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                foreach (DataTable dt in ds.Tables)
                                {
                                    wb.Worksheets.Add(dt);
                                }
                                Response.Clear();
                                Response.Buffer      = true;
                                Response.ContentType = "application/ms-excel";
                                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", ViewState["NomBtnExp"].ToString()));
                                Response.Charset = "";
                                using (MemoryStream MyMemoryStream = new MemoryStream())
                                {
                                    wb.SaveAs(MyMemoryStream);
                                    MyMemoryStream.WriteTo(Response.OutputStream);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        protected void BtnExportar_Click(object sender, EventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            try
            {
                string    Query = "", VbNomArchivo = "", VbOpc = "";
                DataRow[] Result;
                if (RdbTodos.Checked == true)
                {
                    VbOpc = "";
                }
                if (RdbAbierto.Checked == true)
                {
                    VbOpc = "A";
                }
                if (RdbCumpl.Checked == true)
                {
                    VbOpc = "C";
                }

                Cnx.ValidarFechas(TxtFechI.Text.Trim(), TxtFechF.Text.Trim(), 2);
                var Mensj = Cnx.GetMensj();
                if (!Mensj.ToString().Trim().Equals(""))
                {
                    Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                    foreach (DataRow row in Result)
                    {
                        Mensj = row["Texto"].ToString().Trim();
                    }
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + Mensj + "');", true);
                    Page.Title = ViewState["PageTit"].ToString();
                    return;
                }

                Result = Idioma.Select("Objeto= 'CurExptrRteDiferido'");
                foreach (DataRow row in Result)
                {
                    VbNomArchivo = row["Texto"].ToString().Trim();
                }

                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurExptrRteDiferido", Session["77IDM"].ToString().Trim());
                Query = "EXEC Consultas_General_Manto 4,@Hk,@Prmt,'','CurExptrRteDiferido',0,0,0,@ICC,@FI,@FF,'03-10-00'";
                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand cmd = new SqlCommand(Query, con))
                    {
                        cmd.CommandTimeout = 90000000;
                        cmd.Parameters.AddWithValue("@Prmt", VbOpc);
                        cmd.Parameters.AddWithValue("@Hk", DdlAeronave.Text.Trim() == "" ? "" : DdlAeronave.SelectedItem.Text.Trim());
                        cmd.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        cmd.Parameters.AddWithValue("@FI", Convert.ToDateTime(TxtFechI.Text.Trim()));
                        cmd.Parameters.AddWithValue("@FF", Convert.ToDateTime(TxtFechF.Text.Trim()));
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);

                                int VbLog = VbNomArchivo.Length > 30 ? 30 : VbNomArchivo.Length;
                                ds.Tables[0].TableName = VbNomArchivo.Trim().Substring(0, VbLog);
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
                Page.Title = ViewState["PageTit"].ToString();
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Diferido Reporte Manto", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }
コード例 #7
0
        protected void IbnExcel_Click(object sender, ImageClickEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            try
            {
                string    query = "", VbNomArchivo = "";
                DataRow[] Result;
                Idioma = (DataTable)ViewState["TablaIdioma"];

                Cnx.ValidarFechas(TxtFechI.Text.Trim(), TxtFechF.Text.Trim(), 2);
                var Mensj = Cnx.GetMensj();
                if (!Mensj.ToString().Trim().Equals(""))
                {
                    Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                    foreach (DataRow row in Result)
                    {
                        Mensj = row["Texto"].ToString().Trim();
                    }
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + Mensj + "');", true);
                    Page.Title = ViewState["PageTit"].ToString();
                    return;
                }

                Result = Idioma.Select("Objeto= 'ExptrProxCumpNA'");
                foreach (DataRow row in Result)
                {
                    VbNomArchivo = row["Texto"].ToString().Trim();
                }

                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurExptrProxCump", Session["77IDM"].ToString().Trim());
                query = "EXEC SP_PANTALLA_Informe_Ingenieria 13,'','','','CurExptrProxCump',0,0,0,@CC,@FI,@FF,'01-01-1900'";

                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        cmd.CommandTimeout = 90000000;
                        cmd.Parameters.AddWithValue("@CC", Session["!dC!@"]);
                        cmd.Parameters.AddWithValue("@FI", Convert.ToDateTime(TxtFechI.Text.Trim()));
                        cmd.Parameters.AddWithValue("@FF", Convert.ToDateTime(TxtFechF.Text.Trim()));
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection    = con;
                            sda.SelectCommand = cmd;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);

                                int VbLog = VbNomArchivo.Length > 30 ? 30 : VbNomArchivo.Length;
                                ds.Tables[0].TableName = VbNomArchivo.Trim().Substring(0, VbLog);
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Informe Ingeniería Próximos Cumplimientos", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }
コード例 #8
0
        protected void BtnPnPlanti_Click(object sender, EventArgs e)
        {
            Page.Title = ViewState["PageTit"].ToString().Trim();
            Idioma     = (DataTable)ViewState["TablaIdioma"];
            try
            {
                string VbNomArchivo = "";
                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurPLantillaMaestraExportar", Session["77IDM"].ToString().Trim());

                string    query  = "EXEC SP_PANTALLA_Informe_Ingenieria 3,'','','','CurPLantillaMaestraExportar',0,0,0,@ICC,'01-1-2009','01-01-1900','01-01-1900'";
                DataRow[] Result = Idioma.Select("Objeto= 'NomExpPM'");
                foreach (DataRow row in Result)
                {
                    VbNomArchivo = row["Texto"].ToString().Trim();
                }

                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand SC = new SqlCommand(query, con))
                    {
                        SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            SC.Connection     = con;
                            sda.SelectCommand = SC;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);
                                ds.Tables[0].TableName = "PlMaGrl";
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Histórico", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }
コード例 #9
0
        //**************** Ejecutar ***********************************
        protected void BindEjecutar()
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            try
            {
                if (DdlPN.Text.Trim().Equals(""))
                {
                    GrdStokAlma.DataSource = null; GrdStokAlma.DataBind(); return;
                }
                Cnx.SelecBD();
                using (SqlConnection sqlConB = new SqlConnection(Cnx.GetConex()))
                {
                    string VbPn  = DdlPN.Text.Trim();
                    string VbSn  = DdlSN.Text.Trim();
                    string VbLot = DdlLote.Text.Trim();
                    if (CkbAlterno.Checked == true)
                    {
                        VbPn = ""; VbSn = ""; VbLot = "";
                    }

                    CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                    CursorIdioma.Alimentar("CURDATOSCONSULTA1", Session["77IDM"].ToString().Trim());
                    string VbTxtSql = "EXEC SP_TablasLogistica 5, @Rf,@Pn,@Sn,@Lt,'','','','','CURDATOSCONSULTA1',0,0,@ExpVlr,1,@Idm,@ICC,'01-01-1','02-01-1','03-01-1'";
                    sqlConB.Open();
                    using (SqlCommand SC = new SqlCommand(VbTxtSql, sqlConB))
                    {
                        SC.Parameters.AddWithValue("@Rf", ViewState["CodReferencia"]);
                        SC.Parameters.AddWithValue("@Pn", VbPn);
                        SC.Parameters.AddWithValue("@Sn", VbSn);
                        SC.Parameters.AddWithValue("@Lt", VbLot);
                        SC.Parameters.AddWithValue("@ExpVlr", ViewState["VblCE4"]);
                        SC.Parameters.AddWithValue("@Idm", Session["77IDM"]);
                        SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        using (SqlDataAdapter SDA = new SqlDataAdapter())
                        {
                            using (DataSet DSSM = new DataSet())
                            {
                                SDA.SelectCommand = SC;
                                SDA.Fill(DSSM);
                                DSSM.Tables[0].TableName = "Stock";
                                DSSM.Tables[1].TableName = "StockActual";
                                DSSM.Tables[2].TableName = "Mvtos";
                                DSSM.Tables[3].TableName = "Exprtr";
                                ViewState["DSSM"]        = DSSM;

                                GrdStokAlma.DataSource = DSSM.Tables[0]; GrdStokAlma.DataBind();
                                TxtStockActual.Text    = DSSM.Tables[1].Rows[0]["CantTtl"].ToString().Trim();
                                GrdMvtos.DataSource    = DSSM.Tables[2]; GrdMvtos.DataBind();
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                DataRow[] Result = Idioma.Select("Objeto= 'MensIncovCons'");
                foreach (DataRow row in Result)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                }                                                                                                                                       //

                Cnx.UpdateErrorV2(Session["C77U"].ToString(), ViewState["PFileName"].ToString().Trim(), "UPDATE Detalle PPT", Ex.StackTrace.Substring(Ex.StackTrace.Length > 300 ? Ex.StackTrace.Length - 300 : 0, 300), Ex.Message, Session["77Version"].ToString(), Session["77Act"].ToString());
            }
        }
コード例 #10
0
        protected void IbtExcelRepa_Click(object sender, ImageClickEventArgs e)
        {
            Page.Title = ViewState["PageTit"].ToString().Trim();
            DataRow[] Result;
            Idioma = (DataTable)ViewState["TablaIdioma"];
            if (TxtFechI.Text.Equals("") || TxtFechF.Text.Equals(""))
            {
                Result = Idioma.Select("Objeto= 'MensCampoReq'");
                foreach (DataRow row in Result)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString().Trim() + "');", true);
                }
                if (TxtFechF.Text.Equals(""))
                {
                    TxtFechI.Focus();
                }
                if (TxtFechI.Text.Equals(""))
                {
                    TxtFechI.Focus();
                }
                return;
            }
            Cnx.ValidarFechas(TxtFechI.Text.Trim(), TxtFechF.Text.Trim(), 2);
            var MensjF = Cnx.GetMensj();

            if (!MensjF.ToString().Trim().Equals(""))
            {
                Result = Idioma.Select("Objeto= '" + MensjF.ToString().Trim() + "'");
                foreach (DataRow row in Result)
                {
                    MensjF = row["Texto"].ToString().Trim();
                }
                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + MensjF + "');", true);
                Page.Title = ViewState["PageTit"].ToString();
                return;
            }

            string VbNomArchivo = "";

            Result = Idioma.Select("Objeto= 'NomArcRepa'");
            foreach (DataRow row in Result)
            {
                VbNomArchivo = row["Texto"].ToString().Trim();
            }

            CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();

            CursorIdioma.Alimentar("CurExportLogstcRepa", Session["77IDM"].ToString().Trim());

            string Query = "EXEC SP_Mvto_Entrada_Repa @FI, @FF, '', @NA, @Idm, @ICC";

            Cnx.SelecBD();
            using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
            {
                using (SqlCommand cmd = new SqlCommand(Query, con))
                {
                    cmd.CommandTimeout = 90000000;
                    cmd.Parameters.AddWithValue("@FI", Convert.ToDateTime(TxtFechI.Text.Trim()));
                    cmd.Parameters.AddWithValue("@FF", Convert.ToDateTime(TxtFechF.Text.Trim()));
                    cmd.Parameters.AddWithValue("@NA", "CurExportLogstcRepa");
                    cmd.Parameters.AddWithValue("@Idm", Session["77IDM"]);
                    cmd.Parameters.AddWithValue("@ICC", Session["!dC!@"]);

                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.Connection    = con;
                        sda.SelectCommand = cmd;
                        using (DataSet ds = new DataSet())
                        {
                            sda.Fill(ds);
                            ds.Tables[0].TableName = "Historic";
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                foreach (DataTable dt in ds.Tables)
                                {
                                    wb.Worksheets.Add(dt);
                                }
                                Response.Clear();
                                Response.Buffer      = true;
                                Response.ContentType = "application/ms-excel";
                                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                Response.Charset = "";
                                using (MemoryStream MyMemoryStream = new MemoryStream())
                                {
                                    wb.SaveAs(MyMemoryStream);
                                    MyMemoryStream.WriteTo(Response.OutputStream);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        protected void BtnExport_Click(object sender, EventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            if (ViewState["TblDetalle"] != null)
            {
                Page.Title = ViewState["PageTit"].ToString().Trim();
                TblDetalle = (DataTable)ViewState["TblDetalle"];
                DataTable TbExportar        = new DataTable();
                string    VbNomCursorIdioma = "CurExportCuadroComparativo";

                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar(VbNomCursorIdioma, Session["77IDM"].ToString().Trim());

                Cnx.SelecBD();
                using (SqlConnection SCX = new SqlConnection(Cnx.GetConex()))
                {
                    SCX.Open();
                    using (SqlCommand SC = new SqlCommand("ExportCuadroComparativo", SCX))
                    {
                        try
                        {
                            SC.CommandType = CommandType.StoredProcedure;
                            SqlParameter Prmtrs  = SC.Parameters.AddWithValue("@CurDet", TblDetalle);
                            SqlParameter Prmtrs2 = SC.Parameters.AddWithValue("@IdConfigCia", Session["!dC!@"].ToString());
                            SqlParameter Prmtrs3 = SC.Parameters.AddWithValue("@NomCursorIdioma", VbNomCursorIdioma);
                            Prmtrs.SqlDbType = SqlDbType.Structured;
                            SqlDataAdapter SDA = new SqlDataAdapter();
                            SDA.SelectCommand = SC;
                            SDA.Fill(TbExportar);

                            TbExportar.TableName = "77NeoWeb";
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                wb.Worksheets.Add(TbExportar);
                                Response.Clear();
                                Response.Buffer      = true;
                                Response.ContentType = "application/ms-excel";
                                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", ViewState["PageTit"].ToString().Trim()));
                                Response.Charset = "";
                                using (MemoryStream MyMemoryStream = new MemoryStream())
                                {
                                    wb.SaveAs(MyMemoryStream);
                                    MyMemoryStream.WriteTo(Response.OutputStream);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                        }
                        catch (Exception Ex)
                        {
                            DataRow[] Result = Idioma.Select("Objeto= 'MensErrMod'");
                            foreach (DataRow row in Result)
                            {
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                            }                                                                                                                                       //
                            string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                            Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Cuadro Comparativo", Ex.StackTrace.Substring(Ex.StackTrace.Length > 300 ? Ex.StackTrace.Length - 300 : 0, 300), Ex.Message, VbcatVer, VbcatAct);
                        }
                    }
                }
            }
        }
コード例 #12
0
        protected void IbnExcel_Click(object sender, ImageClickEventArgs e)
        {
            Idioma = (DataTable)ViewState["TablaIdioma"];
            try
            {
                string    VbTxtSql = "", VbNomArchivo = "";
                DataRow[] Result;
                Idioma = (DataTable)ViewState["TablaIdioma"];

                Result = Idioma.Select("Objeto= 'CurExptrAlerProxSvc'");
                foreach (DataRow row in Result)
                {
                    VbNomArchivo = row["Texto"].ToString().Trim();
                }

                CsTypExportarIdioma CursorIdioma = new CsTypExportarIdioma();
                CursorIdioma.Alimentar("CurExptrAlerProxSvc", Session["77IDM"].ToString().Trim());
                if (DdlAeronave.Text.Trim().Equals("0"))
                {
                    VbTxtSql = "EXEC Consultas_General 3, '', '', 'CurExptrAlerProxSvc',@Todo,@Di, @ICC, '06-01-2012', '06-01-2012'";
                }
                else
                {
                    VbTxtSql = "EXEC Consultas_General 3, @A, '', 'CurExptrAlerProxSvc',@Todo,@Di, @ICC, '06-01-2012', '06-01-2012'";
                }

                Cnx.SelecBD();
                using (SqlConnection con = new SqlConnection(Cnx.GetConex()))
                {
                    using (SqlCommand SC = new SqlCommand(VbTxtSql, con))
                    {
                        SC.CommandTimeout = 90000000;
                        SC.Parameters.AddWithValue("@Todo", CkbVisualTodo.Checked == true ? 1 : 0);
                        SC.Parameters.AddWithValue("@Di", TxtDiaVisual.Text);
                        SC.Parameters.AddWithValue("@A", DdlAeronave.SelectedItem.Text.Trim());
                        SC.Parameters.AddWithValue("@ICC", Session["!dC!@"]);
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            SC.Connection     = con;
                            sda.SelectCommand = SC;
                            using (DataSet ds = new DataSet())
                            {
                                sda.Fill(ds);

                                int VbLog = VbNomArchivo.Length > 30 ? 30 : VbNomArchivo.Length;
                                ds.Tables[0].TableName = VbNomArchivo.Trim().Substring(0, VbLog);
                                using (XLWorkbook wb = new XLWorkbook())
                                {
                                    foreach (DataTable dt in ds.Tables)
                                    {
                                        wb.Worksheets.Add(dt);
                                    }
                                    Response.Clear();
                                    Response.Buffer      = true;
                                    Response.ContentType = "application/ms-excel";
                                    Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", VbNomArchivo));
                                    Response.Charset = "";
                                    using (MemoryStream MyMemoryStream = new MemoryStream())
                                    {
                                        wb.SaveAs(MyMemoryStream);
                                        MyMemoryStream.WriteTo(Response.OutputStream);
                                        Response.Flush();
                                        Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
                Page.Title = ViewState["PageTit"].ToString();
            }
            catch (Exception Ex)
            {
                string VbcatUs = Session["C77U"].ToString(), VbcatNArc = ViewState["PFileName"].ToString(), VbcatVer = Session["77Version"].ToString(), VbcatAct = Session["77Act"].ToString();
                Cnx.UpdateErrorV2(VbcatUs, VbcatNArc, "Exportar Informe Ingeniería Próximos Cumplimientos", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct);
            }
        }