Model:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace WebApplicationAccount.Models
{
public class Account
{
/// <summary>
/// 客户id
/// </summary>
public Guid id { get; set; }//客户id
/// <summary>
/// 客户名称
/// </summary>
[Required]
public string new_name { get; set; }//客户名称
/// <summary>
/// 销售修改者
/// </summary>
public string modifiedby { get; set; }//销售修改者
/// <summary>
/// 客户类型
/// </summary>
public string new_cust_type { get; set; }//客户类型
/// <summary>
/// 身份证号
/// </summary>
[StringLength(18, MinimumLength = 18)]
[Required]
public string new_id_no { get; set; }//身份证号
/// <summary>
/// 生日
/// </summary>
public string new_birthday { get; set; }//生日
/// <summary>
/// 年龄
/// </summary>
public string new_age { get; set; }//年龄
/// <summary>
/// 手机号码
/// </summary>
[StringLength(11,MinimumLength = 11)]
[Required]
public string new_mobile { get; set; }//手机号码
/// <summary>
/// 教育背景
/// </summary>
public string new_education { get; set; }//教育背景
/// <summary>
/// 职业
/// </summary>
public string new_occupation { get; set; }//职业
/// <summary>
/// 行业
/// </summary>
public string new_industrycode { get; set; }//行业
/// <summary>
/// 手机号码2
/// </summary>
public string new_mobile2 { get; set; }//手机号码2
/// <summary>
/// 微信号
/// </summary>
public string new_wechart { get; set; }//微信号
/// <summary>
/// 邮件
/// </summary>
public string new_email { get; set; }//邮件
/// <summary>
/// 详细地址
/// </summary>
public string new_address { get; set; }//详细地址
/// <summary>
/// 省
/// </summary>
public string new_province1 { get; set; }//省
/// <summary>
/// 市
/// </summary>
public string new_city { get; set; }//市
/// <summary>
/// 年收入(万元)
/// </summary>
public decimal new_annual_income { get; set; }//年收入(万元)
/// <summary>
/// 月可支配收入(元)
/// </summary>
public decimal new_monthly_disposable { get; set; }//月可支配收入(元)
/// <summary>
/// 现金流水情况(元)
/// </summary>
public decimal new_cash_flow { get; set; }// 现金流水情况(元)
/// <summary>
/// 性别
/// </summary>
public string new_gender1 { get; set; }//性别
/// <summary>
/// 婚姻状况
/// </summary>
public string new_marital_status { get; set; }//婚姻状况
/// <summary>
/// 利率偏好
/// </summary>
public string new_interest_rate { get; set; }//利率偏好
/// <summary>
/// 金融产品偏好
/// </summary>
public string new_financial_product_preference { get; set; }//金融产品偏好
/// <summary>
/// 期数偏好
/// </summary>
public string new_installments_preferences { get; set; }//期数偏好
/// <summary>
/// 客户标签
/// </summary>
public string new_cust { get; set; }//客户标签
/// <summary>
/// 个人信用情况
/// </summary>
public string new_credit_status { get; set; }//个人信用情况
}
}
Controller:
public ActionResult CreateAccount(Account account)
{
if (account.new_mobile == null)
{
return Content("手机号码");
}
}
View:
<script>
function CreateAccount() {
$.ajax({
url: "/Home/CreateAccount",
type: "post",
data: {
"new_mobile": $("#new_mobile").val()
},
success: function (data) {
/*alert(111111)//有弹框*/
if (data == "手机号码") {
alert("手机号码不能为空");
}
}
}
});
}
</script>
<div>
<input type="submit" value="添加" onclick="CreateAccount()" />
</div>