Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tabla1 tabla1 = db.Tabla1.Find(id);

            db.Tabla1.Remove(tabla1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "Id,Nombre,Compania,Empleados")] Tabla1 tabla1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tabla1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tabla1));
 }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Compania,Empleados")] Tabla1 tabla1)
        {
            if (ModelState.IsValid)
            {
                db.Tabla1.Add(tabla1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tabla1));
        }
Esempio n. 4
0
        // GET: Tabla1/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tabla1 tabla1 = db.Tabla1.Find(id);

            if (tabla1 == null)
            {
                return(HttpNotFound());
            }
            return(View(tabla1));
        }
        protected void crear_pdf()
        {
            nombres[0] = "Id";
            nombres[1] = "Producto";
            nombres[2] = "Módulo";
            nombres[3] = "Cantidad";
            nombres[4] = "Fecha";
            nombres[5] = "Descripción";
            DataSet datos = new DataSet();

            datos             = bd.GenerarReporte();
            Tabla1.DataSource = datos;
            Tabla1.DataBind();

            int cols = bd.Columnas();

            iTextSharp.text.Table table = new iTextSharp.text.Table(cols);
            table.Cellpadding = 2;
            table.Width       = 100;
            ///////////////////////////////////////////////////////
            /*AQUI SE COMIENZA A CREAR UNA TABLA EN EL PDF USANDO LOS DATOS DEL GRIDVIEW */
            ///////////////////////////////////////////////////////

            for (int i = 0; i < cols; i++)
            {
                string cellText = Server.HtmlDecode

                                      (nombres[i]);

                iTextSharp.text.Cell cell = new iTextSharp.text.Cell(cellText);

                cell.BackgroundColor = new Color(System.Drawing.ColorTranslator.FromHtml("#93a31d"));

                table.AddCell(cell);
            }

            for (int i = 0; i < Tabla1.Rows.Count; i++)
            {
                if (Tabla1.Rows[i].RowType == DataControlRowType.DataRow)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        string cellText = Server.HtmlDecode

                                              (Tabla1.Rows[i].Cells[j].Text);

                        iTextSharp.text.Cell cell = new iTextSharp.text.Cell(cellText);
                        //Set Color of Alternating row
                        if (i % 2 != 0)
                        {
                            cell.BackgroundColor = new Color(System.Drawing.ColorTranslator.FromHtml("#dce0bc"));
                        }

                        table.AddCell(cell);
                    }
                }
            }
            //////////////////////////////////////////////////////////
            /* CREACION DEL DOCUMENTO PDF USANDO LA LIBRERIA iTextSharp*/
            //////////////////////////////////////////////////////////

            Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);

            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

            pdfDoc.Open();

            pdfDoc.Add(table);

            pdfDoc.Close();

            Response.ContentType = "application/pdf";


            Response.AddHeader("content-disposition", "attachment;" +

                               "filename=Inventario.pdf");

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            Response.Write(pdfDoc);

            Response.End();
        }
        protected void reporte_personal(string personal)
        {
            ////////////////////////////////////////////////////////////////////////////////////////////
            /*HACER LA CONSULTA DIRECTAMENTE DESDE ESTE MEDIO PARA EVITAR PROBLEMAS CON FILAS/COLUMNAS */
            ///////////////////////////////////////////////////////////////////////////////////////////

            MySqlConnection con = new MySqlConnection();
            MySqlCommand    cmd;

            con.ConnectionString = "server=localhost; database=carsolio; Uid=root; pwd=;";
            con.Open();
            DataTable datos = new DataTable();

            cmd = new MySqlCommand("select idProd as Codigo, Producto, Cantidad, Fecha  from transacciones where Persona= '" + personal + "'", con);
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);

            adapter.Fill(datos);
            con.Close();


            ///////////////////////////////////////////
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=Transacciones " + personal + ".xls");
            Response.Charset     = "";
            Response.ContentType = "application/vnd.ms-excel";
            using (StringWriter sw = new StringWriter())
            {
                HtmlTextWriter hw = new HtmlTextWriter(sw);

                //To Export all pages
                Tabla1.AllowPaging = false;
                Tabla1.DataSource  = datos;
                Tabla1.DataBind();

                Page page = new Page();
                page.EnableEventValidation = false;

                //Tabla1.HeaderRow.BackColor = System.Drawing.Color.Transparent;

                foreach (TableCell cell in Tabla1.HeaderRow.Cells)
                {
                    cell.BackColor = Tabla1.HeaderStyle.BackColor;
                }
                foreach (GridViewRow row in Tabla1.Rows)
                {
                    row.BackColor = System.Drawing.Color.Transparent;
                    foreach (TableCell cell in row.Cells)
                    {
                        if (row.RowIndex % 2 == 0)
                        {
                            cell.BackColor = Tabla1.AlternatingRowStyle.BackColor;
                        }
                        else
                        {
                            cell.BackColor = Tabla1.RowStyle.BackColor;
                        }
                        cell.CssClass = "textmode";
                    }
                }

                Tabla1.RenderControl(hw);

                //style to format numbers to string
                string style = @"<style> .textmode { } </style>";
                Response.Write(style);
                Response.Output.Write(sw.ToString());
                Response.Flush();
                Response.End();
            }
        }