internal int InsertAndGetId() { try { using (CategoriesDL _categoriesdlDL = new CategoriesDL()) { return(_categoriesdlDL.InsertAndGetId(this)); } } catch (Exception) { throw; } }
internal int Delete() { try { using (CategoriesDL _categoriesdlDL = new CategoriesDL()) { return(_categoriesdlDL.Delete(this)); } } catch (Exception) { throw; } }
public Form1() { InitializeComponent(); using (CategoriesDL catDL = new CategoriesDL()) { Categories cat = new Categories(); grdVw.DataSource = catDL.GetTable(cat);//catDL.Categories; //catDL.GetTable(cat); grdVw.Refresh(); cat.CategoryName = "MyNew Category"; cat.Description = "New Added Category"; cat.Picture = File.ReadAllBytes(@"C:\Users\Krkt\Desktop\suskun.jpg"); cat.CategoryID = catDL.InsertAndGetId(cat); MessageBox.Show(cat.CategoryID.ToString()); grdVw.DataSource = catDL.GetTable(cat); grdVw.Refresh(); } }