private void label7_Click(object sender, EventArgs e) { Model.sarmaye model = new Model.sarmaye() { count = Int32.Parse(count.Text), creatoreCo = Ctitle.Text, title = title.Text, kollPD = Int32.Parse(koldollary.Text), kollPR = Int32.Parse(kolrially.Text), vahedPD = Int32.Parse(vaheddollary.Text), vahedPR = Int32.Parse(vahedrially.Text), shenasnameID = GlobalVariable.shenasnameID, }; dbcontext.sarmayes.Add(model); dbcontext.SaveChanges(); int index = 0; foreach (Form form in Application.OpenForms) { if (form.Name == "Form9_money_sarmaye") { break; } index += 1; } this.Hide(); Application.OpenForms[index].Close(); Form9_money_sarmaye form9 = new Form9_money_sarmaye(); form9.Show(); }
private void dataGridView1_CellDoubleClick(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.sarmaye model = dbcontext.sarmayes.SingleOrDefault(x => x.title == rowID && x.shenasnameID == GlobalVariable.shenasnameID); dbcontext.Entry(model).State = EntityState.Deleted; dbcontext.SaveChanges(); int index = 0; foreach (Form form in Application.OpenForms) { if (form.Name == "Form9_money_sarmaye") { break; } index += 1; } this.Hide(); Application.OpenForms[index - 1].Close(); Form9_money_sarmaye form9 = new Form9_money_sarmaye(); form9.Show(); } } }