private void InsertNewEntitybutton_Click(object sender, EventArgs e) { if (EntityStructure.Viewtype != ViewType.Table) { MessageBox.Show("Cannot Edit an Non Table Structure", "BeepDM"); } else { if (ds != null && ds.ConnectionStatus == ConnectionState.Open) { EntitybindingSource.AddNew(); ob = EntitybindingSource.Current; if (Passedarg.Objects.Where(i => i.Name == EntityName).Any()) { Passedarg.Objects.Remove(Passedarg.Objects.Where(i => i.Name == EntityName).FirstOrDefault()); } if (Passedarg.Objects.Where(i => i.Name == "BindingSource").Any()) { Passedarg.Objects.Remove(Passedarg.Objects.Where(i => i.Name == "BindingSource").FirstOrDefault()); } Passedarg.Objects.Add(new ObjectItem() { Name = EntityName, obj = ob }); Passedarg.Objects.Add(new ObjectItem() { Name = "BindingSource", obj = EntitybindingSource }); Visutil.ShowUserControlPopUp("uc_Insertentity", DMEEditor, new string[] { "" }, Passedarg); // RefreshData(); } } }
private void RefreshData(object obj) { EntitybindingSource.DataSource = obj; EntitybindingSource.ResetBindings(true); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = EntitybindingSource; dataGridView1.Refresh(); EntityNamelabel.Text = EntityName; subtitlelabel.Text = $"From Data Source : {ds.DatasourceName}"; }
private void DeleteSelectedbutton_Click(object sender, EventArgs e) { if (EntityStructure.Viewtype != ViewType.Table) { MessageBox.Show("Cannot Edit an Non Table Structure", "BeepDM"); } else { if (MessageBox.Show(this, "Delete", "Are you sure ? ", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (ds != null && ds.ConnectionStatus == ConnectionState.Open) { if (dataGridView1.SelectedRows.Count > 0) { object ob = EntitybindingSource.Current; try { if (ds.DeleteEntity(EntityName, ob).Flag == Errors.Failed) { EntitybindingSource.RemoveCurrent(); GetData(); MessageBox.Show("Failed to Delete Record"); } else { MessageBox.Show("Success to Delete Record"); } } catch (Exception ex) { throw; } } } } } }