private void label8_Click(object sender, EventArgs e) { Form15_addOmrani form = new Form15_addOmrani(); form.Show(); this.Hide(); }
private void label7_Click(object sender, EventArgs e) { Model.omrani model = new Model.omrani() { kollPD = Int32.Parse(dollari.Text), kollPR = Int32.Parse(rially.Text), title = title.Text, zirbana = Int32.Parse(zirbana.Text), shenasnameID = GlobalVariable.shenasnameID, }; dbcontext.omranis.Add(model); dbcontext.SaveChanges(); int index = 0; foreach (Form form in Application.OpenForms) { if (form.Name == "Form15_addOmrani") { break; } index += 1; } this.Hide(); Application.OpenForms[index].Close(); Form15_addOmrani form15 = new Form15_addOmrani(); form15.Show(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { using (var dbcontext = new Model.Context()) { Model.shenasname item = dbcontext.shenasnames.Where(x => x.ID == GlobalVariable.shenasnameID).FirstOrDefault(); if (item.final != 1) { int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex; if (iSelectedGridIndex != 0) { return; } int rowindex = dataGridView1.CurrentCell.RowIndex; string rowID = dataGridView1.Rows[rowindex].Cells[2].Value.ToString(); Model.omrani model = dbcontext.omranis.SingleOrDefault(x => x.title == rowID); dbcontext.Entry(model).State = EntityState.Deleted; dbcontext.SaveChanges(); int index = 0; foreach (Form form in Application.OpenForms) { if (form.Name == "Form15_addOmrani") { break; } index += 1; } this.Hide(); Application.OpenForms[index - 1].Close(); Form15_addOmrani form13 = new Form15_addOmrani(); form13.Show(); } } }