private void ackbtn_Click(object sender, EventArgs e) { //添加奖惩信息 #region string time = System.DateTime.Now.ToString(); Reward_Punish addrp = new Reward_Punish(); addrp.studengID = idbox.Text; addrp.xuenian = yearbox.Text; addrp.rewards = rewardbox.Text; addrp.punishments = punishbox.Text; addrp.ID = idbox.Text + " " + time; try { db.Reward_Punish.InsertOnSubmit(addrp); db.SubmitChanges(); MessageBox.Show("添加成功"); } catch { MessageBox.Show("添加失败"); } #endregion //初始化datagridview内容,显示当前所有同学的奖惩情况 #region var again = (from studentrp in db.Reward_Punish from studentname in db.student where studentrp.studengID == studentname.Student_id select new { 姓名 = studentname.Student_name, 学号 = studentname.Student_id, 学年 = studentrp.xuenian, 奖励 = studentrp.rewards, 惩罚 = studentrp.punishments }).ToList(); dataGridView1.DataSource = again; #endregion }
partial void DeleteReward_Punish(Reward_Punish instance);
partial void UpdateReward_Punish(Reward_Punish instance);
partial void InsertReward_Punish(Reward_Punish instance);