Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (button1.Text == "Filtrar errores")
     {
         button1.Text = "Mostrar todo";
         Infragistics.Win.UltraWinGrid.FilterCondition myConditions = new Infragistics.Win.UltraWinGrid.FilterCondition();
         myConditions.CompareValue        = "Y";
         myConditions.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
         dgvDatos.Rows.ColumnFilters["Error"].FilterConditions.Add(myConditions);
     }
     else
     {
         button1.Text = "Filtrar errores";
         UltraGridBand band = this.dgvDatos.DisplayLayout.Bands[0];
         band.ColumnFilters["Error"].FilterConditions.Clear();
     }
 }
Beispiel #2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                dgvDatos.DataSource   = null;
                dgvStocks.DataSource  = null;
                dgvVentas.DataSource  = null;
                dgvTotales.DataSource = null;

                if (cbOrigen.SelectedIndex == 0)
                {
                    this.SetMensaje("Seleccione un almacén origen", 5000, Color.Red, Color.White);
                    return;
                }

                if (cbDestino.SelectedIndex == 0)
                {
                    this.SetMensaje("Seleccione un almacén destino", 5000, Color.Red, Color.White);
                    return;
                }

                using (SqlConnection connection = new SqlConnection(Datos.Clases.Constantes.conectionLog))
                {
                    using (SqlCommand command = new SqlCommand("sp_Inventario", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@TipoConsulta", 13);
                        command.Parameters.AddWithValue("@Almacen_Origen", cbOrigen.SelectedValue);
                        command.Parameters.AddWithValue("@Almacen_Destino", cbDestino.SelectedValue);
                        command.Parameters.AddWithValue("@ItemCode", txtArticulo.Text);
                        command.Parameters.AddWithValue("@CardCode", cbLinea.SelectedValue);
                        command.Parameters.AddWithValue("@nameOrigen", cbOrigen.Text);
                        command.Parameters.AddWithValue("@nameDestino", cbDestino.Text);
                        command.Parameters.Add("@TipoReubicacion", SqlDbType.VarChar, 10).Direction = ParameterDirection.Output;

                        SqlDataAdapter da = new SqlDataAdapter();
                        da.SelectCommand = command;
                        DataTable table = new DataTable();
                        da.Fill(table);

                        TipoFormato         = Convert.ToString(command.Parameters["@TipoReubicacion"].Value.ToString());
                        dgvDatos.DataSource = table;

                        dgvDatos.Rows.ColumnFilters[(int)Columnas1.Linea].FilterConditions.Clear();
                        dgvDatos.Rows.ColumnFilters[(int)Columnas1.Articulo].FilterConditions.Clear();

                        if (Convert.ToInt32(cbLinea.SelectedValue) != 0)
                        {
                            Infragistics.Win.UltraWinGrid.FilterCondition myConditions = new Infragistics.Win.UltraWinGrid.FilterCondition();
                            myConditions.CompareValue        = cbLinea.Text;
                            myConditions.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
                            dgvDatos.Rows.ColumnFilters[(int)Columnas1.Linea].FilterConditions.Add(myConditions);
                        }
                        if (!string.IsNullOrEmpty(txtArticulo.Text))
                        {
                            Infragistics.Win.UltraWinGrid.FilterCondition myConditions = new Infragistics.Win.UltraWinGrid.FilterCondition();
                            myConditions.CompareValue        = txtArticulo.Text;
                            myConditions.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
                            dgvDatos.Rows.ColumnFilters[(int)Columnas1.Articulo].FilterConditions.Add(myConditions);
                        }

                        if (TipoFormato.Equals("TRA1"))
                        {
                            DataTable tbl = new DataTable();
                            tbl.Columns.Add("Total (PZ)", typeof(decimal));
                            tbl.Columns.Add("Total ($)", typeof(decimal));
                            tbl.Columns.Add("Peso (KG)", typeof(decimal));
                            tbl.Columns.Add("Volumen (ft3)", typeof(decimal));

                            DataRow row = tbl.NewRow();
                            decimal pz = decimal.Zero; decimal mm = decimal.Zero; decimal peso = decimal.Zero; decimal vol = decimal.Zero;
                            foreach (UltraGridRow item in dgvDatos.Rows)
                            {
                                if (!item.IsFilteredOut)
                                {
                                    pz   += Convert.ToDecimal(item.Cells[(int)Columnas1.Transferir].Value);
                                    mm   += Convert.ToDecimal(item.Cells[(int)Columnas1.Monto].Value);
                                    peso += Convert.ToDecimal(item.Cells["TP"].Value == DBNull.Value ? decimal.Zero
                                        : item.Cells["TP"].Value);
                                    vol += Convert.ToDecimal(item.Cells["Volumen"].Value);
                                }
                            }
                            row[0] = pz;
                            row[1] = mm;
                            row[2] = peso;
                            row[3] = vol;

                            tbl.Rows.Add(row);
                            dgvTotales.DataSource = tbl;

                            Infragistics.Win.UltraWinCalcManager.UltraCalcManager calcManager;
                            calcManager          = new Infragistics.Win.UltraWinCalcManager.UltraCalcManager(this.Container);
                            dgvDatos.CalcManager = calcManager;
                            calcManager.ReCalc();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.SetMensaje(ex.Message, 5000, Color.Red, Color.White);
            }
        }