Пример #1
0
        private void Buscar()
        {
            if (fun.ValidarFecha(txtFechaDesde.Text) == false)
            {
                Mensaje("La fecha desde es incorrecta");
                return;
            }

            if (fun.ValidarFecha(txtFechaHasta.Text) == false)
            {
                Mensaje("La fecha hasta es incorrecta");
                return;
            }

            DateTime fechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime fechaHasta = Convert.ToDateTime(txtFechaHasta.Text);
            string   Patente    = "";

            if (txtPatente.Text != "")
            {
                Patente = txtPatente.Text;
            }
            string Apellido = "";

            if (txtApellido.Text != "")
            {
                Apellido = txtApellido.Text;
            }
            Int32?CodOrden = null;

            if (txtNroOrden.Text != "")
            {
                CodOrden = Convert.ToInt32(txtNroOrden.Text);
            }
            Int32?Tipo = null;

            if (CmbTipo.SelectedIndex > 0)
            {
                Tipo = Convert.ToInt32(CmbTipo.SelectedValue);
            }
            cOrden    orden = new cOrden();
            DataTable trdo  = orden.GetOrdenxFecha(fechaDesde, fechaHasta, Patente, Apellido, CodOrden, Tipo);

            if (Tipo == 2)
            {
                for (int k = 0; k < trdo.Rows.Count; k++)
                {
                    if (Convert.ToDouble(trdo.Rows[k]["Saldo"].ToString()) == 0)
                    {
                        trdo.Rows[k].Delete();
                    }
                }
                trdo.AcceptChanges();
            }

            if (Tipo == 3)
            {
                for (int k = 0; k < trdo.Rows.Count; k++)
                {
                    if (Convert.ToDouble(trdo.Rows[k]["Saldo"].ToString()) > 0)
                    {
                        trdo.Rows[k].Delete();
                    }
                }
                trdo.AcceptChanges();
            }


            trdo = fun.TablaaMiles(trdo, "Costo");
            trdo = fun.TablaaMiles(trdo, "Venta");
            trdo = fun.TablaaMiles(trdo, "ManoObra");
            trdo = fun.TablaaMiles(trdo, "Ganancia");
            trdo = fun.TablaaMiles(trdo, "Efectivo");
            trdo = fun.TablaaMiles(trdo, "Documento");
            trdo = fun.TablaaMiles(trdo, "Cheque");
            trdo = fun.TablaaMiles(trdo, "Tarjeta");
            trdo = fun.TablaaMiles(trdo, "Garantia");
            trdo = fun.TablaaMiles(trdo, "Saldo");
            trdo = fun.TablaaMiles(trdo, "CuentaCorriente");
            if (Tipo == 2)
            {
            }
            grdOrdenes.DataSource            = trdo;
            grdOrdenes.Columns[0].HeaderText = "Orden";
            grdOrdenes.Columns[0].Width      = 80;
            grdOrdenes.Columns[4].Width      = 60;
            grdOrdenes.Columns[5].Visible    = false;
            grdOrdenes.Columns[3].Visible    = false;
            grdOrdenes.Columns[7].Visible    = false;
            txtTotal.Text    = fun.TotalizarColumna(trdo, "Ganancia").ToString();
            txtTotal.Text    = fun.SepararDecimales(txtTotal.Text);
            txtTotal.Text    = fun.FormatoEnteroMiles(txtTotal.Text);
            txtCantidad.Text = trdo.Rows.Count.ToString();
            VerificarUsuario();
            Pintar();
            PintarOrdenesSinSaldo();
        }