private void button1_Click(object sender, EventArgs e) { if (sel1 >= 0 && sel2 >= 0) { Exercise_form.ServiceReference1.classExp mcq = new classExp(); mcq.attach = checkBox1.Checked; mcq.maxatta = int.Parse(comboBox2.Text); mcq.maxfile = int.Parse(comboBox1.Text); mcq.starttime = dateTimePicker1.Value; mcq.endtime = dateTimePicker2.Value; mcq.cid = ((classinfo)Lcs[sel1]).classid; mcq.expid = ((exp_q)Lexp1[sel2]).idexp; try { pp.context.AddToclassExp(mcq); pp.context.SaveChanges(); } catch { pp.context.DeleteObject(mcq); MessageBox.Show("关联已经存在"); } } else { MessageBox.Show("请选择班级和实验"); } displayexp2(); }
private void button3_Click(object sender, EventArgs e) { if (listBox3.SelectedIndex >= 0) { int cid2 = Lexp2[sel3].classid; int expid2 = Lexp2[sel3].expid; var q4 = from o in pp.context.classExp where o.cid == cid2 && o.expid == expid2 select o; classExp eed = q4.First <classExp>(); eed.attach = checkBox1.Checked; eed.maxatta = int.Parse(comboBox2.Text); eed.maxfile = int.Parse(comboBox1.Text); eed.starttime = dateTimePicker1.Value; eed.endtime = dateTimePicker2.Value; pp.context.UpdateObject(eed); pp.context.SaveChanges(); dispalylist(); } else { MessageBox.Show("please select a list"); } }
private void listBox3_SelectedIndexChanged(object sender, EventArgs e) { sel3 = listBox3.SelectedIndex; // if (listBox3.SelectedIndex >= 0) { int cid2 = Lexp2[sel3].classid; int expid2 = Lexp2[sel3].expid; var q4 = from o in pp.context.classExp where o.cid == cid2 && o.expid == expid2 select o; classExp eed = q4.First <classExp>(); // eed.attach = checkBox1.Checked; //eed.maxatta = int.Parse(comboBox2.Text); //eed.maxfile = int.Parse(comboBox1.Text); //eed.starttime = dateTimePicker1.Value; //eed.endtime = dateTimePicker2.Value; checkBox1.Checked = (bool)eed.attach; comboBox2.Text = eed.maxatta.ToString(); comboBox1.Text = eed.maxfile.ToString(); dateTimePicker1.Value = (DateTime)eed.starttime; dateTimePicker2.Value = (DateTime)eed.endtime; } // }
private void button2_Click(object sender, EventArgs e) { if (listBox3.SelectedIndex >= 0) { int cid2 = Lexp2[sel3].classid; int expid2 = Lexp2[sel3].expid; var q4 = from o in pp.context.classExp where o.cid == cid2 && o.expid == expid2 select o; classExp eed = q4.First <classExp>(); pp.context.DeleteObject(eed); pp.context.SaveChanges(); displayexp2(); } }