private void DeleteItem(object sender, EventArgs e) { try { var element = sender as Label; string id = element.Name.Substring(1, element.Name.Length - 1); GlobalVariable.comiteID = id; List <komite> markazlist = dbcontext.komites.Where(x => x.markazID == id).ToList(); if (markazlist.Count == 0) { komite delitem = dbcontext.komites.SingleOrDefault(x => x.ID == GlobalVariable.comiteID); dbcontext.komites.Remove(delitem); dbcontext.SaveChanges(); Komite_List form2 = new Komite_List(); this.Hide(); //form2.Show(); } } catch (Exception errror) { message.Text = errror.InnerException.Message; } }
private void bakhshList_Click(object sender, EventArgs e) { Komite_List form = new Komite_List(); form.Show(); this.Hide(); }
private void filter_Click(object sender, EventArgs e) { string komiteID = GlobalVariable.comiteID; using (var dbcontext = new Model.Context()) { komite marz = dbcontext.komites.SingleOrDefault(x => x.ID == komiteID); if (marz.final != 1) { string parentID = marz.parent; marz.title = title.Text; marz.masoul = masool.Text; marz.janeshin = janeshin.Text; marz.markazID = bakhsh.SelectedValue.ToString(); List <komite> lst = dbcontext.komites.Where(x => x.parent == parentID).ToList(); foreach (komite item in lst) { item.master = "0"; } ; marz.isDone = true; marz.master = "1"; marz.final = 1; dbcontext.SaveChanges(); } GlobalVariable.comiteID = marz.parent; } this.Hide(); Komite_List form5 = new Komite_List(); form5.Show(); }