private void getData(AutoCompleteStringCollection dataCollection) { materialBAL = new BAL.MaterialBAL(); DataSet ds = new DataSet(); ds = materialBAL.getMaterials(null); try { DataTable dt = new DataTable(); dt = ds.Tables[0]; dt.Columns.Remove("MaterialId"); dt.Columns.Remove("MaterialDescription"); dt.Columns.Remove("PriceId"); dt.Columns.Remove("CreatedOn"); dt.Columns.Remove("ModifiedOn"); foreach (DataRow row in dt.Rows) { dataCollection.Add(row[0].ToString()); dataCollection.Add(row[1].ToString()); dataCollection.Add(row[2].ToString()); } } catch (Exception ex) { MessageBox.Show("Can not open connection ! "); } }
private void BindEditForm(object[] data) { materialBAL = new BAL.MaterialBAL(); DataSet table = new DataSet(); table = materialBAL.getMaterials(data); BindFields(table); }
private void BindMaterialPanel() { materialBAL = new BAL.MaterialBAL(); DataSet tables = new DataSet(); DataTable dt = new DataTable(); tables = materialBAL.getMaterials(null); dt = tables.Tables[0]; tables.Relations.Add("DetailsPrices", tables.Tables[0].Columns["MaterialId"], tables.Tables[1].Columns["MaterialId"]); BindingSource bsMaterials = new BindingSource(); bsMaterials.DataSource = tables; bsMaterials.DataMember = "Table"; BindingSource bsPrices = new BindingSource(); bsPrices.DataSource = bsMaterials; bsPrices.DataMember = "DetailsPrices"; dataGridMaterial.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing; dataGridMaterial.DataSource = bsMaterials; dataGridPrice.DataSource = bsPrices; this.dataGridUser.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridMaterial_RowPostPaint); //dataGridMaterial.DataSource = tables.Tables[0]; this.dataGridMaterial.Columns["MaterialId"].Visible = false; this.dataGridPrice.Columns["MaterialId"].Visible = false; this.dataGridMaterial.Columns["PriceId"].Visible = false; dataGridMaterial.Columns["CreatedOn"].DefaultCellStyle.Format = "MM/dd/yyyy"; // Auto Resize dataGridMaterial.AutoResizeColumns(); dataGridMaterial.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridPrice.AutoResizeColumns(); dataGridPrice.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; BindAutoCompleteToMaterial(dt); }