internal void SetDataViewManager(DataViewManager dataViewManager) { if (_dataViewManager != dataViewManager) { _dataViewManager = dataViewManager; } }
internal DataView(DataTable table, DataViewManager manager) { dataTable = table; rowState = DataViewRowState.CurrentRows; dataViewManager = manager; Open(); }
internal DataView (DataTable table, DataViewManager manager) { dataTable = table; rowState = DataViewRowState.CurrentRows; dataViewManager = manager; Open (); }
public static DataView loadAllGroup() { DataSet ds = DAGroup.Instance.loadDataSetGroup(); DataViewManager dvManager = new DataViewManager(ds); DataView dv = dvManager.CreateDataView(ds.Tables["GROUP_TBL"]); return dv; }
private void Form1_Load(object sender, EventArgs e) { DbADOTest = new DataSet("DbADOTest"); tblPeople = MakePeopleTable(); tblSale = MakeSaleTable(); DbADOTest.Tables.Add(tblPeople); DbADOTest.Tables.Add(tblSale); // 매니저를 통한 뷰 설정 DataViewManager vm = new DataViewManager(DbADOTest); vm.DataViewSettings["tblPeople"].Sort = "Name"; vm.DataViewSettings["tblSale"].RowFilter = "OrderNo > 1"; // 새로운 뷰 생성 DataView ViewMan = vm.CreateDataView(tblPeople); ViewMan.RowFilter = "Male = true"; ViewMan.Sort = "Age DESC"; foreach (DataViewSetting vs in vm.DataViewSettings) { listBox1.Items.Add(string.Format("테이블:{0}, 필터:{1}, 정렬:{2}, 상태:{3}", vs.Table, vs.RowFilter, vs.Sort, vs.RowStateFilter)); } dataGridView1.DataSource = vm; dataGridView1.DataMember = "tblPeople"; dataGridView2.DataSource = vm; dataGridView2.DataMember = "tblSale"; dataGridView3.DataSource = ViewMan; }
/// <summary> /// Retrieve the data /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> protected void retrieveButton_Click(object sender, System.EventArgs e) { retrieveButton.Enabled = false ; string orders = "SELECT * FROM Orders"; string customers = "SELECT * FROM Customers"; SqlConnection con = new SqlConnection ( Login.Connection ) ; SqlDataAdapter da = new SqlDataAdapter ( orders , con ) ; DataSet ds = new DataSet ( ) ; da.Fill ( ds , "Orders" ) ; da = new SqlDataAdapter ( customers , con ) ; da.Fill ( ds , "Customers" ) ; ds.Relations.Add("CustomerOrders", ds.Tables["Customers"].Columns["CustomerID"], ds.Tables["Orders"].Columns["CustomerID"]); DataViewManager dvm = new DataViewManager ( ds ) ; dvm.DataViewSettings["Customers"].RowFilter = "Country='UK'" ; dataGrid.SetDataBinding ( dvm , "Customers" ) ; }
internal DataViewSettingCollection(DataViewManager dataViewManager) { if (dataViewManager == null) { throw ExceptionBuilder.ArgumentNull("dataViewManager"); } this.dataViewManager = dataViewManager; }
internal void SetDataViewManager(DataViewManager dataViewManager) { if(this.dataViewManager != dataViewManager) { if(this.dataViewManager != null) { // throw exception here; } this.dataViewManager = dataViewManager; } }
internal DataViewSettingCollection(DataViewManager dataViewManager) { if (dataViewManager == null) { throw ExceptionBuilder.ArgumentNull(nameof(dataViewManager)); } _dataViewManager = dataViewManager; }
internal DataViewSettingCollection (DataViewManager manager) { settingList = new ArrayList (); if (manager.DataSet != null) foreach (DataTable dt in manager.DataSet.Tables) settingList.Add (new DataViewSetting ( manager, dt)); }
private void LlenaDetalle(string sAcabado) { DataViewManager dvmAcabado = new DataViewManager(); DataSet dsAcabado = new DataSet(); dsAcabado.Clear(); dsAcabado = SistEti.lpQueries.ObtenAcabadoBusqueda(sAcabado); dvmAcabado = dsAcabado.DefaultViewManager; dgvAcabados.DataSource = dvmAcabado.DataSet.Tables[0]; dgvAcabados.Refresh(); }
internal void SetDataViewManager(DataViewManager dataViewManager) { if (this.dataViewManager != dataViewManager) { if (this.dataViewManager != null) { // throw exception here; } this.dataViewManager = dataViewManager; } }
internal DataView(DataTable table, DataViewManager manager, string RowFilter, string Sort, DataViewRowState RowState) { dataTable = table; dataViewManager = manager; rowState = DataViewRowState.CurrentRows; this.RowFilter = RowFilter; this.Sort = Sort; rowState = RowState; Open(); }
internal DataViewSettingCollection(DataViewManager manager) { settingList = new ArrayList(); if (manager.DataSet != null) { foreach (DataTable dt in manager.DataSet.Tables) { settingList.Add(new DataViewSetting( manager, dt)); } } }
public DataViewSettingsEnumerator(DataViewManager dvm) { if (dvm.DataSet != null) { this.dataViewSettings = dvm.DataViewSettings; this.tableEnumerator = dvm.DataSet.Tables.GetEnumerator(); } else { this.dataViewSettings = null; this.tableEnumerator = DataSet.zeroTables.GetEnumerator(); } }
public DataViewSettingsEnumerator(DataViewManager dvm) { DataSet ds = dvm.DataSet; if (ds != null) { dataViewSettings = dvm.DataViewSettings; tableEnumerator = dvm.DataSet.Tables.GetEnumerator(); } else { dataViewSettings = null; tableEnumerator = DataSet.zeroTables.GetEnumerator(); } }
public DataViewSettingsEnumerator(DataViewManager dvm) { DataSet ds = dvm.DataSet; if (ds != null) { _dataViewSettings = dvm.DataViewSettings; _tableEnumerator = dvm.DataSet.Tables.GetEnumerator(); } else { _dataViewSettings = null; _tableEnumerator = Array.Empty <DataTable>().GetEnumerator(); } }
public void Ctor () { string defaultString = "<DataViewSettingCollectionString></DataViewSettingCollectionString>"; string current = @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter="""" RowStateFilter=""CurrentRows""/></DataViewSettingCollectionString>"; string deleted = @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter="""" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>"; DataViewManager m = new DataViewManager (null); Assert (m.DataSet == null); Assert (m.DataViewSettingCollectionString == ""); AssertNotNull (m.DataViewSettings); DataSet ds = new DataSet ("ds"); m.DataSet = ds; AssertEquals ("default#1", defaultString, m.DataViewSettingCollectionString); DataSet ds2 = new DataSet ("ds2"); AssertEquals ("default#2", defaultString, ds.DefaultViewManager.DataViewSettingCollectionString); DataTable dt2_1 = new DataTable ("table2-1"); dt2_1.Namespace ="urn:foo"; // It is ignored though. ds2.Tables.Add (dt2_1); m.DataSet = ds2; AssertEquals ("#3", current, m.DataViewSettingCollectionString); // Note that " Deleted " is trimmed. m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter=' Deleted '/></DataViewSettingCollectionString>"; AssertEquals ("#4", deleted, m.DataViewSettingCollectionString); m.DataSet = ds2; //resets modified string. AssertEquals ("#5", current, m.DataViewSettingCollectionString); m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter='Deleted'/></DataViewSettingCollectionString>"; // it does not clear anything. m.DataViewSettingCollectionString = "<DataViewSettingCollectionString/>"; AssertEquals ("#6", deleted, m.DataViewSettingCollectionString); // text node is not rejected (ignored). // RowFilter is not examined. m.DataViewSettingCollectionString = "<DataViewSettingCollectionString>blah<table2-1 RowFilter='a=b' ApplyDefaultSort='true' /></DataViewSettingCollectionString>"; // LAMESPEC: MS.NET ignores ApplyDefaultSort. // AssertEquals ("#7", @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter=""a=b"" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>", m.DataViewSettingCollectionString); }
private void PopulateCptyData() { this.Text = "Cpty Fax Mapping"; this.lblCode.Text = "Cpty Short Name:"; this.ddCptyCode.Visible = true; this.txtDesc.Visible = false; DataSet ds = new DataSet(); OracleDataAdapter adapter = new OracleDataAdapter(_CPTY_SQL, connectionString); adapter.Fill(ds,"Cpty"); DataViewManager dvm = new DataViewManager(ds); dv = dvm.CreateDataView(ds.Tables["Cpty"]); dv.Sort = "SHORT_NAME"; this.ddCptyCode.Properties.DataSource = dv; this.ddCptyCode.Properties.ValidateOnEnterKey = true; this.ddCptyCode.DataBindings.Add("EditValue", dv, "SHORT_NAME"); this.ddCptyCode.Properties.ValueMember = "SHORT_NAME"; this.ddCptyCode.Properties.DisplayMember = "SHORT_NAME"; GridColumn col1 = ddCptyCode.Properties.View.Columns.ColumnByFieldName("SHORT_NAME"); col1.VisibleIndex = 0; col1.Caption = "Short Name"; GridColumn col2 = ddCptyCode.Properties.View.Columns.ColumnByFieldName("LEGAL_NAME"); col2.VisibleIndex = 1; col2.Caption = "Name"; this.txtFax.Text = this.faxNumber; this.ddCptyCode.EditValue = this.codeDesc; }
internal DataViewSetting (DataViewManager manager, DataTable table) { dataViewManager = manager; dataTable = table; }
//PropertyDescriptorCollection propsCollection; internal DataViewManagerListItemTypeDescriptor(DataViewManager dvm) { this.dvm = dvm; }
public static DataView LoadAllOperationLog() { DataSet ds = DAUserLog.Instance.loadDataSetOperationLog("USER_LOG"); DataViewManager dvManager = new DataViewManager(ds); DataView dv = dvManager.CreateDataView(ds.Tables["USER_LOG"]); return dv; }
internal DataView (DataTable table, DataViewManager manager, string RowFilter, string Sort, DataViewRowState RowState) { dataTable = table; dataViewManager = manager; rowState = DataViewRowState.CurrentRows; this.RowFilter = RowFilter; this.Sort = Sort; rowState = RowState; Open (); }
private void ShowProductList() { com.CommandText = sqlShowProductList; com.CommandType = CommandType.Text; dr = com.ExecuteReader(); if (dr.HasRows) { dtProductList = new DataTable(); dtProductList.Load(dr); TotalRecord = dtProductList.Rows.Count; double tmpPageCount = (double)TotalRecord / PageSize; PageCount = Convert.ToInt32(Math.Ceiling(tmpPageCount)); tsRecordCount.Text = TotalRecord.ToString() + " รายการ"; CurrentPage = 1; RecordToDisplay = 0; ShowRecord(CurrentPage); FormatDgvProductList(); } else { ClearAllProduct(); dgvProductList.DataSource = null; tsRecord.Text = "0/0"; tsRecordCount.Text = "0 รายการ"; } dr.Close(); sb.Remove(0, sb.Length); sb.Append("SELECT PRODUCT.ProductParentId,PRODUCT.ProductId,PRODUCT.ProductName,"); sb.Append("UNITCHILD.UnitChildName,"); sb.Append("ISNULL(SUM(RECEIVE_DETAIL.ReceiveDetailQuantity),0) AS ReceiveTotal,ISNULL(SUM(SALERETURN_DETAIL.SaleReturnDetailQuantity),0) AS ReturnTotal,ISNULL(SUM(SALE_DETAIL.SaleDetailQuantity),0) AS SaleTotal,ISNULL(SUM(SALEBACK_DETAIL.SaleBackDetailQuantity),0) AS SentBackTotal,"); sb.Append("(ISNULL(SUM(RECEIVE_DETAIL.ReceiveDetailQuantity),0) + ISNULL(SUM(SALERETURN_DETAIL.SaleReturnDetailQuantity),0)) - (ISNULL(SUM(SALE_DETAIL.SaleDetailQuantity),0) + ISNULL(SUM(SALEBACK_DETAIL.SaleBackDetailQuantity),0)) AS Total,"); sb.Append("UNITSALE.UnitSaleName,PRODUCT.ProductStockConvert,"); sb.Append("((ISNULL(SUM(RECEIVE_DETAIL.ReceiveDetailQuantity),0) + ISNULL(SUM(SALERETURN_DETAIL.SaleReturnDetailQuantity),0)) - (ISNULL(SUM(SALE_DETAIL.SaleDetailQuantity),0) + ISNULL(SUM(SALEBACK_DETAIL.SaleBackDetailQuantity),0)) * PRODUCT.ProductStockConvert) AS CovertTotal ,UNITCONVERT.UnitConvertName "); sb.Append("FROM (PRODUCT INNER JOIN UNITCHILD ON PRODUCT.UnitChildId = UNITCHILD.UnitChildId) "); sb.Append("INNER JOIN UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId "); sb.Append("LEFT JOIN UNITCONVERT ON PRODUCT.UnitConvertId = UNITCONVERT.UnitConVertId "); sb.Append("LEFT JOIN RECEIVE_DETAIL ON PRODUCT.ProductId = RECEIVE_DETAIL.ProductId "); sb.Append("LEFT JOIN SALE_DETAIL ON PRODUCT.ProductId = SALE_DETAIL.ProductId "); sb.Append("LEFT JOIN SALERETURN_DETAIL ON PRODUCT.ProductId = SALERETURN_DETAIL.ProductId "); sb.Append("LEFT JOIN SALEBACK_DETAIL ON PRODUCT.ProductId = SALEBACK_DETAIL.ProductId "); sb.Append("GROUP BY PRODUCT.ProductParentId, PRODUCT.ProductId, UNITCHILD.UnitChildName, PRODUCT.ProductName, UNITSALE.UnitSaleName,PRODUCT.ProductStockConvert,UNITCONVERT.UnitConvertName"); sqlSubProductList = sb.ToString(); da.SelectCommand.CommandText = sqlSubProductList; da.Fill(ds, "Product"); DataColumn dcProductParent, dcProduct; dcProductParent = ds.Tables["ProductParent"].Columns["ProductParentId"]; dcProduct = ds.Tables["Product"].Columns["ProductParentId"]; dl = new DataRelation("Product_detail", dcProductParent, dcProduct); ds.Relations.Add(dl); dvm = new DataViewManager(); dvm.DataSet = ds; DataViewSetting dvsProductParant, dvs, dvsProduct; dvsProductParant = dvm.DataViewSettings["ProductParent"]; dvsProductParant.Sort = "ProductParentId"; dvsProduct = dvm.DataViewSettings["Product"]; dvsProduct.Sort = "ProductId"; dgvProductList.DataSource = dvm; dgvProductList.DataMember = "ProductParent"; dgvDetailProduct.DataSource = dvm; dgvDetailProduct.DataSource = dvm; dgvDetailProduct.DataMember = "ProductParent.Product_detail"; // == = ประวัติการรับ sb.Remove(0, sb.Length); sb.Append("SELECT PRODUCT.ProductParentId,RECEIVE_HEAD.ReceiveHeadId, RECEIVE_HEAD.ReceiveHeadDate, RECEIVE_DETAIL.ProductId, PRODUCT.ProductName, "); sb.Append("RECEIVE_DETAIL.ReceiveDetailQuantity, UNITSALE.UnitSaleName, RECEIVE_DETAIL.ReceiveDetailPriceUnit,"); sb.Append("ISNULL(RECEIVE_DETAIL.ReceiveDetailQuantity,0) * ISNULL(RECEIVE_DETAIL.ReceiveDetailPriceUnit,0) AS ReceiveTotal,SUPPLIER.SupplierName "); sb.Append("FROM RECEIVE_HEAD INNER JOIN "); sb.Append("RECEIVE_DETAIL ON RECEIVE_HEAD.ReceiveHeadId = RECEIVE_DETAIL.ReceiveHeadId left JOIN "); sb.Append(" PRODUCT ON RECEIVE_DETAIL.ProductId = PRODUCT.ProductId LEFT JOIN"); sb.Append(" SUPPLIER ON RECEIVE_DETAIL.SupplierId = SUPPLIER.SupplierId LEFT JOIN"); sb.Append(" UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId"); string sqlReeviceHistory = sb.ToString(); da.SelectCommand.CommandText = sqlReeviceHistory; da.Fill(ds, "RECEIVE"); DataColumn dcReceive; dcProductParent = ds.Tables["ProductParent"].Columns["ProductParentId"]; dcReceive = ds.Tables["RECEIVE"].Columns["ProductParentId"]; DataRelation dl2 = new DataRelation("Product_Receive", dcProductParent, dcReceive); ds.Relations.Add(dl2); dvs = dvm.DataViewSettings["RECEIVE"]; dvs.Sort = "ProductId"; dgvReceiveHistory.DataSource = dvm; dgvReceiveHistory.DataMember = "ProductParent.Product_Receive"; // == = ประวัติการขาย sb.Remove(0, sb.Length); sb.Append("SELECT PRODUCT.ProductParentId,SALE_HEAD.SaleHeadId, SALE_HEAD.SaleHeadDateTime, SALE_DETAIL.ProductId, PRODUCT.ProductName, SALE_DETAIL.SaleDetailQuantity,"); sb.Append("UNITSALE.UnitSaleName, SALE_DETAIL.SaleDetailPriceUnit,ISNULL(SALE_DETAIL.SaleDetailQuantity,0) * ISNULL(SALE_DETAIL.SaleDetailPriceUnit,0) AS TotalSale,CUSTOMER.CustomerName "); sb.Append("FROM SALE_HEAD INNER JOIN "); sb.Append("SALE_DETAIL ON SALE_HEAD.SaleHeadId = SALE_DETAIL.SaleHeadId LEFT JOIN "); // sb.Append("SALE_DETAIL ON SALE_HEAD.SaleHeadId = SALE_DETAIL.SaleHeadId INNER JOIN "); sb.Append(" PRODUCT ON SALE_DETAIL.ProductId = PRODUCT.ProductId LEFT JOIN "); sb.Append(" UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId LEFT JOIN "); sb.Append(" CUSTOMER ON SALE_HEAD.CustomerId = CUSTOMER.CustomerId"); string sqlSaleHistory = sb.ToString(); da.SelectCommand.CommandText = sqlSaleHistory; da.Fill(ds, "SALE"); DataColumn dcSale; dcProductParent = ds.Tables["ProductParent"].Columns["ProductParentId"]; dcSale = ds.Tables["SALE"].Columns["ProductParentId"]; DataRelation dl3 = new DataRelation("Product_Sale", dcProductParent, dcSale); ds.Relations.Add(dl3); dvs = dvm.DataViewSettings["SALE"]; dvs.Sort = "ProductId"; dgvSaleHistory.DataSource = dvm; dgvSaleHistory.DataMember = "ProductParent.Product_Sale"; // == = ประวัติการรับคืน sb.Remove(0, sb.Length); sb.Append("SELECT PRODUCT.ProductParentId,SALERETURN_HEAD.SaleReturnHeadId, SALERETURN_HEAD.SaleReturnHeadDate, CUSTOMER.CustomerName, SALE_HEAD.SaleHeadId, "); sb.Append("SALE_DETAIL.ProductId, PRODUCT.ProductName, SALERETURN_DETAIL.SaleReturnDetailQuantity, UNITSALE.UnitSaleName,SALERETURN_DETAIL.SaleReturnDetailPriceUnit "); sb.Append("FROM SALERETURN_HEAD LEFT JOIN"); sb.Append(" SALERETURN_DETAIL ON SALERETURN_HEAD.SaleReturnHeadId = SALERETURN_DETAIL.SaleReturnHeadId LEFT JOIN "); sb.Append(" PRODUCT ON SALERETURN_DETAIL.ProductId = PRODUCT.ProductId LEFT JOIN "); sb.Append(" CUSTOMER ON SALERETURN_HEAD.CustomerId = CUSTOMER.CustomerId LEFT JOIN"); sb.Append(" SALE_HEAD ON SALERETURN_DETAIL.SaleHeadId = SALE_HEAD.SaleHeadId AND CUSTOMER.CustomerId = SALE_HEAD.CustomerId LEFT JOIN "); sb.Append(" UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId LEFT JOIN SALE_DETAIL ON PRODUCT.ProductId = SALE_DETAIL.ProductId AND SALE_HEAD.SaleHeadId = SALE_DETAIL.SaleHeadId "); string sqlSaleReturnHistory = sb.ToString(); da.SelectCommand.CommandText = sqlSaleReturnHistory; da.Fill(ds, "SALERETURN"); DataColumn dcSaleReturn; dcProductParent = ds.Tables["ProductParent"].Columns["ProductParentId"]; dcSaleReturn = ds.Tables["SALERETURN"].Columns["ProductParentId"]; DataRelation dl4 = new DataRelation("Product_SaleReturn", dcProductParent, dcSaleReturn); ds.Relations.Add(dl4); dvs = dvm.DataViewSettings["SALERETURN"]; dvs.Sort = "ProductId"; dgvSaleReturnHistory.DataSource = dvm; dgvSaleReturnHistory.DataMember = "ProductParent.Product_SaleReturn"; // == = ประวัติการส่งคืน sb.Remove(0, sb.Length); sb.Append(" SELECT PRODUCT.ProductParentId,SALEBACK_HEAD.SaleBackHeadId, SALEBACK_HEAD.SaleBackHeadDate, SALEBACK_DETAIL.ReceiveHeadId, SALEBACK_DETAIL.ProductId, "); sb.Append(" PRODUCT.ProductName, SALEBACK_DETAIL.SaleBackDetailQuantity, UNITSALE.UnitSaleName, SALEBACK_DETAIL.SaleBackDetailPriceUnit, "); sb.Append("SUPPLIER.SupplierName "); sb.Append("FROM PRODUCT LEFT JOIN SALEBACK_DETAIL ON PRODUCT.ProductId = SALEBACK_DETAIL.ProductId LEFT JOIN "); sb.Append("SALEBACK_HEAD ON SALEBACK_DETAIL.SaleBackHeadId = SALEBACK_HEAD.SaleBackHeadId LEFT JOIN "); sb.Append(" SUPPLIER ON SALEBACK_HEAD.SupplierId = SUPPLIER.SupplierId LEFT JOIN"); sb.Append(" UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId LEFT JOIN "); sb.Append(" UNITSALE AS UNITSALE_1 ON PRODUCT.UnitSaleId = UNITSALE_1.UnitSaleId "); string sqlSaleBackHistory = sb.ToString(); da.SelectCommand.CommandText = sqlSaleBackHistory; da.Fill(ds, "SALEBACK"); DataColumn dcSaleBack; dcProductParent = ds.Tables["ProductParent"].Columns["ProductParentId"]; dcSaleBack = ds.Tables["SALEBACK"].Columns["ProductParentId"]; DataRelation dl5 = new DataRelation("Product_SaleBack", dcProductParent, dcSaleBack); ds.Relations.Add(dl5); dvs = dvm.DataViewSettings["SALEBACK"]; dvs.Sort = "ProductId"; dgvSaleBack.DataSource = dvm; dgvSaleBack.DataMember = "ProductParent.Product_SaleBack"; FormatDgvDetailProduct(); FormatDgvProductList(); FormatDgvReceiveHistory(); FormatDgvSaleHistory(); FormatDgvSaleReturnHistory(); FormatDgvSaleBack(); }
public void SpecifyNonExistentTable () { DataViewManager m = new DataViewManager (null); // NullReferenceException is thrown. m.DataViewSettingCollectionString = "<DataViewSettingCollectionString><table1-1 RowFilter='a=b' /></DataViewSettingCollectionString>"; }
public DataViewSettingsEnumerator(DataViewManager dvm) { DataSet ds = dvm.DataSet; if(ds != null) { dataViewSettings = dvm.DataViewSettings; tableEnumerator = dvm.DataSet.Tables.GetEnumerator(); }else { dataViewSettings = null; tableEnumerator = DataSet.zeroTables.GetEnumerator(); } }
/// <summary> /// This prints out the contents of a datagrid using ReportBuilder /// </summary> /// <param name="reportDocument"></param> public void MakeDocument(ReportDocument reportDocument, string strFontSize, string strStartDate, string strEndDate) { if (dataGrid == null) return; // We may need a DataSet and Data Table depending on DataGrid source type DataTable dataTable = new DataTable(); DataSet dataSet = new DataSet(); DataViewManager dataViewManager = new DataViewManager(); DataView dataView = new DataView(); // We may need to create a DataView depending on the type of DataSouce that is // in the DataGrid bool dataViewExpected=true; //Depending on the Source and if there is a valid data memember we may need //to create a dataView, We actually will try and get the dataView later on //from the currency manager as this will let us show the datatable if we //have drilled down. switch (dataGrid.DataSource.GetType().ToString()) { case "System.Data.DataViewManager": { //Check that a view is being shown, if no load views into a table if (dataGrid.DataMember == String.Empty) { dataViewExpected = false; //ok no Data View is active so print out he DataView dataTable = new DataTable("DataViewManager"); DataColumn dataColumn = dataTable.Columns.Add("TableID",typeof(String)); //Get the dataViewManger from the DataGrid source dataViewManager = (DataViewManager)dataGrid.DataSource; //Add a dataRow to our little table for each DataView Setting foreach (DataViewSetting dvs in dataViewManager.DataViewSettings) { dataTable.Rows.Add(new string[]{dvs.Table.TableName}); } //Now Create a DataView that the ReportPRinting can use to print dataView = new DataView(dataTable); } break; } case "System.Data.DataView": { dataView = (DataView)dataGrid.DataSource; break; } case "System.Data.DataTable": { dataView = ((DataTable)dataGrid.DataSource).DefaultView; break; } case "System.Data.DataSet": { //If DataGrid uses a Data set than the DataTable is in DataMember if (dataGrid.DataMember == String.Empty) { dataViewExpected = false; //ok no Data View is active so print out tables in DataSet //by first creating a dataTable and loading the dataSet Table names //into it so we can create a dataView dataTable = new DataTable("DataSetTables"); DataColumn dataColumn = dataTable.Columns.Add("TableID",typeof(String)); //Get the DataSet from the DataGrid source dataSet = (DataSet)dataGrid.DataSource; //Load the name of each table in the dataSet into our new table foreach (DataTable dt in dataSet.Tables) { dataTable.Rows.Add(new string[]{dt.TableName}); } //Now Create a DataView that the ReportPRinting can use to print dataView = new DataView(dataTable); } break; } } // See if we can pickup the current view from the currency manager // This should also pickup if we are drilled down on any relations etc // This will be skipped where there was no dataView obtainable from the // dataGrid dataSource and DataMember CurrencyManager currencyManager; if (dataViewExpected) { //Currency Manager for the DataGrid currencyManager = (CurrencyManager)dataGrid.BindingContext [dataGrid.DataSource,dataGrid.DataMember]; //This is the DataView that we are going to fill up... dataView = (DataView)currencyManager.List; } // Setup the document's settings reportDocument.DefaultPageSettings= pageSettings; reportBuilder.StartLinearLayout(Direction.Vertical); // Print out the actual Report Page // // %p is code for the page number // string pageStr = "-%p-"; // // string tableName=dataView.Table.TableName; // // reportBuilder.AddPageHeader( // // First page // pageStr, tableName , String.Empty, // // Right pages // pageStr, tableName , String.Empty, // // Odd pages // String.Empty, tableName, pageStr); // // reportBuilder.AddPageFooter (DateTime.Now.ToLongDateString(), ReportPrinting.HorizontalAlignment.Center); // //Now lets print out the Datagrid - First the Heading reportBuilder.AddText(dataGrid.CaptionText, TextStyle.Heading1); // We need to print any parent row info here // Check the dataGrid.DataMember and see if it is a data relation // If it is then get the first DataRow in the DataGrid and then // use its GetParentRows method, Each row should be checked to see // if there was a DataGridTableStyle set up for it // We have to work our way backwards up the data relation building strings that // need to be printed in reverse order to match the way the dataGrid displays if (dataGrid.ParentRowsVisible && //Are parents rows showing?? dataViewExpected && //If no view then skip this dataGrid.DataMember.LastIndexOf(".") > 0 ) //check Tablename.Relation { DataRowView dataRowView1= dataView[0]; //first get the DataRow View DataRow dataRow1 = dataRowView1.Row; //Now get the DataRow for viewRow //break up the DataRelations string into its parts //[0] will be the original table,[1][..] will be relations //This need to be processed from last to first as the last one is //what is currently being displayed on the data grid string [] relations = dataGrid.DataMember.Split(new Char [] {'.'}); //we will build an array of strings of parent data showing on the //datagrid that needs to be printed in reverse order //of the way they were built on the DataGrid in order //to replicate the drill down on the data grid. string[] parentText = new string[relations.Length - 1]; //Go through each Relation from the last to first and get the parent rows //of the childRow using the data relations for that parent-child relation for (int r=relations.Length-1;r > 0;r--) { //If a child has multiple parent rows than we need to figure out which //is parent for this drill down. To get the information for each //parent row we are going to build a string with table & relations //which is the same as the dataGrid Builds automatically on drilldown //for the DataMember field which we will store in parentMember. //parentMember will then be used to get the correct currencyManager //which in turn will get the correct dataview,dataRowView and DataRow //IE TABLENAME.RELATION1.RELATION2 etc string parentMember = String.Empty; for (int i=0 ; i < r; i++) { parentMember += relations[i]; if (i < r-1) parentMember += "."; //Separate with periods except last } //Now that we have the parentMember we need to get the currency //manager for that parentmember which is holding the current //DataView from which we will get the currencyManager = (CurrencyManager)dataGrid.BindingContext [dataGrid.DataSource,parentMember]; //This is the DataView that we are going to fill up... DataView parentDataView = (DataView)currencyManager.List; DataRowView parentDataRowView = (DataRowView)currencyManager.Current; //first get the DataRow View DataRow parentRow = parentDataRowView.Row; //Start with the TableName: parentText[r-1] = parentRow.Table.TableName+": "; // Determine if there is DataGrid Table Style for the parent table // or do we just go through all the columns in the parent DataTable try { DataGridTableStyle tableStyle = dataGrid.TableStyles[parentRow.Table.TableName]; //Go through the table style columns & build the parent text line foreach(DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles) { parentText[r-1] += columnStyle.MappingName+": " + parentRow[columnStyle.MappingName].ToString()+" "; } } catch { //Go through the columns in the parentRow DataTable and built //the parent text line foreach(DataColumn dataColumn in parentRow.Table.Columns) { parentText[r-1] += dataColumn.ColumnName+": " +parentRow[dataColumn].ToString()+" "; } } } //Now print out all the Parent Text array using the report builder for (int i=0; i < parentText.Length; i++) { reportBuilder.AddHorizontalLine (); reportBuilder.AddText(parentText[i], TextStyle.Normal); } reportBuilder.AddHorizontalLine (); } // Add dataView & all columns that are in the data grid reportBuilder.AddTable(dataView, true); // Now we have to determine if there was a DataGridTableStyle setup for this // DataGrid, The default will be to load from the DataView table columns bool loadFromDataView = true; //If there is a DataGridTableStyle - Add any columns showing in the grid.. foreach (DataGridTableStyle tableStyle in dataGrid.TableStyles) { if(tableStyle.MappingName == dataView.Table.TableName) { loadFromDataView = false; foreach(DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles) { reportBuilder.AddColumn(columnStyle.MappingName, columnStyle.HeaderText, (float)columnStyle.Width/75, //Not sure if correct sizing true, true, (ReportPrinting.HorizontalAlignment)columnStyle.Alignment); DataGridTextBoxColumn textCol = columnStyle as DataGridTextBoxColumn; if (textCol != null) { Debug.WriteLine (textCol.Format); reportBuilder.CurrentColumn.FormatExpression = textCol.Format; } } } } //If this is still true than we have to load from the Table columns in the //dataView that the datagrid is using. // // IE there was NOT a valid DataGridTableStyle in the datagrid if (loadFromDataView) { reportBuilder.AddAllColumns (maxColumnSize, true, true); } reportBuilder.FinishLinearLayout(); }
internal DataViewManagerListItemTypeDescriptor(DataViewManager dataViewManager) { this.dataViewManager = dataViewManager; }
//PropertyDescriptorCollection propsCollection; internal DataViewManagerListItemTypeDescriptor (DataViewManager dvm) { this.dvm = dvm; }
private void loadGridViewGroupSelectionChanged() { if (gridViewGroup.FocusedRowHandle >= 0) { DataRow row = gridViewGroup.GetDataRow(gridViewGroup.FocusedRowHandle); //DataSet ds = Feature.getFeatureGroupAdapter(HelpNumber.ParseInt64(row["groupid"].ToString()), "GROUP_FEATURE_TBL"); //DataViewManager dvManager = new DataViewManager(ds); //DataView dv = dvManager.CreateDataView(ds.Tables["GROUP_FEATURE_TBL"]); //gridControlFeature.DataSource = dv; //HUNG DataSet dsTemp = getGroupFeatureAdapter1(HelpNumber.ParseInt64(row["groupid"].ToString()), "GROUP_FEATURE_TBL"); setModifyFeatureDataSetAfterLoad(dsTemp); treeListFeature.KeyFieldName = "ID"; treeListFeature.ParentFieldName = "PARENTID"; treeListFeature.DataSource = dsTemp.Tables[0]; //treeListFeature.ExpandAll(); //----------------------------- //S:CHAUTV SetDisableFunction(dsTemp); //E:CHAUTV DataSet ds2 = BaoBieu.getReportGroupAdapter(HelpNumber.ParseInt64(row["groupid"].ToString()), "GROUP_REPORT_TBL"); DataViewManager dvManager2 = new DataViewManager(ds2); DataView dv2 = dvManager2.CreateDataView(ds2.Tables["GROUP_REPORT_TBL"]); gridControlReport.DataSource = dv2; getAllUserByGroupId(ref dsGetUserByGroup, HelpNumber.ParseInt64(row["groupid"]), false); } else { //gridControlFeature.DataSource = null; treeListFeature.DataSource = null; gridControlReport.DataSource = null; } }
private void loadGridViewUserSelectionChanged() { if (gridViewUser.FocusedRowHandle >= 0) { DataRow row = gridViewUser.GetDataRow(gridViewUser.FocusedRowHandle); //DataSet ds = Feature.getFeatureUserAdapter(HelpNumber.ParseInt64(row["userid"].ToString()), "USER_FEATURE_TBL"); //DataViewManager dvManager = new DataViewManager(ds); //DataView dv = dvManager.CreateDataView(ds.Tables["USER_FEATURE_TBL"]); //gridControlFeature.DataSource = dv; //HUNG/// DataSet dsTemp = getUserFeatureAdapter1(HelpNumber.ParseInt64(row["userid"].ToString()), "USER_FEATURE_TBL"); setModifyFeatureDataSetAfterLoad(dsTemp); treeListFeature.KeyFieldName = "ID"; treeListFeature.ParentFieldName = "PARENTID"; treeListFeature.DataSource = dsTemp.Tables[0]; //treeListFeature.ExpandAll(); //----------------------------- //START : CHAUTV SetDisableFunction(dsTemp); //END : CHAUTV DataSet ds2 = BaoBieu.getReportUserAdapter(HelpNumber.ParseInt64(row["userid"].ToString()), "USER_REPORT_TBL"); DataViewManager dvManager2 = new DataViewManager(ds2); DataView dv2 = dvManager2.CreateDataView(ds2.Tables["USER_REPORT_TBL"]); gridControlReport.DataSource = dv2; getAllGroupByUserId(ref dsGetGroupByUser, HelpNumber.ParseInt64(row["userid"]), false); if (row["username"].ToString() == "admin") { this.btnDelete.Enabled = false; } else { this.btnDelete.Enabled = true; } } else { //gridControlFeature.DataSource = null; treeListFeature.DataSource = null; gridControlReport.DataSource = null; } }
// DataGrid alignment been controlled by datagrid column width private void InitDataGridBinding() { dvm = new DataViewManager(_allocDiff.ds); dvm.DataViewSettings[_allocDiff.basedatatable.TableName].RowFilter = strFilter; dvm.DataViewSettings[_allocDiff.basedatatable.TableName].Sort = "diffIncl desc"; dgToplevelDiff.CaptionText = "Function allocation diff"; dgToplevelDiff.SetDataBinding(dvm, _allocDiff.basedatatable.TableName); dgCallee.SetDataBinding(null, null); dgCaller.SetDataBinding(null, null); dgSelected.SetDataBinding(null, null); }
private void loadGridViewGroupSelectionChanged() { if (gridViewGroup.FocusedRowHandle >= 0) { DataRow row = gridViewGroup.GetDataRow(gridViewGroup.FocusedRowHandle); DataSet ds = Feature.getFeatureGroupAdapter(HelpNumber.ParseInt64(row["groupid"].ToString()), "GROUP_FEATURE_TBL"); DataViewManager dvManager = new DataViewManager(ds); DataView dv = dvManager.CreateDataView(ds.Tables["GROUP_FEATURE_TBL"]); gridControlFeature.DataSource = dv; SetDisableFunction(); DataSet ds2 = BaoBieu.getReportGroupAdapter(HelpNumber.ParseInt64(row["groupid"].ToString()), "GROUP_REPORT_TBL"); DataViewManager dvManager2 = new DataViewManager(ds2); DataView dv2 = dvManager2.CreateDataView(ds2.Tables["GROUP_REPORT_TBL"]); gridControlReport.DataSource = dv2; UserManUtil.getAllUserByGroupId(gridControlThanhPhanGroupUser,ref dsGetUserByGroup, HelpNumber.ParseInt64(row["groupid"]), false); } else { gridControlFeature.DataSource = null; gridControlReport.DataSource = null; } }
internal DataViewSetting(DataViewManager manager, DataTable table) { dataViewManager = manager; dataTable = table; }
public void SetIncorrectRootElement () { DataViewManager m = new DataViewManager (null); m.DataViewSettingCollectionString = "<foo/>"; }
private void ShowData() { sb = new StringBuilder(); sb.Remove(0, sb.Length); sb.Append("SELECT * From MAINCATE ORDER BY MainCateId"); String SqlMainCate = sb.ToString(); da = new SqlDataAdapter(SqlMainCate,Conn); ds = new DataSet(); da.Fill(ds, "MainCate"); sb.Remove(0, sb.Length); sb.Append("SELECT * FROM SUBCATE ORDER BY SubCateId"); String SqlSubCate = sb.ToString(); da.SelectCommand.CommandText = SqlSubCate; da.Fill(ds, "SubCate"); DataColumn dcMainCate, dcSubCate; dcMainCate = ds.Tables["MainCate"].Columns["MainCateId"]; dcSubCate = ds.Tables["SubCate"].Columns["MainCateId"]; dl = new DataRelation("SubCate_detail",dcMainCate,dcSubCate); ds.Relations.Add(dl); dvm = new DataViewManager(); dvm.DataSet = ds; DataViewSetting dvs; dvs = dvm.DataViewSettings["MainCate"]; dvs.Sort = "MainCateId"; dvs = dvm.DataViewSettings["SubCate"]; dvs.Sort = "SubCateId"; dgvMainCateList.DataSource = dvm; dgvMainCateList.DataMember = "MainCate"; CheckResult = dgvMainCateList.Rows.Count; lblCheckResult.Text = "พบ : " + CheckResult.ToString() + " รายการ"; dgvSubCateList.DataSource = dvm; dgvSubCateList.DataMember = "MainCate.SubCate_detail"; CheckResultSubcate = dgvSubCateList.Rows.Count; lblCheckResultSubcate.Text = "พบ : " + CheckResultSubcate.ToString() + " รายการ"; com = new SqlCommand(); /* // วิธัแบบ Data Reader string sqlCate; sqlCate = "SELECT * FROM MAINCATE ORDER BY MainCateId"; SqlDataReader dr; // สร้าง data reader ชื่อ dr com = new SqlCommand(); com.CommandType = CommandType.Text; com.CommandText = sqlCate; // ดึง sqlunit com.Connection = Conn; // เชื่อมกะ db dr = com.ExecuteReader(); // รันชุดคำสั่ง if (dr.HasRows) { DataTable dt = new DataTable(); // สร้าง object datatable มาชื่อ dt dt.Load(dr); // ให้ dt โหลดข้อมูลออกมา CheckResult = dt.Rows.Count; dgvMainCateList.DataSource = dt; // แสดงรายชื่อ ลงไปยัง dgv unit ( Datagrid view) } else { CheckResult = 0; dgvMainCateList.DataSource = null; // ล้างข้อมูลออก } lblCheckResult.Text = "พบ : " + CheckResult.ToString() + " รายการ"; dr.Close(); // ปิด object dr */ }
public void SetNullDataSet () { DataViewManager m = new DataViewManager (null); m.DataSet = null; // DataException }
private void ViewSelectedInfo(DataGrid dg) { if( dg.DataMember == "") return; dvm = new DataViewManager(_allocDiff.ds); dvm_caller = new DataViewManager(_allocDiff.ds); dvm_callee = new DataViewManager(_allocDiff.ds); int roeNumber = dg.CurrentCell.RowNumber; string name = (string)dg[roeNumber, 0]; int id = (int)_allocDiff.basedataId[name]; DataRow[] caller = _allocDiff.callertbl.Select("id =" + id); DataRow[] callee = _allocDiff.calleetbl.Select("id =" + id); //======== caller table============ if(name != "<root>") { dgCaller.CaptionText = CallerCaption; dvm_caller.DataViewSettings[_allocDiff.ContriTocallertbl.TableName].RowFilter = "id = " + id; dgCaller.SetDataBinding(dvm_caller ,_allocDiff.ContriTocallertbl.TableName); } else { dgCaller.SetDataBinding(null, null); } dgCaller.Visible = true; //========= selected table ========== dgSelected.CaptionText = SelectedCaption; dvm.DataViewSettings[_allocDiff.basedatatable.TableName].RowFilter = "id" + '=' + id; dgSelected.SetDataBinding(dvm,_allocDiff.basedatatable.TableName); dgSelected.Visible = true; //========= callee Table =============== if(name != "<bottom>") { dgCallee.CaptionText = CalleeCaption; dvm_callee.DataViewSettings[_allocDiff.ContriTocalleetbl.TableName].RowFilter = "id = " + id; dgCallee.SetDataBinding(dvm_callee ,_allocDiff.ContriTocalleetbl.TableName); } else { dgCallee.SetDataBinding(null, null); } dgCallee.Visible = true; this.Invalidate(); }
private void loadGridViewUserSelectionChanged() { if (gridViewUser.FocusedRowHandle >= 0) { DataRow row = gridViewUser.GetDataRow(gridViewUser.FocusedRowHandle); DataSet ds = Feature.getFeatureUserAdapter(HelpNumber.ParseInt64(row["userid"]), "USER_FEATURE_TBL"); DataViewManager dvManager = new DataViewManager(ds); DataView dv = dvManager.CreateDataView(ds.Tables["USER_FEATURE_TBL"]); gridControlFeature.DataSource = dv; SetDisableFunction(); DataSet ds2 = BaoBieu.getReportUserAdapter(HelpNumber.ParseInt64(row["userid"]), "USER_REPORT_TBL"); DataViewManager dvManager2 = new DataViewManager(ds2); DataView dv2 = dvManager2.CreateDataView(ds2.Tables["USER_REPORT_TBL"]); gridControlReport.DataSource = dv2; UserManUtil.getAllGroupByUserId(gridControlThanhPhanGroupUser, ref dsGetGroupByUser, HelpNumber.ParseInt64(row["userid"]), false); if (row["username"].ToString() == "admin") { this.btnDelete.Enabled = false; } else { this.btnDelete.Enabled = true; } } else { gridControlFeature.DataSource = null; gridControlReport.DataSource = null; } }