private LPModel.ProspectEmployment CreateModelFromPage() { LPModel.ProspectEmployment model = new LPModel.ProspectEmployment(); model.CompanyName = this.txtEmployer.Text; if (hfdEmploymentId.Value != "-1") { model.EmplId = Convert.ToInt32(hfdEmploymentId.Value); } model.ContactId = Convert.ToInt32(hfdContractId.Value); if (!string.IsNullOrEmpty(hfdBranchContractId.Value)) { model.ContactBranchId = Convert.ToInt32(hfdBranchContractId.Value.ToString()); } model.SelfEmployed = checkSelf.Checked; model.Position = txtPisition.Text; if (string.IsNullOrEmpty(txtStart.Text)) { model.StartMonth = null; model.StartYear = null; } else { model.StartMonth = Convert.ToDecimal(txtStart.Text.Split('/')[0]); model.StartYear = Convert.ToDecimal(txtStart.Text.Split('/')[1]); } if (string.IsNullOrEmpty(txtEnd.Text)) { model.EndMonth = null; model.EndYear = null; } else { model.EndMonth = Convert.ToDecimal(txtEnd.Text.Split('/')[0]); model.EndYear = Convert.ToDecimal(txtEnd.Text.Split('/')[1]); } model.Phone = txtPhone.Text; if (!string.IsNullOrEmpty(txtYearsExp.Text)) { model.YearsOnWork = Convert.ToDecimal(txtYearsExp.Text); } model.Address = txtAddress.Text; model.City = txtCity.Text; model.State = ddlState.SelectedValue; model.Zip = txtZip.Text; model.BusinessType = txtBusinessType.Text; model.VerifyYourTaxes = checkVerify.Checked; return(model); }
protected void btnSave_Click(object sender, EventArgs e) { LPModel.ProspectEmployment model = CreateModelFromPage(); if (hfdEmploymentId.Value == "-1") { new ProspectEmployment().Add(model); } else { new ProspectEmployment().Update(model); LPWeb.BLL.ProspectIncome bll = new ProspectIncome(); bll.UpdateIncome(model.EmplId, string.IsNullOrEmpty(txtSalary.Text) ? "NULL" : txtSalary.Text); } StringBuilder sbJavaScript = new StringBuilder(); sbJavaScript.AppendLine("$('#divContainer').hide();"); sbJavaScript.AppendLine("alert('The Point file(s) has been updated successfully.'); CancelOnClick();"); // success this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", sbJavaScript.ToString(), true); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(LPWeb.Model.ProspectEmployment model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LPWeb.Model.ProspectEmployment model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <LPWeb.Model.ProspectEmployment> DataTableToList(DataTable dt) { List <LPWeb.Model.ProspectEmployment> modelList = new List <LPWeb.Model.ProspectEmployment>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LPWeb.Model.ProspectEmployment model; for (int n = 0; n < rowsCount; n++) { model = new LPWeb.Model.ProspectEmployment(); if (dt.Rows[n]["EmplId"] != null && dt.Rows[n]["EmplId"].ToString() != "") { model.EmplId = int.Parse(dt.Rows[n]["EmplId"].ToString()); } if (dt.Rows[n]["ContactId"] != null && dt.Rows[n]["ContactId"].ToString() != "") { model.ContactId = int.Parse(dt.Rows[n]["ContactId"].ToString()); } if (dt.Rows[n]["SelfEmployed"] != null && dt.Rows[n]["SelfEmployed"].ToString() != "") { if ((dt.Rows[n]["SelfEmployed"].ToString() == "1") || (dt.Rows[n]["SelfEmployed"].ToString().ToLower() == "true")) { model.SelfEmployed = true; } else { model.SelfEmployed = false; } } if (dt.Rows[n]["Position"] != null && dt.Rows[n]["Position"].ToString() != "") { model.Position = dt.Rows[n]["Position"].ToString(); } if (dt.Rows[n]["StartYear"] != null && dt.Rows[n]["StartYear"].ToString() != "") { model.StartYear = decimal.Parse(dt.Rows[n]["StartYear"].ToString()); } if (dt.Rows[n]["StartMonth"] != null && dt.Rows[n]["StartMonth"].ToString() != "") { model.StartMonth = decimal.Parse(dt.Rows[n]["StartMonth"].ToString()); } if (dt.Rows[n]["EndYear"] != null && dt.Rows[n]["EndYear"].ToString() != "") { model.EndYear = decimal.Parse(dt.Rows[n]["EndYear"].ToString()); } if (dt.Rows[n]["EndMonth"] != null && dt.Rows[n]["EndMonth"].ToString() != "") { model.EndMonth = decimal.Parse(dt.Rows[n]["EndMonth"].ToString()); } if (dt.Rows[n]["YearsOnWork"] != null && dt.Rows[n]["YearsOnWork"].ToString() != "") { model.YearsOnWork = decimal.Parse(dt.Rows[n]["YearsOnWork"].ToString()); } if (dt.Rows[n]["Phone"] != null && dt.Rows[n]["Phone"].ToString() != "") { model.Phone = dt.Rows[n]["Phone"].ToString(); } if (dt.Rows[n]["ContactBranchId"] != null && dt.Rows[n]["ContactBranchId"].ToString() != "") { model.ContactBranchId = int.Parse(dt.Rows[n]["ContactBranchId"].ToString()); } if (dt.Rows[n]["CompanyName"] != null && dt.Rows[n]["CompanyName"].ToString() != "") { model.CompanyName = dt.Rows[n]["CompanyName"].ToString(); } if (dt.Rows[n]["Address"] != null && dt.Rows[n]["Address"].ToString() != "") { model.Address = dt.Rows[n]["Address"].ToString(); } if (dt.Rows[n]["City"] != null && dt.Rows[n]["City"].ToString() != "") { model.City = dt.Rows[n]["City"].ToString(); } if (dt.Rows[n]["State"] != null && dt.Rows[n]["State"].ToString() != "") { model.State = dt.Rows[n]["State"].ToString(); } if (dt.Rows[n]["Zip"] != null && dt.Rows[n]["Zip"].ToString() != "") { model.Zip = dt.Rows[n]["Zip"].ToString(); } modelList.Add(model); } } return(modelList); }
/// <summary> /// /// </summary> /// <param name="iContactId"></param> /// <param name="sCompanyName"></param> /// <param name="bSelfEmployed"></param> /// <param name="sPosition"></param> /// <param name="sProfession"></param> /// <param name="sYearsInField"></param> /// <param name="sStartYear"></param> /// <param name="sStartMonth"></param> /// <param name="sEndYear"></param> /// <param name="sEndMonth"></param> private void UpdateProspectEmployment(int iEmploymentID, string sCompanyName, bool bSelfEmployed, string sPosition, string sProfession, string sYearsInField, string sStartYear, string sStartMonth, string sEndYear, string sEndMonth) { #region update ProspectEmployment ProspectEmployment ProspectEmploymentMgr = new ProspectEmployment(); LPWeb.Model.ProspectEmployment ProspectEmploymentModel = ProspectEmploymentMgr.GetModel(iEmploymentID); ProspectEmploymentModel.CompanyName = sCompanyName; ProspectEmploymentModel.SelfEmployed = bSelfEmployed; ProspectEmploymentModel.Position = sPosition; ProspectEmploymentModel.BusinessType = sProfession; if (sYearsInField == string.Empty) { ProspectEmploymentModel.YearsOnWork = null; } else { ProspectEmploymentModel.YearsOnWork = Convert.ToDecimal(sYearsInField); } if (sStartYear == string.Empty) { ProspectEmploymentModel.StartYear = null; } else { ProspectEmploymentModel.StartYear = Convert.ToDecimal(sStartYear); } if (sStartMonth == string.Empty) { ProspectEmploymentModel.StartMonth = null; } else { ProspectEmploymentModel.StartMonth = Convert.ToDecimal(sStartMonth); } if (sEndYear == string.Empty) { ProspectEmploymentModel.EndYear = null; } else { ProspectEmploymentModel.EndYear = Convert.ToDecimal(sEndYear); } if (sEndMonth == string.Empty) { ProspectEmploymentModel.EndMonth = null; } else { ProspectEmploymentModel.EndMonth = Convert.ToDecimal(sEndMonth); } ProspectEmploymentMgr.Update(ProspectEmploymentModel); #endregion }