DS--知识积累

1、

  /// <summary>
  /// 从本地加载xml配置数据
  /// </summary>
  /// <returns></returns>
  private static Dictionary<string, int> LoadRole()
  {
  Dictionary<string, int> dict = new Dictionary<string, int>();//键,值
  string fileName = "~/config/RoleList.xml";
  XmlDocument doc = new XmlDocument();
  doc.Load(HttpContext.Current.Server.MapPath(fileName));
  XmlNode root = doc.DocumentElement;
  foreach (XmlNode node in root.ChildNodes)
  {
  XmlElement element = (XmlElement)node;
  dict.Add(element.GetAttribute("Name"),int.Parse(element.GetAttribute("Id")));
  }
  return dict;
  }

 

2、

  if (!int.TryParse(context.Request["Dep"], out depId) || depId <= 0)
  {
  return new ResultMessage(false, "无效的部门编号!");
  }

  int.TryParse(context.Request["Dep"], out depId) 是异常强转为int,为空则为0

3、

  嵌套类定义

  public class BIGBODY
  {
  public List<BODY> BODY { get; set; }
  }

  public class BODY
  {
  public List<TRANS_SUM> TRANS_SUM { get; set; }
  public List<TRANS_DETAILS> TRANS_DETAILS { get; set; }

  }

  public class TRANS_SUM
  {
  }

  public class TRANS_DETAILS
  {
  public List<TRANS_DETAIL> TRANS_DETAIL { get; set; }
  }

  public class TRANS_DETAIL
  {
  }

4、

  筛选数据集中的列信息

  var rights = client.GetPageRightsByCondition(condition.ToString(), pars, values);
  var result = rights.Select(m => new
  {
  m.EditRight,
  m.GroupId,
  m.PageId,
  m.PageName,
  m.PageUrl,
  m.PageType,
  GroupName = GetGroupName(m.GroupId)
  });

5、

  //回车时登录
  document.onkeydown = function (e) {
  var ev = document.all ? window.event : e;
  if (ev.keyCode == 13) {
  $(".login").click();
  }
  }

6、

   IList<Dict> dicts = client.GetDictByCondition(condition.ToString(), parms.ToArray(), values.ToArray());

Dict.prototype = {
GetDictDDLByType: function ($DictType) {
//根据类型获取简单下拉列表
var result = "";
$.ajax({
type: "post",
url: "../../../Handler/DictHandler.ashx",
dataType: "json",
data: { type: 5, DictType: $DictType },
async: false,
cache: true,
complete: function () {
},
success: function (data) {

var str = '<option value="-1">请选择</option>';
$(data.Data).each(function (i, e) {
str += '<option value="' + e.DictId + '">' + e.DictName + '</option>';
});
result = str;
}
});
return result;
}}

7、

  jquery各种写法

  • if ($("input[name=CoborrowName]").val() != "") {}
  • $("#tbFlow input").attr("readonly", true);//tbFlow为table表格

    <span class="NonSerialized" data-name="StartDate"></span>

  • $("span[data-name='StartDate']").text(ChangeDateFormat(contractInfo.StartDate));
  • $(".contractInfo").css("display", "inline");
  • ChangeProductName.split(',')[0];
  • $("select[name = CoborrowId]").css("display", "inline").html(str);
  • var type = $("select.ddlAccordanceProduct").val();//ddlAccordanceProduct为类
  • $("[name=chkLoan]:checkbox").prop("checked", true);
  • var $LoanChecked = $(this).is(":checked");//是否选中
  • $(".txtInitialLoanDate").val(new Date().Format("yyyy/MM/dd"));

  • $(".userInfo tr").css("cursor", "pointer").click(function () {
    $(".txtUserName").val($(this).find(".name").text());
    $(".txtUserId").val($(this).find(".userId").text());
    });

  • $("#AuthentionTemplate").tmpl(item).appendTo(dom).find(".openLayout").click(function () {}

8、

   jquery最新 模板

loadinfo.CallBack = function (data) {
if (data != null) {
$.each(data, function (index, item) {
$("#CustomRecordTemplate").tmpl(item).appendTo("#tbRecord");
})
}
};

页面

<div class="debit_credit_tab" id="tabCustomRecord" style="display: none">
<table id="tbRecord">
<tr class="dc_tr1">
<td>项目编号</td>
<td>审批节点</td>
<td>借款人</td>
<td>贷款种类</td>
<td>批核额度</td>
<td>还款期限</td>
<td>逾期情况</td>
<td>编辑</td>
</tr>
</table>
</div>

<script id="CustomRecordTemplate" type="text/x-jquery-tmpl">
<tr>
<td>
<input type="text" class="txtOrderId" name="OrderId" readonly="readonly" value="${OrderId}" /></td>
<td>
<input type="text" class="txtVerifyStatusName" name="VerifyStatusName" readonly="readonly" value="${VerifyStatusName}" /></td>
<td>
<input type="text" class="txtUserName" name="UserName" value="${UserName}" /></td>
<td>
<input type="text" class="txtProductTypeName" name="ProductTypeName" readonly="readonly" value="${ProductTypeName}" /></td>
<td>
<input type="text" class="txtAmount" name="Amount" readonly="readonly" value="${Amount}" /></td>
<td>
<input type="text" class="txtTerm" name="Term" readonly="readonly" value="${Term}" /></td>
<td>
<input type="text" class="txtOverdue" name="Overdue" readonly="readonly" value="${Overdue}" /></td>
<td>
<a href="LoanCreditPreview.aspx?orderId=${OrderId}&css=1030" target="_blank">查看</a></td>
</tr>

</script>

9、

/**
* 通过身份证判断是男是女
* @param idCard 15/18位身份证号码
* @return 'female'-女、'male'-男
*/
function maleOrFemalByIdCard(idCard) {
if (idCard.length == 15) {
if (idCard.substr(14, 1) % 2 == 0) {
return false;
} else {
return true;
}
} else if (idCard.length == 18) {
if (idCard.substr(16, 1) % 2 == 0) {
return false;
} else {
return true;
}
} else {
return null;
}
}     

10、

/*
*通过身份证判断出生日期 1 3 0 5 2 1 9 2 1 2 1 8 8 2 6
*/
function birthDateByIdCard(idCard) {
if (idCard.length == 15) {
return '19' + idCard.substring(6, 8) + '/' + idCard.substring(8, 10) + '/' + idCard.substring(10, 12);
} else if (idCard.length == 18) {
return idCard.substring(6, 10) + '/' + idCard.substring(10, 12) + '/' + idCard.substring(12, 14);
}
}

11、 

/* 通过身份证 判断所在省份*/
var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
var arrCityId = { 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 21: 6, 22: 7, 23: 8, 31: 9, 32: 10, 33: 11, 34: 12, 35: 13, 36: 14, 37: 15, 41: 16, 42: 17, 43: 18, 44: 19, 46: 20, 45: 21, 62: 22, 61: 23, 65: 24, 63: 25, 64: 26, 50: 27, 51: 28, 52: 29, 53: 30, 54: 31, 71: 32, 82: 33, 81: 34 };
function provinceByIdCard(idCard) {

var provNo = idCard.substring(0, 2);
var provId = arrCityId[provNo];
return provId;

}

 

    

posted on 2015-05-18 09:30  创世无神_攻城狮  阅读(170)  评论(0编辑  收藏  举报

导航