Esempio n. 1
0
        /// <summary>
        /// 操作数据列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvCertificateData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0) return;
            if (dgvCertificateData.Columns[e.ColumnIndex].Name == "Delete")
            {
                List<Certificate> temp = dgvCertificateData.DataSource as List<Certificate>;
                Certificate cert = GetCertificateFromDgv(e.RowIndex);
                DialogResult result = MessageBox.Show("确定要删除该项?删除后不可恢复", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        certificateService.Delete(cert);
                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show("删除记录出错"+ex.Message);
                    }
                    dgvCertificateData.DataSource = null;
                    temp.Remove(cert);
                    dgvCertificateData.DataSource = temp;
                }
            }
            if (dgvCertificateData.Columns[e.ColumnIndex].Name == "Modify")
            {
                 List<Certificate> cerList = dgvCertificateData.DataSource as List<Certificate>;
                 certificate = cerList[e.RowIndex];
                 this.cboCertificateType.Text = certificate.CertificateType;
                 if (certificate.CertificateType == "自定义证书")
                 {
                     txtCertificateNmae.Visible = true;
                     this.txtCertificateNmae.Text = certificate.CertificateName;
                 }
                 else this.cboCertificateName.Text = certificate.CertificateName;
                 this.cboGetYear.Text = DateTime.Now.Year.ToString();
                 this.cboGetMonth.Text = DateTime.Now.Month.ToString();

            }
        }
Esempio n. 2
0
 /// <summary>
 /// 添加证书并更新数据列表
 /// </summary>
 private void CreatAndAdd()
 {
     if (cboCertificateName.Text == "" && txtCertificateNmae.Text == "" || cboGetYear.Text == "" || cboGetMonth.Text == "")
     {
         MessageBox.Show("信息不完整");
         return;
     }
     certificate = new Certificate();
     certificate.ResumeId = resume.Id;
     certificate.CertificateType = cboCertificateType.Text;
     certificate.CertificateName = (cboCertificateType.Text != "自定义证书") ? cboCertificateName.Text : txtCertificateNmae.Text;
     try
     {
         String data = cboGetYear.Text + "-" + cboGetMonth.Text;
         certificate.CertificateGetDate = DateTime.Parse(data);
     }
     catch
     { MessageBox.Show("请输入完整日期"); }
     if (TheSameCertificate(resume, certificate.CertificateName))
     {
         MessageBox.Show("证书" + "【" + certificate.CertificateName.ToString() + "】" + "已经存在");
         clearInfo();
         return;
     }
     else
         certificateService.AddOrUpdate(certificate);
     RefreshDgvData(this.resume);
 }