| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using Org.BouncyCastle.Asn1;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Text.Json;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using static ddq.DataAccess;
- using static ddq.Utility;
- namespace ddq
- {
- public partial class PersonnelQ : Form
- {
- private string personnelId;
- private string companyId;
- private int userId;
- public PersonnelQ(string personnelId, string companyId, int userId)
- {
- InitializeComponent();
- this.personnelId = personnelId;
- this.companyId = companyId;
- this.userId = userId;
- InitializeData();
-
- }
- private void InitializeData()
- {
- //int role_type;
- BindingSource bs = new BindingSource();
- Dictionary<int, string> d = new Dictionary<int, string>(Utility.RoleType);
- bs.DataSource = d;
- this.cmbRole.DataSource = bs;
- this.cmbRole.DisplayMember = "Value";
- this.cmbRole.ValueMember = "Key";
- this.cmbRole.SelectedValue = 1;
- if (personnelId != null)
- {
- DataTable dt = DataAccess.Get_dd_personnel_info(personnelId, companyId);
- if (dt != null && dt.Rows.Count > 0)
- {
- this.txtName.Text = dt.Rows[0]["name"].ToString();
- this.txtTitle.Text = Null2Text(dt.Rows[0]["title"]);
- this.txtIndustryStartYear.Text = Null2Text(dt.Rows[0]["industry_start_year"]);
- this.txtCompanyStartYear.Text = Null2Text(dt.Rows[0]["company_start_year"]);
- this.txtBio.Text = Null2Text(dt.Rows[0]["bio"]);
- this.tspManagerInfo.Text = DateTime.Parse(dt.Rows[0]["updatetime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- this.tspManagerInfo.ForeColor = IsChangedRecently(this.tspManagerInfo.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
- string strRole = dt.Rows[0]["role"].ToString();
- int.TryParse(strRole, out int role);
- this.cmbRole.SelectedValue = role;
- }
- }
- }
- private string Null2Text(object o)
- {
- if (o == null) return "";
- return o.ToString();
- }
- private void btnSavePersonnel_Click(object sender, EventArgs e)
- {
- int? companyStartYear = null;
- int? industryStartYear = null;
- if (int.TryParse(this.txtCompanyStartYear.Text, out int newYear)) { companyStartYear = newYear; }
- if (int.TryParse(this.txtIndustryStartYear.Text, out int newYear2)) { industryStartYear = newYear2; }
- DataAccess.Set_dd_personnel_info(personnelId, DateTime.Today, companyId,
- this.txtName.Text.Trim(),
- int.Parse(this.cmbRole.SelectedValue.ToString()),
- this.txtTitle.Text.Trim(),
- companyStartYear,
- industryStartYear,
- this.txtBio.Text.Trim(),
- 1, 1, userId, out string personnel_id);
- this.DialogResult = DialogResult.OK;
- }
- }
- }
|