getFormData: function(formid) {
var data = {};
//获取TEXT文件内容
$("#" + formid + " input[type=text]").each(function(i, o) {
var jo = $(o);
if (jo.attr("datafield")) {
var str = jo.val();
str = str.replace(" ", "");
if (str !== "") {
data[jo.attr("datafield")] = jo.val();
}
}
});
return data;
}
var save = function(sender) {
$(sender).prop("disabled", true); //禁用按钮,防止重复发送
var data = getFormData("form1");
var jsonobj = { jsondata: data };
var textdata = JSON.stringify(jsonobj);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "xxxxx.aspx/Save",
dataType: "json",
data: textdata,
success: function(msg) {
if (msg.d == "1") {
document.form1.reset();
alert("保存成功!");
}
else if (msg.d == "0") {
alert("保存失败!");
}
},
complete: function(jqXHR, textStatus) {
$(sender).prop("disabled", false); //还原按钮
}
});
}
public static T1 UpdateObjectByDic<T1>(T1 scrobj, IDictionary<string, string> sourceobject, bool ignoreCase)
where T1 : new()
{
T1 result = scrobj;
PropertyInfo[] pifresults = typeof(T1).GetProperties();
foreach (var dic in sourceobject)
{
foreach (PropertyInfo pifresult in pifresults)
{
if (string.Compare(dic.Key, pifresult.Name, ignoreCase) == 0)
{
pifresult.SetValue(result, ChangeType(dic.Value, pifresult.PropertyType), null);
break;
}
}
}
return result;
}
public static Object ChangeType(object value, Type targetType)
{
Type convertType = targetType;
if (targetType.IsGenericType && targetType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
NullableConverter nullableConverter = new NullableConverter(targetType);
convertType = nullableConverter.UnderlyingType;
}
return Convert.ChangeType(value, convertType);
}
[WebMethod(EnableSession = true)]
public static string Save(Dictionary<string, string> jsondata)
{
string result = "0";
Model.Project pro = ConvertHandle.UpdateObjectByDic< Model.Project>(jsondata,new Model.Project,true);
pro.CreatorID = BLL.Sys_User.GetCurUser().ID.ToString();
pro.CreatorName = BLL.Sys_User.GetCurUser().Name;
prohandle.Insert(pro);
result = "1";
return result;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有