private void btnAdd_Click(object sender, EventArgs e) { try { if (WorkerName.Text != null && cboSex.Text != null) { string NewID = Md5LockedUtil.MD5Encrypt32(WorkerID.Text.ToString()); string NewTel = Md5LockedUtil.MD5Encrypt32(WorkerTel.Text.ToString()); #region 员工信息添加代码块 Worker worker = new Worker { WorkerId = WorkerNo.Text.Trim(), WorkerName = WorkerName.Text.Trim(), WorkerBirthday = dtpBirthday.Value, WorkerSex = (int)cboSex.SelectedValue, WorkerNation = cbWorkerNation.SelectedValue.ToString(), WorkerTel = NewTel, WorkerClub = cboClub.SelectedValue.ToString(), WorkerAddress = txtAddress.Text, WorkerPosition = cboWorkerPosition.SelectedValue.ToString(), CardId = NewID, WorkerTime = dtpTime.Value, WorkerFace = cboWorkerFace.Text, WorkerEducation = cboEducation.SelectedValue.ToString(), datains_usr = AdminInfo.Account, datains_date = DateTime.Now }; bool n = new WorkerService().AddWorker(worker); #endregion if (ucHistory.txtCompany != null && ucHistory.txtPosition != null && ucHistory.dtpStartDate.Value != null && ucHistory.dtpEndDate.Value != null) { #region 履历添加代码块 WorkerHistory workerHistory = new WorkerHistory { StartDate = ucHistory.dtpStartDate.Value, EndDate = ucHistory.dtpEndDate.Value, Position = ucHistory.txtPosition.Text, Company = ucHistory.txtCompany.Text, WorkerId = WorkerNo.Text.Trim() }; bool j = new WorkerHistoryService().AddHistoryByWorkerId(workerHistory); #endregion #region 判断履历和信息代码块 if (n == true && j == true) { UIMessageBox.Show("员工信息/履历添加成功!该员工登录密码为:123456,请提醒员工妥善保管并首次登录系统时修改密码!"); FrmWorkerManager.Reload(); #region 获取添加操作日志所需的信息 OperationLog o = new OperationLog(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = AdminInfo.Account + AdminInfo.Name + "于" + DateTime.Now + "进行了添加员工操作,员工编号为:" + WorkerNo.Text + "!"; o.OperationAccount = AdminInfo.Account + AdminInfo.Name; o.datains_usr = AdminInfo.Account; o.datachg_date = DateTime.Now; new OperationlogService().InsertOperationLog(o); #endregion } else { UIMessageBox.Show("员工信息/履历添加失败,请检查数据格式或稍后再试!"); } #endregion } } else { UIMessageBox.Show("信息不能为空!"); } } catch (Exception ex) { //MessageBox.Show(ex.ToString()); UIMessageBox.Show("服务器繁忙或数据格式为空!"); } finally { this.Close(); } }
public static int AddHistoryByWorkerId(WorkerHistory workerHistory, string wid) { return(WorkerHistoryService.AddHistoryByWorkerId(workerHistory, wid)); }
private void FrmAddWorker_Load(object sender, EventArgs e) { //加载部门信息 cboClub.DataSource = new BaseService().SelectDeptAll(); cboClub.DisplayMember = "dept_name"; cboClub.ValueMember = "dept_no"; //加载民族信息 cbWorkerNation.DataSource = new BaseService().SelectNationAll(); cbWorkerNation.DisplayMember = "nation_name"; cbWorkerNation.ValueMember = "nation_no"; //加载职位信息 cboWorkerPosition.DataSource = new BaseService().SelectPositionAll(); cboWorkerPosition.DisplayMember = "position_name"; cboWorkerPosition.ValueMember = "position_no"; //加载性别信息 cboSex.DataSource = new BaseService().SelectSexTypeAll(); cboSex.DisplayMember = "sexName"; cboSex.ValueMember = "sexId"; //加载学历信息 cboEducation.DataSource = new BaseService().SelectEducationAll(); cboEducation.DisplayMember = "education_name"; cboEducation.ValueMember = "education_no"; pictureBox1.LoadAsync("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1587209835893&di=02964b1de4a1ef4f938f7d3ae12b5b17&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F17%2F11%2F25%2F0ef5a188956c2717db96d72d58524dec.jpg"); if (this.Text == "员工信息查看页") { foreach (Control control in this.Controls) { switch (control.GetType().ToString()) { case "Sunny.UI.UITextBox": (control as Sunny.UI.UITextBox).ReadOnly = true; break; case "Sunny.UI.UIComboBox": (control as Sunny.UI.UIComboBox).ReadOnly = true; break; case "Sunny.UI.UIDatePicker": (control as Sunny.UI.UIDatePicker).ReadOnly = true; break; } } btnAdd.Visible = false; WorkerNo.Text = FrmChangeWorker.wk_WorkerNo; WorkerName.Text = FrmChangeWorker.wk_WorkerName; cboSex.Text = FrmChangeWorker.wk_WorkerSex; cboWorkerPosition.Text = FrmChangeWorker.wk_WorkerPosition; cboWorkerFace.Text = FrmChangeWorker.wk_WorkerFace; cbWorkerNation.Text = FrmChangeWorker.wk_WorkerNation; dtpBirthday.Value = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday); dtpTime.Value = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime); WorkerID.Text = FrmChangeWorker.wk_WorkerID; txtAddress.Text = FrmChangeWorker.wk_WorkerAddress; WorkerTel.Text = FrmChangeWorker.wk_WorkerTel; cboEducation.Text = FrmChangeWorker.wk_WorkerEducation; cboClub.Text = FrmChangeWorker.wk_WorkerClub; this.WorkerID.Validated -= new EventHandler(WorkerID_Validated); List <WorkerHistory> workerHistories = new WorkerHistoryService().SelectHistoryByWorkerId(WorkerNo.Text); for (int i = 0; i < workerHistories.Count; i++) { ucHistory = new ucHistory(); ucHistory.dtpStartDate.Value = workerHistories[i].StartDate; ucHistory.dtpEndDate.Value = workerHistories[i].EndDate; ucHistory.txtPosition.Text = workerHistories[i].Position; ucHistory.txtCompany.Text = workerHistories[i].Company; ucHistory.dtpStartDate.ReadOnly = true; ucHistory.dtpEndDate.ReadOnly = true; ucHistory.txtPosition.ReadOnly = true; ucHistory.txtCompany.ReadOnly = true; flpHistory.Controls.Add(ucHistory); } } else if (this.Text == "添加员工") { WorkerNo.Text = new CounterHelper().GetNewId("WorkerId"); ucHistory = new ucHistory(); //ucHistory.txtCompany.ReadOnly = false; //ucHistory.txtPosition.ReadOnly = false; ucHistory.dtpStartDate.Enabled = true; ucHistory.dtpEndDate.Enabled = true; ucHistory.txtCompany.Enabled = true; ucHistory.txtPosition.Enabled = true; flpHistory.Controls.Add(ucHistory); cboClub.SelectedIndex = 0; cboEducation.SelectedIndex = 0; cboSex.SelectedIndex = 0; cboWorkerFace.SelectedIndex = 0; cboWorkerPosition.SelectedIndex = 0; } else { bool dr = UIMessageBox.Show("修改操作仅能修改姓名、性别、电话号码、联系地址、面貌以及最高学历,以上是否知晓?点击确定继续进行修改!", "修改提醒", UIStyle.Orange, UIMessageBoxButtons.OKCancel); if (dr == true) { foreach (Control item in this.Controls) { switch (item.Name) { case "Sunny.UI.UITextBox": (item as Sunny.UI.UITextBox).ReadOnly = true; break; case "Sunny.UI.UIComboBox": (item as Sunny.UI.UIComboBox).ReadOnly = true; break; case "Sunny.UI.UIDatePicker": (item as Sunny.UI.UIDatePicker).ReadOnly = true; break; } } WorkerNo.Text = FrmChangeWorker.wk_WorkerNo; WorkerName.Text = FrmChangeWorker.wk_WorkerName; cboSex.Text = FrmChangeWorker.wk_WorkerSex; cboWorkerPosition.Text = FrmChangeWorker.wk_WorkerPosition; cboWorkerFace.Text = FrmChangeWorker.wk_WorkerFace; cbWorkerNation.Text = FrmChangeWorker.wk_WorkerNation; dtpBirthday.Value = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday); dtpTime.Value = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime); WorkerID.Text = FrmChangeWorker.wk_WorkerID; txtAddress.Text = FrmChangeWorker.wk_WorkerAddress; WorkerTel.Text = FrmChangeWorker.wk_WorkerTel; cboEducation.Text = FrmChangeWorker.wk_WorkerEducation; cboClub.Text = FrmChangeWorker.wk_WorkerClub; this.WorkerID.Validated -= new EventHandler(WorkerID_Validated); btnAdd.Text = "修改"; this.btnAdd.Click -= new EventHandler(btnAdd_Click); this.btnAdd.Click += new EventHandler(btnUpd_Click); WorkerTel.ReadOnly = false; txtAddress.ReadOnly = false; List <WorkerHistory> workerHistories = new WorkerHistoryService().SelectHistoryByWorkerId(WorkerNo.Text); for (int i = 0; i < workerHistories.Count; i++) { ucHistory = new ucHistory(); ucHistory.dtpStartDate.Value = workerHistories[i].StartDate; ucHistory.dtpEndDate.Value = workerHistories[i].EndDate; ucHistory.txtPosition.Text = workerHistories[i].Position; ucHistory.txtCompany.Text = workerHistories[i].Company; flpHistory.Controls.Add(ucHistory); } } } }
public static List <WorkerHistory> SelectHistoryByWorkerId(string wid) { return(WorkerHistoryService.SelectHistoryByWorkerId(wid)); }