PersonnelQ.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Org.BouncyCastle.Asn1;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Text.Json;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace ddq
  13. {
  14. public partial class PersonnelQ : Form
  15. {
  16. private string personnelId;
  17. private string companyId;
  18. private int userId;
  19. public PersonnelQ(string personnelId, string companyId, int userId)
  20. {
  21. InitializeComponent();
  22. this.personnelId = personnelId;
  23. this.companyId = companyId;
  24. this.userId = userId;
  25. InitializeData();
  26. }
  27. private void InitializeData()
  28. {
  29. //int role_type;
  30. BindingSource bs = new BindingSource();
  31. Dictionary<int, string> d = new Dictionary<int, string>(Utility.RoleType);
  32. bs.DataSource = d;
  33. this.cmbRole.DataSource = bs;
  34. this.cmbRole.DisplayMember = "Value";
  35. this.cmbRole.ValueMember = "Key";
  36. this.cmbRole.SelectedValue = 1;
  37. if (personnelId != null)
  38. {
  39. DataTable dt = DataAccess.Get_dd_personnel_info(personnelId, companyId);
  40. if (dt != null && dt.Rows.Count > 0)
  41. {
  42. this.txtName.Text = dt.Rows[0]["name"].ToString();
  43. this.txtTitle.Text = dt.Rows[0]["title"].ToString();
  44. this.txtIndustryStartYear.Text = dt.Rows[0]["industry_start_year"].ToString();
  45. this.txtCompanyStartYear.Text = dt.Rows[0]["company_start_year"].ToString();
  46. this.txtBio.Text = dt.Rows[0]["bio"].ToString();
  47. string strRole = dt.Rows[0]["role"].ToString();
  48. int.TryParse(strRole, out int role);
  49. this.cmbRole.SelectedValue = role;
  50. }
  51. }
  52. }
  53. private void btnSavePersonnel_Click(object sender, EventArgs e)
  54. {
  55. int? companyStartYear = null;
  56. int? industryStartYear = null;
  57. if (int.TryParse(this.txtCompanyStartYear.Text, out int newYear)) { companyStartYear = newYear; }
  58. if (int.TryParse(this.txtIndustryStartYear.Text, out int newYear2)) { industryStartYear = newYear2; }
  59. DataAccess.Set_dd_personnel_info(personnelId, DateTime.Today, companyId,
  60. this.txtName.Text.Trim(),
  61. int.Parse(this.cmbRole.SelectedValue.ToString()),
  62. this.txtTitle.Text.Trim(),
  63. companyStartYear,
  64. industryStartYear,
  65. this.txtBio.Text.Trim(),
  66. 1, 1, userId, out string personnel_id);
  67. this.DialogResult = DialogResult.OK;
  68. }
  69. }
  70. }