/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { DSIStaffInfo data = new DSIStaffInfo(); data.StaffID = this.StaffID.IsValid ? this.StaffID : GUIDEx.New; if (this.ucStaffInfo.SaveData(data)) this.SaveData(); } catch (System.Data.SqlClient.SqlException x) { if (x.Number == 2627) this.ShowMessage("教职工编号或身份证号重复!"); else this.ShowMessage(x.Message); } catch (Exception x) { this.ShowMessage(x.Message); } }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public bool SaveData(DSIStaffInfo data) { bool result = false; if (data == null) return result; data.StaffCode = this.txtStaffCode.Text; data.HardCategory = int.Parse(this.ddlHardCategory.SelectedValue); data.Theidentity = int.Parse(this.ddlTheidentity.SelectedValue); data.StaffName = this.txtStaffName.Text; data.PeopleID = this.ddlPeople.SelectedValue; data.Gender = int.Parse(this.ddlGender.SelectedValue); data.PoliticalFace = int.Parse(this.ddlPoliticalFace.SelectedValue); data.HealthStatus = int.Parse(this.ddlHealthStatus.SelectedValue); data.Disability = this.txtDisability.Text; data.IDCard = this.txtIDCard.Text; if (!string.IsNullOrEmpty(this.txtBirthday.Text)) data.Birthday = DateTime.Parse(this.txtBirthday.Text + "-01"); data.HouseType = int.Parse(this.ddlHouseType.SelectedValue); data.BuildArea = float.Parse(this.txtBuildArea.Text); data.ZipCode = this.txtZipCode.Text; data.Contact = this.txtContact.Text; data.Address = this.txtAddress.Text; data.Maritalstatus = int.Parse(this.ddlMaritalstatus.SelectedValue); if (!string.IsNullOrEmpty(this.txtTimeWorkStart.Text)) data.TimeWorkStart = DateTime.Parse(this.txtTimeWorkStart.Text + "-01"); data.UnitID = this.ddlUnit.SelectedValue; data.AvgIncome = float.Parse(this.txtAvgIncome.Text); data.FamilyIncome = float.Parse(this.txtFamilyIncome.Text); data.FamilyCount = int.Parse(this.txtFamilyCount.Text); data.FamilyAvgIncome = float.Parse(this.txtFamilyAvgIncome.Text); data.SelfHelp = int.Parse(this.rdSelfHelp.SelectedValue); data.HardBecause = int.Parse(this.ddlHardBecause.SelectedValue); data.HardBecauseDesc = this.txtHardBecauseDesc.Text.Trim(); data.CreateUserID = this.CurrentUserID; data.CreateUserName = this.CurrentUserName; data.CreateTime = DateTime.Now; data.FamilyMembers = this.ucStaffFamily.FamilyMemberDataSource; this.uploadAttachments.SaveUploadAs(new EventHandler<iPower.Web.Upload.UploadViewEventArgs>(delegate(object sender, iPower.Web.Upload.UploadViewEventArgs e) { if (e != null && e.ItemRaw != null) { DSIAttachment attachment = new DSIAttachment(); attachment.ID = e.ItemRaw.FileID; attachment.Name = e.ItemRaw.FileName; attachment.ContentType = e.ItemRaw.ContentType; attachment.Create = DateTime.Now; attachment.Raw = e.ItemRaw.FileRaw; if (data.Attachments == null) data.Attachments = new List<DSIAttachment>(); data.Attachments.Add(attachment); } })); return this.presenter.UpdateData(data, this.uploadAttachments.DeleteFileID); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public bool SaveData(DSIStaffInfo data) { return this.ucStaff.SaveData(data); }
/// <summary> /// /// </summary> /// <param name="data"></param> public void LoadData(DSIStaffInfo data) { if (data != null) { this.StaffID = data.StaffID; this.txtStaffCode.Text = data.StaffCode; this.ddlHardCategory.SelectedValue = data.HardCategory.ToString(); this.ddlTheidentity.SelectedValue = data.Theidentity.ToString(); this.txtStaffName.Text = data.StaffName; this.ddlPeople.SelectedValue = data.PeopleID; this.ddlGender.SelectedValue = data.Gender.ToString(); this.ddlPoliticalFace.SelectedValue = data.PoliticalFace.ToString(); this.ddlHealthStatus.SelectedValue = data.HealthStatus.ToString(); this.txtDisability.Text = data.Disability; this.txtIDCard.Text = data.IDCard; if (data.Birthday != DateTime.MinValue && data.Birthday != DateTime.MaxValue) this.txtBirthday.Text = string.Format("{0:yyyy-MM}", data.Birthday); else this.txtBirthday.Text = string.Empty; this.ddlHouseType.SelectedValue = data.HouseType.ToString(); this.txtBuildArea.Text = string.Format("{0:N2}", data.BuildArea); this.txtZipCode.Text = data.ZipCode; this.txtContact.Text = data.Contact; this.txtAddress.Text = data.Address; this.ddlMaritalstatus.SelectedValue = data.Maritalstatus.ToString(); if (data.TimeWorkStart != DateTime.MinValue && data.TimeWorkStart != DateTime.MaxValue) this.txtTimeWorkStart.Text = string.Format("{0:yyyy-MM}", data.TimeWorkStart); else this.txtTimeWorkStart.Text = string.Empty; this.ddlUnit.SelectedValue = data.UnitID; this.txtAvgIncome.Text = string.Format("{0:N2}", data.AvgIncome); this.txtFamilyIncome.Text = string.Format("{0:N2}", data.FamilyIncome); this.txtFamilyCount.Text = string.Format("{0}", data.FamilyCount); this.txtFamilyAvgIncome.Text = string.Format("{0:N2}", data.FamilyAvgIncome); this.rdSelfHelp.SelectedValue = data.SelfHelp.ToString(); this.ddlHardBecause.SelectedValue = data.HardBecause.ToString(); this.txtHardBecauseDesc.Text = data.HardBecauseDesc; this.uploadAttachments.DataSource = data.Attachments; this.uploadAttachments.BuildUploadView(); this.ucStaffFamily.FamilyMemberDataSource = data.FamilyMembers; this.ucStaffFamily.LoadData(); } }
/// <summary> /// /// </summary> /// <param name="data"></param> public void LoadData(DSIStaffInfo data) { this.ucStaff.LoadData(data); }