protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Request.UserLanguages[0]); }
         catch { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-CL"); }
         RadGridRF.DataSource = "";
         RadGridRF.DataBind();
         RadGridPlanchas.DataSource = "";
         RadGridPlanchas.DataBind();
         RadGridOtros.DataSource = "";
         RadGridOtros.DataBind();
         RadGridSerExterno.DataSource = "";
         RadGridSerExterno.DataBind();
     }
 }
        protected void btnFiltro_Click(object sender, EventArgs e)
        {
            Controller_EstadoOT controlstatus = new Controller_EstadoOT();
            Estado_OT           status        = controlstatus.BuscarOTLiquidar(txtOT.Text, 1);

            lblOT.Text = status.NombreOT;
            if (status.FechaMaxima != "")
            {
                lblFeliqui.Text    = Convert.ToDateTime(status.FechaMaxima).ToString("dd-MM-yyyy");
                lblFeliqui.Visible = true;
                Label2.Visible     = true;
            }
            lblOT.Visible  = true;
            Label1.Visible = true;
            List <Consumo> lista = controlCons.Listar(txtOT.Text);

            Consumo Papel = new Consumo();

            RadGridRF.DataSource = lista.Where(o => o.Tipo == "Bobina" || o.Tipo == "Pliego").ToList();
            RadGridRF.DataBind();
            foreach (Consumo c in lista.Where(o => o.Tipo == "Bobina" || o.Tipo == "Pliego"))
            {
                if (c.Tipo == "Bobina")
                {
                    Papel.Cons_Bobina = (Convert.ToInt32(c.Cons_Bobina.Substring(0, c.Cons_Bobina.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Bobina)).ToString();
                }
                else
                {
                    Papel.Cons_Pliego = (Convert.ToInt32(c.Cons_Pliego.Substring(0, c.Cons_Pliego.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Pliego)).ToString();
                }
                Papel.Costtot = (Convert.ToDouble(Papel.Costtot) + Convert.ToDouble(c.Costtot.Replace(",", string.Empty))).ToString();
            }
            lblPliego.Text = Convert.ToInt32(Papel.Cons_Pliego).ToString("N0").Replace(",", ".") + " FL";
            lblBobina.Text = Convert.ToInt32(Papel.Cons_Bobina).ToString("N0").Replace(",", ".") + " KG";
            lblTotal.Text  = Convert.ToDouble(Papel.Costtot).ToString("N2");

            if (lista.Where(o => o.Tipo == "Plancha").ToList().Count > 0)
            {
                RadGridPlanchas.DataSource = lista.Where(o => o.Tipo == "Plancha").ToList();
                RadGridPlanchas.DataBind();
                RadGridPlanchadiv.Visible = true;
                RadGridPlanchaTit.Visible = true;
                tablaPlancha.Visible      = true;
                foreach (Consumo c in lista.Where(o => o.Tipo == "Plancha"))
                {
                    Papel.Cons_Plancha = (Convert.ToInt32(c.Cons_Plancha.Substring(0, c.Cons_Plancha.Length - 2).Replace(",", string.Empty)) + Convert.ToInt32(Papel.Cons_Plancha)).ToString();

                    Papel.Ancho = (Convert.ToDouble(Papel.Ancho) + Convert.ToDouble(c.Costtot.Replace(",", string.Empty))).ToString();
                }

                lblPlancha.Text  = Convert.ToInt32(Papel.Cons_Plancha).ToString("N0") + " UN";
                lblTotalplc.Text = Convert.ToDouble(Papel.Ancho).ToString("N2");
            }
            else
            {
                RadGridPlanchadiv.Visible = false;
                RadGridPlanchaTit.Visible = false;
                tablaPlancha.Visible      = false;
            }
            if (lista.Where(o => o.Tipo == "Otro").ToList().Count > 0)
            {
                RadGridOtros.DataSource = lista.Where(o => o.Tipo == "Otro").ToList();
                RadGridOtros.DataBind();
                RadGridOtrosdiv.Visible = true;
                RadGridOtrosTit.Visible = true;
                TableOtros.Visible      = true;
                foreach (Consumo c in lista.Where(o => o.Tipo == "Otro"))
                {
                    Papel.Cons_Otros = (Convert.ToInt32(c.Cons_Otros.Substring(0, c.Cons_Otros.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Otros)).ToString();

                    Papel.Certif = (Convert.ToDouble(Papel.Certif) + Convert.ToDouble(c.Costtot.Replace(",", string.Empty))).ToString();
                }

                lblOtros.Text      = Convert.ToInt32(Papel.Cons_Otros).ToString("N0") + " UN";
                lblTotalOtros.Text = Convert.ToDouble(Papel.Certif).ToString("N2");
            }
            else
            {
                RadGridOtrosdiv.Visible = false;
                RadGridOtrosTit.Visible = false;
                TableOtros.Visible      = false;
            }
            List <Consumo> lista2 = controlCons.ListarSerExterno(txtOT.Text);

            if (lista2.Count > 0)
            {
                DivTitServExt.Visible        = true;
                DivSerExterno.Visible        = true;
                TablaSerExter.Visible        = true;
                RadGridSerExterno.DataSource = lista2;
                RadGridSerExterno.DataBind();
                foreach (Consumo c in lista2)
                {
                    Papel.CostUni = (Convert.ToDouble(Papel.CostUni) + Convert.ToDouble(c.Costtot.Replace(",", string.Empty))).ToString();
                    //aaaa = aaaa + "+" + Convert.ToDouble(c.Costtot.Replace(".", string.Empty).Replace(",", ".")).ToString();
                }
                lblTotalSerExt.Text = Convert.ToDouble(Papel.CostUni).ToString("N2");
                //string b = aaaa;
            }
            else
            {
                DivTitServExt.Visible = false;
                DivSerExterno.Visible = false;
                TablaSerExter.Visible = false;
            }
        }
Esempio n. 3
0
        public void CargarFacturacion(string OT)
        {
            Controller_Consumo controlCons = new Controller_Consumo();

            List <Consumo> lista = controlCons.Listar(OT);

            Consumo Papel = new Consumo();

            RadGridRF.DataSource = lista.Where(o => o.Tipo == "Bobina" || o.Tipo == "Pliego").ToList();
            RadGridRF.DataBind();
            string aaaa = "";

            foreach (Consumo c in lista.Where(o => o.Tipo == "Bobina" || o.Tipo == "Pliego"))
            {
                if (c.Tipo == "Bobina")
                {
                    Papel.Cons_Bobina = (Convert.ToInt32(c.Cons_Bobina.Substring(0, c.Cons_Bobina.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Bobina)).ToString();
                }
                else
                {
                    Papel.Cons_Pliego = (Convert.ToInt32(c.Cons_Pliego.Substring(0, c.Cons_Pliego.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Pliego)).ToString();
                }
                Papel.Costtot = (Convert.ToDouble(Papel.Costtot) + Convert.ToDouble(c.Costtot.Replace(".", string.Empty).Replace(",", "."))).ToString();
            }
            lblPliego.Text = Convert.ToInt32(Papel.Cons_Pliego).ToString("N0").Replace(",", ".") + " FL";
            lblBobina.Text = Convert.ToInt32(Papel.Cons_Bobina).ToString("N0").Replace(",", ".") + " KG";
            lblTotal.Text  = Convert.ToDouble(Papel.Costtot).ToString("N2");

            if (lista.Where(o => o.Tipo == "Plancha").ToList().Count > 0)
            {
                RadGridPlanchas.DataSource = lista.Where(o => o.Tipo == "Plancha").ToList();
                RadGridPlanchas.DataBind();
                RadGridPlanchadiv.Visible = true;
                RadGridPlanchaTit.Visible = true;
                tablaPlancha.Visible      = true;
                foreach (Consumo c in lista.Where(o => o.Tipo == "Plancha"))
                {
                    Papel.Cons_Plancha = (Convert.ToInt32(c.Cons_Plancha.Substring(0, c.Cons_Plancha.Length - 2).Replace(",", string.Empty)) + Convert.ToInt32(Papel.Cons_Plancha)).ToString();

                    Papel.Ancho = (Convert.ToDouble(Papel.Ancho) + Convert.ToDouble(c.Costtot.Replace(".", string.Empty).Replace(",", "."))).ToString();
                }

                lblPlancha.Text  = Convert.ToInt32(Papel.Cons_Plancha).ToString("N0") + " UN";
                lblTotalplc.Text = Convert.ToDouble(Papel.Ancho).ToString("N2");
            }
            else
            {
                RadGridPlanchadiv.Visible = false;
                RadGridPlanchaTit.Visible = false;
                tablaPlancha.Visible      = false;
            }
            if (lista.Where(o => o.Tipo == "Otro").ToList().Count > 0)
            {
                RadGridOtros.DataSource = lista.Where(o => o.Tipo == "Otro").ToList();
                RadGridOtros.DataBind();
                RadGridOtrosdiv.Visible = true;
                RadGridOtrosTit.Visible = true;
                TableOtros.Visible      = true;
                foreach (Consumo c in lista.Where(o => o.Tipo == "Otro"))
                {
                    Papel.Cons_Otros = (Convert.ToInt32(c.Cons_Otros.Substring(0, c.Cons_Otros.Length - 2).Replace(".", string.Empty)) + Convert.ToInt32(Papel.Cons_Otros)).ToString();

                    Papel.Certif = (Convert.ToDouble(Papel.Certif) + Convert.ToDouble(c.Costtot.Replace(".", string.Empty).Replace(",", "."))).ToString();
                }

                lblOtros.Text      = Convert.ToInt32(Papel.Cons_Otros).ToString("N0") + " UN";
                lblTotalOtros.Text = Convert.ToDouble(Papel.Certif).ToString("N2");
            }
            else
            {
                RadGridOtrosdiv.Visible = false;
                RadGridOtrosTit.Visible = false;
                TableOtros.Visible      = false;
            }
            List <Consumo> lista2 = controlCons.ListarSerExterno(OT);

            if (lista2.Count > 0)
            {
                DivTitServExt.Visible        = true;
                DivSerExterno.Visible        = true;
                TablaSerExter.Visible        = true;
                RadGridSerExterno.DataSource = lista2;
                RadGridSerExterno.DataBind();
                foreach (Consumo c in lista2)
                {
                    Papel.CostUni = (Convert.ToDouble(Papel.CostUni) + Convert.ToDouble(c.Costtot.Replace(",", string.Empty))).ToString();
                    aaaa          = aaaa + "+" + Convert.ToDouble(c.Costtot.Replace(".", string.Empty).Replace(",", ".")).ToString();
                }
                lblTotalSerExt.Text = Convert.ToDouble(Papel.CostUni).ToString("N2");
                string b = aaaa;
            }
            else
            {
                DivTitServExt.Visible = false;
                DivSerExterno.Visible = false;
                TablaSerExter.Visible = false;
            }
        }