private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex; int rowindex = dataGridView1.CurrentCell.RowIndex; string rowID = dataGridView1.Rows[rowindex].Cells[1].Value.ToString(); if (iSelectedGridIndex == 0) { using (Context dbcontext = new Context()) { GlobalVariable.markazID = rowID; Markaz_add form2 = new Markaz_add(); form2.Show(); } } else if (iSelectedGridIndex == 0) { GlobalVariable.bakhshID = rowID; Bakhsh_add form2 = new Bakhsh_add(); form2.Show(); } else { return; } }
private void viewDetail(object sender, EventArgs e) { var element = sender as Label; string id = element.Name; GlobalVariable.markazID = id; Markaz_add form2 = new Markaz_add(); form2.Show(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex; int rowindex = dataGridView1.CurrentCell.RowIndex; string rowID = dataGridView1.Rows[rowindex].Cells[2].Value.ToString(); if (iSelectedGridIndex == 1) { using (Context dbcontext = new Context()) { markaz selecteditem = dbcontext.markazs.SingleOrDefault(x => x.ID == rowID); if (selecteditem.master != "1") { return; } DateTime date = DateTime.Now; TimeSpan time = DateTime.Now.TimeOfDay; string ID = RandomString(10); markaz model = new markaz() { masoul = selecteditem.masoul, BakhshID = selecteditem.BakhshID, changer = selecteditem.changer, date = date, time = time, ID = ID, parent = selecteditem.parent, final = 0, isDone = false, janeshin = selecteditem.janeshin, master = "0", title = selecteditem.title }; dbcontext.markazs.Add(model); dbcontext.SaveChanges(); GlobalVariable.markazID = ID; Markaz_add form2 = new Markaz_add(); form2.Show(); } } else if (iSelectedGridIndex == 0) { GlobalVariable.markazID = rowID; Markaz_add form2 = new Markaz_add(); form2.Show(); } else { return; } }
private void bakhshAdd_Click(object sender, EventArgs e) { using (Context dbcontext = new Context()) { string id = RandomString(10); markaz model = new markaz(); DateTime nowdatetime = DateTime.Now; model.master = "1"; model.ID = id; model.parent = id; model.date = nowdatetime; model.time = nowdatetime.TimeOfDay; model.changer = "admin"; dbcontext.markazs.Add(model); dbcontext.SaveChanges(); GlobalVariable.markazID = id; Markaz_add form = new Markaz_add(); form.Show(); } this.Hide(); }