public List <Existencia_Excel> CargarExistencia_Excel(string OT, string NombreOT, string Cliente, DateTime FechaInicio, DateTime FechaTermino, int Procedimiento)
        {
            List <Existencia_Excel> lista = new List <Existencia_Excel>();

            Conexion   conexion = new Conexion();
            SqlCommand cmd      = conexion.AbrirConexionProduccion();

            if (cmd != null)
            {
                cmd.CommandText = "[SP_PT_Existencia]";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@OT", OT);
                cmd.Parameters.AddWithValue("@NombreOT", NombreOT);
                cmd.Parameters.AddWithValue("@Cliente", Cliente);
                cmd.Parameters.AddWithValue("@FechaInicio", FechaInicio);
                cmd.Parameters.AddWithValue("@FechaTermino", FechaTermino);
                cmd.Parameters.AddWithValue("@Procedimiento", Procedimiento);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Existencia_Excel pro = new Existencia_Excel();
                    pro.OT       = reader["OT"].ToString();
                    pro.NombreOT = reader["NombreOT"].ToString();
                    //  pro.Cliente = reader["Cliente"].ToString();

                    //int ti = Convert.ToInt32(reader["TirajeOT"].ToString());
                    pro.TirajeOT = reader["TirajeOT"].ToString();// ti.ToString("N0").Replace(",", ".");

                    //int desp = Convert.ToInt32(reader["TotalDespachado"].ToString());
                    pro.TotalDespachado = reader["TotalDespachado"].ToString();// desp.ToString("N0").Replace(",", ".");

                    //int reci = Convert.ToInt32(reader["TotalRecepcionado"].ToString());
                    pro.TotalRecepcionado = reader["TotalRecepcionado"].ToString();// reci.ToString("N0").Replace(",", ".");

                    //int sald =
                    pro.Existencia = reader["Existencia"].ToString();// sald.ToString("N0").Replace(",", ".");

                    if (Convert.ToInt32(reader["TirajeOT"].ToString()) <= Convert.ToInt32(reader["TotalDespachado"].ToString()))
                    {
                        pro.Estado = "Liquidada";
                    }
                    else
                    {
                        pro.Estado = "En Proceso";
                    }
                    lista.Add(pro);
                }
            }
            conexion.CerrarConexion();
            return(lista);
        }
        public List <Existencia_Excel> ListaExistencia_Excel(string OP, string NombreOP, DateTime FechaInicio, DateTime FechaTermino, int Procedimiento, int ID, string Ubicacion, string CodigoUbicacion)
        {
            List <Existencia_Excel> lista = new List <Existencia_Excel>();

            Conexion   conexion = new Conexion();
            SqlCommand cmd      = conexion.AbrirConexionProduccion();

            if (cmd != null)
            {
                cmd.CommandText = "SP_List_Existencia";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@OP", OP);
                cmd.Parameters.AddWithValue("@NombreOP", NombreOP);
                cmd.Parameters.AddWithValue("@FechaInicio", FechaInicio);
                cmd.Parameters.AddWithValue("@FechaTermino", FechaTermino);
                cmd.Parameters.AddWithValue("@Procedimiento", Procedimiento);
                cmd.Parameters.AddWithValue("@ID", ID);
                cmd.Parameters.AddWithValue("@Ubicacion", Ubicacion);
                cmd.Parameters.AddWithValue("@CodigoUbicacion", CodigoUbicacion);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Existencia_Excel pro = new Existencia_Excel();
                    // Existencia_Excel pro = new Existencia_Excel();
                    //// pro.id_DespProducto = reader["id_DespProducto"].ToString();
                    // pro.O = reader["OP"].ToString();
                    // pro.NombreOP = reader["NombreOP"].ToString();
                    // pro.Terminacion = reader["Terminacion"].ToString();
                    // pro.TipoEmbalaje = reader["TipoEmbalaje"].ToString();
                    // //
                    // //int c = Convert.ToInt32(reader["Cantidad"].ToString());
                    // //pro.Cantidad = c.ToString("N0");
                    // ////
                    // //int e = Convert.ToInt32(reader["Ejemplares"].ToString());
                    // //pro.Ejemplares = e.ToString("N0");
                    // //
                    // int t = Convert.ToInt32(reader["Total"].ToString());
                    // pro.Total = t.ToString("N0");
                    // //pro.Codigo = reader["Codigo"].ToString();
                    // //
                    // DateTime fec = Convert.ToDateTime(reader["FechaCreacion"].ToString());
                    // pro.FechaCreacion = fec.ToString("dd/MM/yyyy HH:mm");
                    // //
                    // //
                    // string ub = reader["Ubicacion2"].ToString();
                    // if (ub == "")
                    // {
                    //     pro.Ubicacion = "Sin UbicaciĆ³n";
                    // }
                    // else
                    // {
                    //     pro.Ubicacion = ub;
                    // }
                    // string ES = reader["Estado"].ToString();
                    // if (ES == "1")
                    // {
                    //     pro.Codigo = "NO";
                    // }
                    // else
                    // {
                    //     pro.Codigo = "SI";
                    // }
                    // lista.Add(pro);
                }
            }
            conexion.CerrarConexion();
            return(lista);
        }
Example #3
0
        protected void ibExcel_Click(object sender, ImageClickEventArgs e)
        {
            //GridView GridView1 = new GridView();
            //if (txtFechaInicio.Text == "" && txtFechaTermino.Text == "" && txtOP.Text == "" && txtNombreOP.Text == "" && txtCliente.Text == "")
            //{
            //    DateTime vaa = DateTime.Now.AddDays(0);
            //    DateTime va2 = DateTime.Now.AddDays(-7);
            //    string fecha1 = vaa.ToString("MM-dd-yyyy");
            //    string fecha2 = va2.ToString("MM-dd-yyyy");
            //    DateTime FI = Convert.ToDateTime(fecha2 + " 00:00:00");
            //    DateTime FT = Convert.ToDateTime(fecha1 + " 23:59:59");



            //    GridView1.DataSource = inf.CargarExistencia_Excel("", "", "", FI, FT, 0);

            //}
            //else
            //{
            //    if (txtFechaInicio.Text != "" && txtFechaTermino.Text != "")
            //    {
            //        DateTime vaa = Convert.ToDateTime(txtFechaInicio.Text);
            //        DateTime va2 = Convert.ToDateTime(txtFechaTermino.Text);
            //        string fecha1 = vaa.ToString("MM-dd-yyyy");
            //        string fecha2 = va2.ToString("MM-dd-yyyy");
            //        DateTime FI = Convert.ToDateTime(fecha1 + " 00:00:00");
            //        DateTime FT = Convert.ToDateTime(fecha2 + " 23:59:59");

            //        GridView1.DataSource = inf.CargarExistencia_Excel(txtOP.Text, txtNombreOP.Text, txtCliente.Text, FI, FT, 0);

            //    }
            //    else
            //    {
            //        DateTime FI = Convert.ToDateTime("1900-01-01 00:00:00");
            //        DateTime FT = Convert.ToDateTime("1900-01-01 23:59:59");

            //        GridView1.DataSource = inf.CargarExistencia_Excel(txtOP.Text, txtNombreOP.Text, txtCliente.Text, FI, FT, 1);

            //    }
            //}
            //GridView1.DataBind();


            //GridView1.HeaderStyle.BackColor = System.Drawing.Color.DarkGray;
            //GridView1.HeaderStyle.ForeColor = System.Drawing.Color.Black;

            //GridView1.HeaderRow.Cells[1].Text = "Nombre OT";
            //GridView1.HeaderRow.Cells[3].Text = "Tiraje";
            //GridView1.HeaderRow.Cells[4].Text = "Total Recepcionado";
            //GridView1.HeaderRow.Cells[5].Text = "Total Despachado";

            List <Existencia_Excel> lista = new List <Existencia_Excel>();

            for (int i = 0; i < RadGrid2.Items.Count; i++)
            {
                Existencia_Excel pro = new Existencia_Excel();
                pro.OT                = RadGrid2.Items[i]["OT"].Text;
                pro.NombreOT          = RadGrid2.Items[i]["NombreOT"].Text;
                pro.TirajeOT          = RadGrid2.Items[i]["Tiraje"].Text;
                pro.TotalRecepcionado = RadGrid2.Items[i]["RecibidoQGChile"].Text;
                pro.TotalDespachado   = RadGrid2.Items[i]["DespachoEnc"].Text;
                pro.Devolucion        = RadGrid2.Items[i]["id_ProductosTerminados"].Text;//cliente
                pro.Existencia        = RadGrid2.Items[i]["Saldo"].Text;
                string tiraje    = RadGrid2.Items[i]["Tiraje"].Text;
                string totaldesp = RadGrid2.Items[i]["DespachoEnc"].Text;

                if (RadGrid2.Items[i]["Terminacion"].Text == "<div style='Color:Red;'>Por Liquidar</div>")
                {
                    pro.Estado = "Por Liquidar";
                }
                else if (RadGrid2.Items[i]["Terminacion"].Text == "<div style='Color:Green;'>Liquidada</div>")
                {
                    pro.Estado = "Liquidada";
                }
                else
                {
                    pro.Estado = "En Proceso";
                }


                lista.Add(pro);
            }
            GridView GridView1 = new GridView();


            GridView1.DataSource = lista;
            GridView1.DataBind();
            GridView1.HeaderStyle.BackColor   = System.Drawing.Color.DarkGray;
            GridView1.HeaderStyle.ForeColor   = System.Drawing.Color.Black;
            GridView1.HeaderRow.Cells[1].Text = "Nombre OT";
            GridView1.HeaderRow.Cells[2].Text = "Tiraje";
            GridView1.HeaderRow.Cells[3].Text = "Total Recepcionado";
            GridView1.HeaderRow.Cells[4].Text = "Total Despachado";
            //GridView1.HeaderRow.Cells[9].Text = "asdasdsda";

            ////int contador = 0;
            //for (contador = 0; contador < GridView1.Rows.Count; contador++)
            //{
            //    GridViewRow row = GridView1.Rows[contador];
            //    row.Cells[9].Visible = false;
            //}
            //    // Tiraje OT
            //    double TirajeOT = Convert.ToDouble(row.Cells[3].Text);
            //    if (row.Cells[3].Text.Length > 3)
            //    {|
            //        string to = TirajeOT.ToString("N0").Replace(",", ".");
            //        row.Cells[3].Text = to;
            //    }
            //    else
            //    {
            //        string to = TirajeOT.ToString("N0");
            //        row.Cells[3].Text = to;
            //    }
            //    //*********************** Total Recepcionado
            //    double TotalRecepcionado = Convert.ToDouble(row.Cells[4].Text);
            //    if (row.Cells[4].Text.Length > 3)
            //    {
            //        string to = TotalRecepcionado.ToString("N0").Replace(",", ".");
            //        row.Cells[4].Text = to;
            //    }
            //    else
            //    {
            //        string to = TotalRecepcionado.ToString("N0");
            //        row.Cells[4].Text = to;
            //    }
            //    //********************** Total Despachado

            //    double TotalDespachado = Convert.ToDouble(row.Cells[5].Text);
            //    if (row.Cells[5].Text.Length > 3)
            //    {
            //        string to = TotalDespachado.ToString("N0").Replace(",", ".");
            //        row.Cells[5].Text = to;
            //    }
            //    else
            //    {
            //        string to = TotalDespachado.ToString("N0");
            //        row.Cells[5].Text = to;
            //    }
            //    //********************** Existencia

            //    double Existencia = Convert.ToDouble(row.Cells[6].Text);
            //    if (row.Cells[6].Text.Length > 3)
            //    {
            //        string to = Existencia.ToString("N0").Replace(",", ".");
            //        row.Cells[6].Text = to;
            //    }
            //    else
            //    {
            //        string to = Existencia.ToString("N0");
            //        row.Cells[6].Text = to;
            //    }
            //}



            string nombre = "Existencia_" + DateTime.Now.ToShortDateString();

            if (txtFechaInicio.Text != "" || txtFechaTermino.Text != "")
            {
                ExportToExcel(nombre, GridView1, "");//GridView1);
            }
            else
            {
                ExportToExcel(nombre, GridView1, "");//GridView1);
            }
        }