private void ResetControlContent() { txboxAwardName.Text = ""; txboxDesc.Text = ""; txboxSchoolActivity.Text = ""; award = null; }
private bool Save() { if (string.IsNullOrWhiteSpace(txboxAwardName.Text)) { MessageBox.Show("请填写奖项名称"); return false; } if (cmboxAwardLevel.Text == "请选择") { MessageBox.Show("请选择奖项级别"); return false; } try { List<Award> lsa = datagvAward.DataSource as List<Award>; datagvAward.DataSource = null; if (award == null) { award = new Award( null, resume.Id, txboxAwardName.Text, cmboxAwardLevel.Text, datetpGetDate.Value, txboxDesc.Text, lsa.Count + 1); lsa.Add(award); } else { award.AwardName = txboxAwardName.Text; award.AwardDesc = txboxDesc.Text; award.AwardGetDate = datetpGetDate.Value; award.AwardLevel = cmboxAwardLevel.Text; } service.AddOrUpdate(award); datagvAward.DataSource = lsa; return true; } catch (Exception ex) { MessageBox.Show("保存专业技能时出错:" + ex.Message); return false; } }
private void datagvAward_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (datagvAward.Columns[e.ColumnIndex].HeaderText == "删除") { if (MessageBox.Show("将直接删除数据信息且不可恢复,确定删除?", "删除?", MessageBoxButtons.YesNo) == DialogResult.Yes) { List<Award> lsa = datagvAward.DataSource as List<Award>; Award award = GetSocialPracticeFromDgv(e.RowIndex); datagvAward.DataSource = null; service.Delete(award); lsa.Remove(award); datagvAward.DataSource = lsa; } } if (datagvAward.Columns[e.ColumnIndex].HeaderText == "编辑") { award = GetSocialPracticeFromDgv(e.RowIndex); txboxAwardName.Text = award.AwardName; txboxDesc.Text = award.AwardDesc; datetpGetDate.Value = award.AwardGetDate.Value; cmboxAwardLevel.Text = award.AwardLevel; } }