Beispiel #1
0
        public static void SetStaicData()
        {
            //ConfigurationSettings.AppSettings["ClientID"].ToString();
            DataTable dtAcademicYear     = GetAcademicYear();
            var       resultAcademicYear = dtAcademicYear.AsEnumerable().OrderByDescending(x => x["StaticID"]).FirstOrDefault();

            //AcademicYear = result["StaticName"].ToString();
            //AcademicYearID = result["StaticID"].ToString();

            try
            {
                DataTable dt = GetClientDetails();

                ClientName    = dt.Rows[0]["ClientName"].ToString();
                ClientAddress = dt.Rows[0]["ClientAddress"].ToString();



                EnumerableRowCollection <DataRow> query = from contact in dt.AsEnumerable()
                                                          where contact.Field <string>("ISDOWNLOAD") == "Y"
                                                          select contact;

                DataView view = query.AsDataView();
                DownloadFile = view.ToTable();



                query = from contact in dt.AsEnumerable()
                        where contact.Field <string>("KEY") == "LOGO" &&
                        contact.Field <string>("ISDOWNLOAD") == "Y"
                        select contact;

                view       = query.AsDataView();
                ClientLogo = view[0]["VALUE"].ToString();



                query = from contact in dt.AsEnumerable()
                        where contact.Field <string>("KEY") == "AcademicYear"
                        select contact;
                view         = query.AsDataView();
                AcademicYear = view[0]["VALUE"].ToString();


                query = from contact in dtAcademicYear.AsEnumerable()
                        where contact.Field <string>("StaticName") == AcademicYear
                        select contact;
                view = query.AsDataView();
                //AcademicYearID = view[0]["StaticID"].ToString();
            }
            catch (Exception ex)
            {
                DAL.logger.Log(ex.Message + Environment.NewLine + ex.StackTrace, MessageType.Error);
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_filters.Count == 0)
            {
                MessageBox.Show("Add filter(s) first!");
                return;
            }

            var owner = ((MainForm)Owner);
            var dt    = owner.DataTable;

            if (m_filter == null)
            {
                m_filter = dt.AsEnumerable();
            }

            if (!checkBox1.Checked)
            {
                m_filter = dt.AsEnumerable();
            }

            if (FilterTable(dt))
            {
                owner.SetDataSource(m_filter.AsDataView());
            }
            else
            {
                MessageBox.Show("Unhandled type?");
            }
        }
        private void comboMeses_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    indesMes = comboMeses.SelectedIndex + 1;
            string mes;

            mes = indesMes.ToString("D" + 2);



            List <Linped> listArt = listaArticulos(indesMes);

            EnumerableRowCollection <DataRow> query = from order in dt.AsEnumerable()
                                                      where order.Field <DateTime>("fecha").Month == indesMes
                                                      orderby order.Field <DateTime>("fecha").Month

                                                      select order;

            DataView view = query.AsDataView();

            dgvPedidosDia.DataSource = view;


            chart1.DataSource = listArt;
            chart1.Series["Articulo"].XValueMember  = "articuloID";
            chart1.Series["Articulo"].XValueType    = ChartValueType.String;
            chart1.Series["Articulo"].YValueMembers = "cantidad";
            chart1.Series["Articulo"].YValueType    = ChartValueType.Int32;
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count == 0)
            {
                MessageBox.Show("Add filter(s) first!");
                return;
            }

            var dt = m_mainForm.DataTable;

            if (m_filter == null)
            {
                m_filter = dt.AsEnumerable();
            }

            if (!checkBox1.Checked)
            {
                m_filter = dt.AsEnumerable();
            }

            var temp = m_filter.AsParallel().AsOrdered().Where(Compare);

            if (temp.Count() != 0)
            {
                m_filter = temp.CopyToDataTable().AsEnumerable();
            }
            else
            {
                m_filter = new DataTable().AsEnumerable();
            }

            m_mainForm.SetDataSource(m_filter.AsDataView());
        }
Beispiel #5
0
        private void button27_Click(object sender, EventArgs e)
        {
            DataTable products = dataSet.Tables["Product"];

            // Query for red colored products.
            EnumerableRowCollection <DataRow> redProductsQuery =
                from product in products.AsEnumerable()
                orderby product.Field <decimal>("ListPrice")
                select product;

            DataView boundView = redProductsQuery.AsDataView();

            bindingSource1.DataSource = boundView;
            // <SnippetQueryDataView1>
            // Create a table from the bound view representing a query of
            // available products.
            DataView  view          = (DataView)bindingSource1.DataSource;
            DataTable productsTable = (DataTable)view.Table;

            // Set RowStateFilter to display the current rows.
            view.RowStateFilter = DataViewRowState.CurrentRows;

            // Query the DataView for red colored products ordered by list price.
            var productQuery = from DataRowView rowView in view
                               where rowView.Row.Field <string>("Color") == "Red"
                               orderby rowView.Row.Field <decimal>("ListPrice")
                               select new { Name  = rowView.Row.Field <string>("Name"),
                                            Color = rowView.Row.Field <string>("Color"),
                                            Price = rowView.Row.Field <decimal>("ListPrice") };

            // Bind the query results to another DataGridView.
            dataGridView2.DataSource = productQuery.ToList();
            // </SnippetQueryDataView1>
        }
Beispiel #6
0
        void fillComboBox()
        {
            // Выборка запросом - см https://msdn.microsoft.com/ru-ru/library/bb669073(v=vs.110).aspx
            // про dataview http://www.c-sharpcorner.com/article/dataview-in-C-Sharp/
            // и http://csharp.net-informations.com/dataview/create-dataview.htm
            EnumerableRowCollection <DataRow> query = from order in baseConnection.dtd.virabotki.AsEnumerable()
                                                      where order.Field <String>("Выработка") == comboBoxVirabotka.Text
                                                      select order;

            DataView view = query.AsDataView();

            comboBoxBlock.DataSource    = view;
            comboBoxBlock.DisplayMember = "Блок";

            comboBoxPodetag.DataSource    = view;
            comboBoxPodetag.DisplayMember = "Подэтаж";


            // для привязок - показываем варианты выбора (их можно редактировать) и готовим новое поле для нового варианта
            EnumerableRowCollection <DataRow> query1 = from order in baseConnection.dtd.priviazki.AsEnumerable()
                                                       where order.Field <String>("Выработка") == comboBoxVirabotka.Text
                                                       select order;
            DataView view1 = query1.AsDataView();

            comboBoxPriviazka.DataSource    = view1;
            comboBoxPriviazka.DisplayMember = "Привязка";
            textBoxPriviazka.Text           = "";
        }
Beispiel #7
0
        public void BindDataTableToImages(DataTable dt)
        {
            EnumerableRowCollection <DataRow> query = from row in dt.AsEnumerable()
                                                      where row.Field <string>(Base.Crawler.CONTET_TYPE_COL).Contains("image")
                                                      select row;

            imagesDataGridView.DataSource        = query.AsDataView();
            imagesDataGridView.SelectionChanged += this.DataGridView_SelectionChanged;
            foreach (DataGridViewColumn column in imagesDataGridView.Columns)
            {
                column.Visible = false;
            }

            imagesDataGridView.Columns[Base.Crawler.ADDRESS_COL].Visible     = true;
            imagesDataGridView.Columns[Base.Crawler.CONTET_TYPE_COL].Visible = true;
            if (Utils.ExtractPageSize)
            {
                imagesDataGridView.Columns[Base.Crawler.SIZE_COL].Visible = true;
            }
            if (Utils.ExtractIndexability)
            {
                imagesDataGridView.Columns[Base.Crawler.INDEXABILITY_COL].Visible        = true;
                imagesDataGridView.Columns[Base.Crawler.INDEXABILITY_STATUS_COL].Visible = true;
            }

            imagesDataGridView.Columns[Base.Crawler.INLINKS_COL].Visible                 = true;
            imagesDataGridView.Columns[Base.Crawler.UNIQUE_INLINKS_COL].Visible          = true;
            imagesDataGridView.Columns[Base.Crawler.UNIQUE_INLINKS_OF_TOTAL_COL].Visible = true;
        }
Beispiel #8
0
        public DataTable GetDisplayTable(string predicate, string expression, string displayMember)
        {
            DataTable displayTable = new DataTable();

            if (string.IsNullOrEmpty(expression))
            {
                DataView dataView = new DataView(CodeTable);

                if (dataView.Count > 0)
                {
                    displayTable = dataView.ToTable(true, this.TextColumnName);
                }
                else
                {
                    displayTable = null;
                    return(displayTable);
                }
            }
            else
            {
                EnumerableRowCollection <DataRow> query =
                    from code in codeTable.AsEnumerable()
                    where code.Field <string>(predicate) == expression
                    select code;

                DataView view = query.AsDataView();
                displayTable = view.ToTable(true, this.TextColumnName);
            }

            displayTable.Columns[0].ColumnName = "Item";

            return(displayTable);
        }
Beispiel #9
0
        private void CargarSucursales()
        {
            Cls_Sucursales_BLL objBLL = new Cls_Sucursales_BLL();
            Cls_Sucursales_DAL objDAL = new Cls_Sucursales_DAL();

            ddlSucursales.DataSource = null;
            ddlSucursales.DataBind();

            objBLL.Listar(ref objDAL);

            DataTable dt = objDAL.DtTabla;

            EnumerableRowCollection <DataRow> query = from dtSucursales in dt.AsEnumerable()
                                                      where dtSucursales.Field <bool>("Activo").Equals(true)
                                                      select dtSucursales;

            DataView view = query.AsDataView();

            ddlSucursales.DataTextField  = "Nombre";
            ddlSucursales.DataValueField = "Id_Sucursal";

            ddlSucursales.DataSource = view;



            ddlSucursales.DataBind();
        }
Beispiel #10
0
        private void CarregarTela(string SortExpression)
        {
            if (IsPostBack)
            {
                ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL();
                int iRepresentante = 0;
                int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);

                //var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, " ", DateTime.Parse(txtDtIni.Text), DateTime.Parse(txtDtFim.Text));
                var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, "00", short.Parse(ddlSemestre.SelectedValue), int.Parse(ddlNumAno.SelectedValue.ToString()));

                DataTable dt1        = dadosGrid;
                DataTable tblOrdered = new DataTable();
                DataView  view       = new DataView();

                var vsSort = ViewState["SortDirection"];

                if (String.IsNullOrEmpty(SortExpression))
                {
                    grdExtratoUtilizacao.DataSource = dt1;
                    grdExtratoUtilizacao.DataBind();
                    return;
                }

                if (dt1.Rows.Count > 0)
                {
                    if (vsSort == null)
                    {
                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }


                    System.Web.UI.WebControls.SortDirection lastDirection = (System.Web.UI.WebControls.SortDirection)ViewState["SortDirection"];

                    if (lastDirection != System.Web.UI.WebControls.SortDirection.Ascending)
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) descending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Ascending;
                    }
                    else
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) ascending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }

                    grdExtratoUtilizacao.DataSource = tblOrdered;
                    grdExtratoUtilizacao.DataBind();
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Load up the children
        /// </summary>
        /// <param name="oParent">parent node</param>
        /// <param name="oTable">datatable with the nodekey</param>
        private void LoadNodeSQLHierarchy(TreeNode oParent, DataTable oTable)
        {
            // make sure there are no existing nodes in case this is a reload of the node
            oParent.Nodes.Clear();

            //get the nodekey from the tag property of the parent node
            SqlHierarchyId iID  = new SqlHierarchyId();
            DataRow        oRow = (DataRow)oParent.Tag;

            iID = (SqlHierarchyId)oRow["NodeKey"];

            //filter the datatable on for the children
            EnumerableRowCollection <DataRow> query = from order in oTable.AsEnumerable()
                                                      where order.Field <SqlHierarchyId>("NodeKey").GetAncestor(1).Equals(iID)
                                                      select order;

            //add the nodes to the tree
            DataView oDV = query.AsDataView();

            foreach (DataRowView oDR in oDV)
            {
                TreeNode oNode = new TreeNode(oDR["Element"].ToString());
                oNode.Tag = oDR.Row;

                LoadNodeSQLHierarchy(oNode, oTable);
                oParent.Nodes.Add(oNode);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Uses Linq to filter the table
        /// additional info from: http://nesteruk.org/blog/post/Working-with-SQL-Server-hierarchical-data-and-Silverlight.aspx#Reference6
        /// </summary>
        /// <param name="oTV">Treeview to load</param>
        /// <param name="oTable">datatable with the nodekey</param>
        private void LoadTreeSQLHierarchy(TreeView oTV, DataTable oTable, string sKeyField, string sTextField)
        {
            oTV.Nodes.Clear();

            TreeNode oNode;

            //get an empty id to get the top node
            SqlHierarchyId iID = new SqlHierarchyId();

            //filter the table using linq. See blog for equals()/== issue
            EnumerableRowCollection <DataRow> query = from TNodes in oTable.AsEnumerable()
                                                      where TNodes.Field <SqlHierarchyId>(sKeyField).GetAncestor(1).Equals(iID)
                                                      select TNodes;

            //convert to a dataview because I am comfortable with a dataview.
            DataView oDV = query.AsDataView();

            if (oDV.Count == 1)
            {
                //load up a node
                oNode = new TreeNode(oDV[0][sTextField].ToString());

                //put the datarow into the tag property
                oNode.Tag = oDV[0].Row;

                //load up the children
                LoadNodeSQLHierarchy(oNode, oTable);

                //add the node hierarchy to the tree
                oTV.Nodes.Add(oNode);
            }
        }
        private void CargarPedidosUsuario()
        {
            Cls_Paquetes_BLL objBLL = new Cls_Paquetes_BLL();
            Cls_Paquetes_DAL objDAL = new Cls_Paquetes_DAL();

            gdvPaquetes.DataSource = null;
            gdvPaquetes.DataBind();

            objBLL.Listar(ref objDAL);
            string prueba = txtBuscar.Value;

            if (objDAL.SError == string.Empty)
            {
                gdvPaquetes.SelectedIndex = -1;
                if (txtBuscar.Value == string.Empty)
                {
                    DataTable dt = objDAL.DtTablaPaquetes;

                    EnumerableRowCollection <DataRow> query = from dtTablaPaquetes in dt.AsEnumerable()
                                                              where dtTablaPaquetes.Field <string>("Usuario").ToLower().Replace(" ", "").Contains(Usuario.ToLower().Replace(" ", ""))
                                                              select dtTablaPaquetes;

                    DataView view = query.AsDataView();

                    gdvPaquetes.DataSource = view;
                }
                else
                {
                    DataTable dt = objDAL.DtTablaPaquetes;

                    EnumerableRowCollection <DataRow> query = from dtSucursales in dt.AsEnumerable()
                                                              where dtSucursales.Field <string>("DetallePaquete").ToLower().Replace(" ", "").Contains(txtBuscar.Value.ToLower().Replace(" ", ""))
                                                              select dtSucursales;

                    DataView view = query.AsDataView();

                    gdvPaquetes.DataSource = view;
                }


                gdvPaquetes.DataBind();

                if (gdvPaquetes.Rows.Count > 0)
                {
                    gdvPaquetes.Visible = true;
                    lblMensaje.Visible  = false;
                    lblMensaje.Text     = "";
                }
                else
                {
                    gdvPaquetes.Visible = false;
                    lblMensaje.Visible  = true;
                    lblMensaje.Text     = "No hay datos que mostrar";
                }
            }
            else
            {
                lblMensaje.Text = objDAL.SError;
            }
        }
        private void cbTime_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataSet cloneSet = ds2.Copy();

            cloneSet.Tables["appointment"].Columns["jobType"].ColumnName = "Job Type";
            cloneSet.Tables["appointment"].Columns["Name"].ColumnName    = "Name";
            cloneSet.Tables["appointment"].Columns["date"].ColumnName    = "Date";
            cloneSet.Tables["appointment"].Columns["time"].ColumnName    = "Time";
            cloneSet.Tables["appointment"].Columns["status"].ColumnName  = "Status";
            cloneSet.Tables["appointment"].Columns["id"].ColumnName      = "Id";
            ComboBoxItem cb = (ComboBoxItem)cbTime.SelectedItem;

            if (cb.Content.ToString().ToLower() != "all")
            {
                EnumerableRowCollection <DataRow> query = from datatable in cloneSet.Tables[0].AsEnumerable()
                                                          .Where(r => r.Field <string>("Time").ToLower() == cb.Content.ToString().ToLower())
                                                          orderby datatable.Field <string>("name")
                                                          select datatable;

                DataView view  = query.AsDataView();
                var      table = view.ToTable(false, "Id", "Name", "Job Type", "Date", "Time", "Status");
                grdInfo.ItemsSource = table.AsDataView();
            }
            else
            {
                Default();
            }
        }
Beispiel #15
0
        private void CreateTableAndSortUsingLinq()
        {
            DataColumn dc1 = new DataColumn("Code", typeof(string));
            DataColumn dc2 = new DataColumn("Description", typeof(string));
            DataTable  dt  = new DataTable();

            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            dt.Rows.Add(dt.NewRow());
            dt.Rows[0]["Code"]        = "3";
            dt.Rows[0]["Description"] = "Three";
            dt.Rows.Add(dt.NewRow());
            dt.Rows[1]["Code"]        = "1";
            dt.Rows[1]["Description"] = "One";
            dt.Rows.Add(dt.NewRow());
            dt.Rows[2]["Code"]        = "2";
            dt.Rows[2]["Description"] = "Two";
            dt.Rows.Add(dt.NewRow());
            dt.Rows[3]["Code"]        = "10";
            dt.Rows[3]["Description"] = "Ten";
            dt.AcceptChanges();

            DataTable dt2 = dt;
            DataView  dv2 = dt2.AsDataView();

            dv2.Sort = "Code Asc";
            DataTable dt3 = dv2.ToTable();

            EnumerableRowCollection <DataRow> sortedTable = from row in dt.AsEnumerable()
                                                            orderby int.Parse(row.Field <string>("Code")) ascending
                                                            select row;

            dt = sortedTable.AsDataView().ToTable();

            dt2.Columns.Add("Sort", typeof(int));
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                dt2.Rows[i]["Sort"] = int.Parse(dt2.Rows[i]["Code"].ToString());
            }
            dt2.AcceptChanges();
            dt2.AsDataView().Sort = "Sort";
            dt3      = dt2.AsDataView().ToTable();
            dv2      = dt2.AsDataView();
            dv2.Sort = "Sort asc";
            dt2      = dv2.ToTable();
            dt2.Columns.Remove("Sort");
            dt2.AcceptChanges();

            TestPage t = new TestPage();

            ddlTest.DataSource     = dt;
            ddlTest.DataTextField  = "Description";
            ddlTest.DataValueField = "Code";
            ddlTest.DataBind();
            ddlTest.Items.Insert(0, new ListItem("Please Select", "0"));
            ddlTest.SelectedIndex = 0;
        }
        private void txtPesquisa_TextChanged(object sender, EventArgs e)
        {
            EnumerableRowCollection <DataRow> query = from objPesquisa in dt.AsEnumerable()
                                                      where objPesquisa.Field <String>("descricao").Contains(txtPesquisa.Text.ToUpper())
                                                      select objPesquisa;

            DataView view = query.AsDataView();

            gridPesquisa.DataSource = view;
        }
        private void CargarCategorias()
        {
            Cls_Categoria_BLL objBLL = new Cls_Categoria_BLL();
            Cls_Categoria_DAL objDAL = new Cls_Categoria_DAL();

            gdvCategorias.DataSource = null;
            gdvCategorias.DataBind();

            objBLL.Listar(ref objDAL);
            string prueba = txtBuscar.Value;
            if (objDAL.SError == string.Empty)
            {
                gdvCategorias.SelectedIndex = -1;
                if (txtBuscar.Value == string.Empty)
                {
                    gdvCategorias.DataSource = objDAL.DtTablaCategoria;
                }
                else
                {
                    DataTable dt = objDAL.DtTablaCategoria;

                    //.REPLACE PARA LA BUSQUEDA ELIMINA LOS ESPACIO EN BLANCO
                    EnumerableRowCollection<DataRow> query = from dtcategoria in dt.AsEnumerable()
                                                             where dtcategoria.Field<string>("Nombre").ToLower().Replace
                                                             (" ", "").Contains(txtBuscar.Value.ToLower().Replace(" ", ""))
                                                             select dtcategoria;

                    DataView view = query.AsDataView();

                    gdvCategorias.DataSource = view;

                }


                gdvCategorias.DataBind();

                if (gdvCategorias.Rows.Count > 0)
                {
                    gdvCategorias.Visible = true;
                    lblMensaje.Visible = false;
                    lblMensaje.Text = "";
                }
                else
                {
                    gdvCategorias.Visible = false;
                    lblMensaje.Visible = true;
                    lblMensaje.Text = "No hay datos que mostrar";
                }
            }
            else
            {
                lblMensaje.Text = objDAL.SError;
            }
        }
Beispiel #18
0
        private void CargarTarjetas()
        {
            Cls_Tarjetas_BLL objBLL = new Cls_Tarjetas_BLL();
            Cls_Tarjetas_DAL objDAL = new Cls_Tarjetas_DAL();

            objDAL.SPersona = Session["UserLogin"].ToString();

            objBLL.Filtrar(ref objDAL);

            gdvTarjetas.DataSource = null;
            gdvTarjetas.DataBind();

            objBLL.Filtrar(ref objDAL);
            if (objDAL.SError == string.Empty)
            {
                gdvTarjetas.SelectedIndex = -1;
                if (txtBuscar.Value == string.Empty)
                {
                    gdvTarjetas.DataSource = objDAL.DtTablaTarjetas;
                }
                else
                {
                    DataTable dt = objDAL.DtTablaTarjetas;

                    EnumerableRowCollection <DataRow> query = from dtUsuarios in dt.AsEnumerable()
                                                              where dtUsuarios.Field <string>("Numero_tarjeta").ToLower().Contains(txtBuscar.Value.ToLower())
                                                              select dtUsuarios;

                    DataView view = query.AsDataView();

                    gdvTarjetas.DataSource = view;
                }


                gdvTarjetas.DataBind();

                if (gdvTarjetas.Rows.Count > 0)
                {
                    gdvTarjetas.Visible = true;
                    lblMensaje.Visible  = false;
                    lblMensaje.Text     = "";
                }
                else
                {
                    gdvTarjetas.Visible = false;
                    lblMensaje.Visible  = true;
                    lblMensaje.Text     = "No hay datos que mostrar";
                }
            }
            else
            {
                lblMensaje.Text = objDAL.SError;
            }
        }
Beispiel #19
0
        public DataTable GetDisplayTable(string predicate, string expression, string displayMember, string formcodetable)
        {
            DataTable displayTable = new DataTable();

            if (string.IsNullOrEmpty(expression))
            {
                DataView dataView1 = new DataView(CodeTable);
                displayTable = dataView1.ToTable();
                DataTable dt = new DataTable();
                dt = this.GetProject().CollectedData.GetTableData(formcodetable);
                DataView dv = new DataView(dt);
                dv.RowFilter = "RECSTATUS=0";
                DataTable      dt1         = dv.ToTable();
                List <DataRow> deletedRows = new List <DataRow>();
                foreach (DataRow dr in displayTable.Rows)
                {
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        if (dr1["GlobalRecordId"].ToString() == dr["GlobalRecordId"].ToString())
                        {
                            deletedRows.Add(dr);
                        }
                    }
                }
                deletedRows.ForEach(x => displayTable.Rows.Remove(x));
                DataView dataView = new DataView(displayTable);
                if (dataView.Count > 0)
                {
                    displayTable = dataView.ToTable(true, this.TextColumnName);
                }
                else
                {
                    displayTable = null;
                    return(displayTable);
                }
            }
            else
            {
                EnumerableRowCollection <DataRow> query =
                    from code in codeTable.AsEnumerable()
                    where code.Field <string>(predicate) == expression
                    select code;

                DataView view = query.AsDataView();
                displayTable = view.ToTable(true, this.TextColumnName);
            }

            displayTable.Columns[0].ColumnName = "Item";
            // displayTable.Columns[0].ColumnName = displayMember;

            return(displayTable);
        }
Beispiel #20
0
        /// <summary>
        /// 27 de Julio de 2016 Daniel Romero
        /// Metodo que permite consultar los zapatos
        /// </summary>
        /// <param name="dsColors"></param>
        /// <param name="sErrMessage"></param>
        /// <returns></returns>
        public bool GetShoes(DataSet dsShoesTypes, DataSet dsShoes, out List <cShoesByType> poShoesByType, out string sErrMessage)
        {
            try
            {
                sErrMessage   = "";
                poShoesByType = new List <cShoesByType>();

                for (int iShoesTypes = 0; iShoesTypes < dsShoesTypes.Tables[0].Rows.Count; iShoesTypes++)
                {
                    EnumerableRowCollection <DataRow> query = from rsl in dsShoes.Tables[0].AsEnumerable()
                                                              where rsl.Field <Int32>("ShoeType").Equals(Convert.ToInt32(dsShoesTypes.Tables[0].Rows[iShoesTypes]["Id"].ToString()))
                                                              select
                                                              rsl;

                    DataView view = query.AsDataView();

                    for (int iShoe = 0; iShoe < view.Count; iShoe++)
                    {
                        cShoesByType nicShoesByType = new cShoesByType();
                        nicShoesByType.iId                    = Convert.ToInt32(view[iShoe]["Id"].ToString());
                        nicShoesByType.sName                  = view[iShoe]["Name"].ToString();
                        nicShoesByType.sDescription           = view[iShoe]["Description"].ToString();
                        nicShoesByType.iQuantityExisting      = Convert.ToInt32(view[iShoe]["QuantityExisting"].ToString());
                        nicShoesByType.iQuantitySold          = Convert.ToInt32(view[iShoe]["QuantitySold"].ToString());
                        nicShoesByType.fPurchasePrice         = Convert.ToSingle(view[iShoe]["PurchasePrice"].ToString());
                        nicShoesByType.fSalePrice             = Convert.ToSingle(view[iShoe]["SalePrice"].ToString());
                        nicShoesByType.iType                  = Convert.ToInt32(view[iShoe]["ShoeType"].ToString());
                        nicShoesByType.iTotalQuantityExisting = Convert.ToInt32(view[iShoe]["TotalQuantityExisting"].ToString());

                        if (!string.IsNullOrEmpty(view[iShoe]["ShoeImage"].ToString()))
                        {
                            byte[] bytes  = (byte[])view[iShoe]["ShoeImage"];
                            var    base64 = Convert.ToBase64String(bytes);
                            var    imgSrc = String.Format("data:image/jpg;base64,{0}", base64);
                            nicShoesByType.simgSrc = imgSrc;
                        }
                        poShoesByType.Add(nicShoesByType);
                    }
                }


                return(true);
            }
            catch (Exception ex)
            {
                cUtilities.WriteLog(ex.Message, out sErrMessage);
                sErrMessage   = ex.Message;
                poShoesByType = new List <cShoesByType>();
                return(false);
            }
        }
Beispiel #21
0
        private void button10_Click(object sender, EventArgs e)
        {
            // <SnippetCreateLDVFromQueryOrderByDescending>
            DataTable orders = dataSet.Tables["SalesOrderHeader"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      orderby order.Field <DateTime>("OrderDate") descending
                                                      select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            // </SnippetCreateLDVFromQueryOrderByDescending>
        }
Beispiel #22
0
        private void button3_Click(object sender, EventArgs e)
        {
            // <SnippetCreateLDVFromQuery3>
            DataTable contacts = dataSet.Tables["Contact"];

            EnumerableRowCollection <DataRow> query = from contact in contacts.AsEnumerable()
                                                      where contact.Field <string>("LastName").StartsWith("S")
                                                      select contact;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            // </SnippetCreateLDVFromQuery3>
        }
Beispiel #23
0
        private void button16_Click(object sender, EventArgs e)
        {
            // <SnippetLDVFromQueryWhere>
            DataTable orders = dataSet.Tables["SalesOrderDetail"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      where order.Field <Int16>("OrderQty") > 2 && order.Field <Int16>("OrderQty") < 6
                                                      select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            // </SnippetLDVFromQueryWhere>
        }
Beispiel #24
0
        private void button18_Click(object sender, EventArgs e)
        {
            // <SnippetLDVFromQueryWhere3>
            DataTable orders = dataSet.Tables["SalesOrderHeader"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      where order.Field <DateTime>("OrderDate") > new DateTime(2002, 6, 1)
                                                      select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            // </SnippetLDVFromQueryWhere3>
        }
        private void CargarRoles()
        {
            Cls_Roles_BLL objBLL = new Cls_Roles_BLL();
            Cls_Roles_DAL objDAL = new Cls_Roles_DAL();

            gdvRoles.DataSource = null;
            gdvRoles.DataBind();

            objBLL.Listar(ref objDAL);
            if (objDAL.sError == string.Empty)
            {
                gdvRoles.SelectedIndex = -1;
                if (txtBuscar.Value == string.Empty)
                {
                    gdvRoles.DataSource = objDAL.dtTabla;
                }
                else
                {
                    DataTable dt = objDAL.dtTabla;

                    EnumerableRowCollection <DataRow> query = from dtRoles in dt.AsEnumerable()
                                                              where dtRoles.Field <string>("Rol").ToLower().Replace(" ", "").Contains(txtBuscar.Value.ToLower().Replace(" ", ""))
                                                              select dtRoles;

                    DataView view = query.AsDataView();

                    gdvRoles.DataSource = view;
                }

                gdvRoles.DataBind();

                if (gdvRoles.Rows.Count > 0)
                {
                    gdvRoles.Visible   = true;
                    lblMensaje.Visible = false;
                    lblMensaje.Text    = "";
                }
                else
                {
                    gdvRoles.Visible   = false;
                    lblMensaje.Visible = true;
                    lblMensaje.Text    = "No hay datos que mostrar";
                }
            }
            else
            {
                lblMensaje.Text = objDAL.sError;
            }
        }
Beispiel #26
0
        private void button21_Click(object sender, EventArgs e)
        {
            // <SnippetLDVFromQueryOrderByFind>
            DataTable contacts = dataSet.Tables["Contact"];

            EnumerableRowCollection <DataRow> query = from contact in contacts.AsEnumerable()
                                                      orderby contact.Field <string>("LastName")
                                                      select contact;

            DataView view = query.AsDataView();

            // Find a contact with the last name of Zhu.
            int found = view.Find("Zhu");
            // </SnippetLDVFromQueryOrderByFind>
        }
Beispiel #27
0
        private void txtRecherche_TextChanged(object sender, EventArgs e)
        {
            if (dgvGrille.DataSource == null)
            {
                return;
            }

            DataTable table = ((DataView)dgvGrille.DataSource).Table;

            EnumerableRowCollection <DataRow> requete = from ligne in table.AsEnumerable()
                                                        where ligne.ItemArray.ToList().Where(i => i.ToString().IndexOf(txtRecherche.Text, StringComparison.OrdinalIgnoreCase) >= 0).Count() > 0
                                                        select ligne;

            dgvGrille.DataSource = requete.AsDataView();
        }
Beispiel #28
0
        private void button8_Click(object sender, EventArgs e)
        {
            // <SnippetCreateLDVFromQueryOrderByThenBy>
            DataTable orders = dataSet.Tables["SalesOrderDetail"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      orderby order.Field <Int16>("OrderQty"), order.Field <int>("SalesOrderID")
            select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;

            // </SnippetCreateLDVFromQueryOrderByThenBy>
        }
Beispiel #29
0
        private void button20_Click(object sender, EventArgs e)
        {
            // <SnippetLDVFromQueryWhereOrderByThenBy2>
            DataTable orders = dataSet.Tables["SalesOrderHeader"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      where order.Field <DateTime>("OrderDate") > new DateTime(2002, 9, 15)
                                                      orderby order.Field <DateTime>("OrderDate"), order.Field <decimal>("TotalDue")
            select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            // </SnippetLDVFromQueryWhereOrderByThenBy2>
        }
Beispiel #30
0
        private void button25_Click(object sender, EventArgs e)
        {
            // <SnippetCreateLDVFromQueryOrderByYear>
            DataTable orders = dataSet.Tables["SalesOrderHeader"];

            EnumerableRowCollection <DataRow> query = from order in orders.AsEnumerable()
                                                      orderby order.Field <DateTime>("OrderDate").Year
                                                      select order;

            DataView view = query.AsDataView();

            bindingSource1.DataSource = view;
            dataGridView1.AutoResizeColumns();
            // </SnippetCreateLDVFromQueryOrderByYear>
        }