private void label2_Click(object sender, EventArgs e) { try { expencecategory exp = new expencecategory(); exp.name = itemname.Text; exp.created_at = DateTime.Now; exp.updated_at = DateTime.Now; db.expencecategories.Add(exp); db.SaveChanges(); if (add != null) { add(this, new Custom.DataSaveargs { data = exp }); } notificationMAnager1.show("data has been successfully seved", 2000); itemname.Clear(); this.Dispose(); } catch (Exception ex) { } }
private void label2_Click(object sender, EventArgs e) { if (expname_txt.Text.Trim() == "") { notificationMAnager1.show("please fill the expenses category name", 2000); return; } try { expencecategory expense = db.expencecategories.Where(o => o.id == id).First(); expense.name = expname_txt.Text; db.Entry(expense).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); if (edit != null) { edit(this, new Custom.DataSaveargs { data = expense }); } notificationMAnager1.show("data are successfully saved", 2000); this.Dispose(); } catch (Exception ex) { notificationMAnager1.show(" please try again", 2000); } }
private void materialButton1_delete_Click(object sender, EventArgs e) { try { expencecategory exp = db.expencecategories.Where(o => o.id == this.id).First(); db.Entry(exp).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); notificationMAnager1.show("the data are successfully deleted", 2000); this.Parent.Controls.Remove(this); } catch (Exception ex) { notificationMAnager1.show("it has many sub type of expences first delete all sub type of expences", 4000); return; } }