DOGNET

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  10 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

公告

昵称:DOGNET
园龄:5年2个月
粉丝:0
关注:1

搜索

 
 

常用链接

我的标签

最新评论

阅读排行榜

评论排行榜

推荐排行榜

2010年9月10日 #

异常图: /Files/abc8103/WCF.pdf

 

转贴网上的解决方案1:http://blogs.leoworks.net/feng/2009/09/13/There-can-be-at-most-one-address-per-scheme-in-this-collection/

 

错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。(This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.)

原因:此 WCF 宿主是 IIS ,并且此站点配置了多个主机头,如果 www.example.comwww.example-alias.com 。但 WCF 不支持对 IIS (Http Binding) 中的 WCF 多个主机头绑定。

解决:

方法1. 用绑定不同主机头的多个网站来部署这个 WCF。

方法2. 自定义 ServiceHostFactory

详细讨 论:

There can be at most one address per scheme in this collection.

How can WCF support multiple IIS Binding specified per site ?

WCF: Hosting multiple WCF services as one single service

 

 转贴网上的解决方案2:http://blog.befruit.com/2008/09/wcf-error-this-collection-already.html

 

WCF error: "This collection already contains an address with scheme http"

I met this error, and wondered what this could be. The explanation is that "WCF services hosted in IIS can have only one Base Address", meaning that in IIS the website hosting the service can not be associated to http://www.example.com and http://example.com at the same time.

I don't know why this prevents a service to work, but I know this is annoying.
I found a couple of bloggers like Rob suggesting a solution with a coded custom ServiceHostFactory, which sounds terribly complicated to me as a workaround.

Fortunately there is a much simpler solution, just by touching the web.config file. Just add the following lines in the system.serviceModel section:
<serviceHostingEnvironment>

    <baseAddressPrefixFilters>

        <add prefix="http://www.example.com"/>

    </baseAddressPrefixFilters>

</serviceHostingEnvironment>

to only keep the service address.

 

 

经过实践,先在web.config里机加了这个设置后,出现新错误,然后再去掉这个设置,看下又不报错了,真是有意思,错误是莫名的出现又是莫名的消失,有哪位仁兄给解释下原因?

 

posted @ 2010-09-10 17:41 DOGNET 阅读(371) 评论(0) 编辑

2010年6月10日 #


前置条件:

 主表a与子表b的定义如下,关系是一对多的关系

要求:

为统计报账中心各个审批单据所耗时间,需要提供3.1-5.31日所有通过已付款状态的单据的各个审批人的耗时,格式要求如下:

 

单据号

申请部门

申请人

申请时间(年月日时分)

审批人1

审批人1审批时间

审批人2

审批人2审批时间

….

….

审批人n

审批人n审批时间

 

 

 

 

 

 

 

 

 

 

 

 

 

 sql:

declare @sql varchar(max)
select @sql=isnull(@sql+',','')+'max(case when 审批顺序='''+ltrim(审批顺序)+''' then 审批人姓名 else '''' end) as [审批人'+ltrim(审批顺序)+']'
+',max(case when 审批顺序='''+ltrim(审批顺序)+''' then Datediff(minute,审批生效时间,审批时间) else null end) as [审批时间'+ltrim(审批顺序)+']'
from (
SELECT distinct
a.ApprOrder 审批顺序
FROM Approval a
INNER JOIN ReMain rm ON a.RequestID=rm.ID
) t order by 审批顺序
set @sql='select 单据号,
部门id,部门名称,申请人id,申请人名称,
申请时间,'+@sql+' from ('+'
SELECT
rm.RAApplyNo 单据号,rm.DepID 部门id,rm.DepName 部门名称,rm.ApplyManID 申请人id,rm.ApplyManName 申请人名称,rm.ApplyDate 申请时间,
a.ApprManDutyName 审批人职位,a.ApprManID 审批人id,a.ApprManName 审批人姓名,a.CreateDate 审批生效时间,a.ApprDate 审批时间,a.ApprOrder 审批顺序
FROM Approval a INNER JOIN ReMain rm ON a.RequestID=rm.ID
WHERE
rm.ApplyDate >= ''2010-03-01''
AND rm.ApplyDate <''2010-06-1''
AND rm.[Status] IN (3,6)
) t group by
单据号,部门id,部门名称,申请人id,申请人名称,申请时间'
exec(@sql)

 

 

 

 

posted @ 2010-06-10 12:36 DOGNET 阅读(225) 评论(0) 编辑

2010年5月27日 #

 error_loginfo:

=== 预绑定状态信息 ===

日志: 用户 = bjyjl-PC\Administrator
日志: DisplayName = Jd.Data
 (Partial)
日志: Appbase = file:///E:/SVN/FMS/ExpenseManager/ExpenseManager/ExpenseManager/
日志: 初始 PrivatePath = E:\SVN\FMS\ExpenseManager\ExpenseManager\ExpenseManager\bin
调用程序集: (Unknown)。
===
日志: 此绑定从 default 加载上下文开始。
日志: 正在使用应用程序配置文件: E:\SVN\FMS\ExpenseManager\ExpenseManager\ExpenseManager\web.config
日志: 使用 C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config 的计算机配置文件。
日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。
日志: 试图下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/
Temporary ASP.NET Files/root/05961a4a/51f29f2/Jd.Data.DLL。
日志: 试图下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/05961a4a/51f29f2/Jd.Data/Jd.Data.DLL。
日志: 试图下载新的 URL file:///E:/SVN/FMS/ExpenseManager/ExpenseManager/ExpenseManager/bin/Jd.Data.DLL。
日志: 正在使用应用程序配置文件: E:\SVN\FMS\ExpenseManager\ExpenseManager\ExpenseManager\web.config
日志: 使用 C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config 的计算机配置文件。
日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。

错误: 未能完成程序集的安装(hr = 0x80070057)。探测终止。

 

solution:

清空目录C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root 下的文件 ,重新编译项目

 

 

 

 

posted @ 2010-05-27 09:30 DOGNET 阅读(383) 评论(1) 编辑

2010年5月19日 #

.net 3.5+VS 2008

 

主界面页面:NoteQuery.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoteQuery.aspx.cs" Inherits="NoteQuery" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" >
    <title>单据查找</title>
    <link href="../Style/CSS/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="../Style/JScript/jquery-1.3.2-vsdoc2.js"></script>
    <%--<script type="text/javascript" language="javascript" src="../Style/JScript/jquery-1.3.2.min.js"></script>--%>
    <script src="../Common/Controls/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../Style/JScript/bgcolor.js" type="text/javascript"></script>
    <script src="../Style/JScript/ShouFuKuan.js" type="text/javascript"></script>
    
    <script type="text/javascript" language="javascript" src="../Style/JScript/jquery.pagination.1.1.js"></script>
    <script src="../Style/JScript/coverLayer.js" type="text/javascript"></script>
    <script src="../Style/JScript/common.js" type="text/javascript"></script>
    <script src="../Style/JScript/ProcessBar.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">

        function jiedaiTextChanged() {
            var v_jiedai = $("#txtJeiDai").val();
            if (v_jiedai == "01" || v_jiedai == "sr")
            {
                $("#txtJeiDai").attr("value", '收入');
            }
            else if (v_jiedai == "02" || v_jiedai == "zc")
            {
                $("#txtJeiDai").attr("value", '支出');
            }
            
        }


        function search() {
            $("#pageIndex").attr("value", 1);
            $.fn.pagination.options.current_page = 0;
            list(0);
            $("#pager").css("display", "block");
        }


        function list(i) {
            var v_startdate = $("#txtStartDate").val();
            var v_enddate = $("#txtEndDate").val();
           

//            var v_warning = "";
//            if (v_startdate == "") {
//                v_warning = v_warning + '开始日期必须输入! \n ';
//            }
//            if (v_enddate == "") {
//                v_warning = v_warning + '结束日期必须输入! \n ';
//            }
//            if (v_warning != "") {
//                //alert(v_warning);
//                showWarnInfoInDivTip($("#divTip").attr("id"), v_warning, 3000);
//                return false;
//            }

            //在本次查询结束前冻结查询按钮
            $("#btnQuery").attr("disabled", true);
            showWarnTipNoneTimeOut("查询中...");//操作提示:与进度度功能类似
            $("#div_Refund").load(
            "NoteQueryHandler.aspx?action=get_note_list&stamp=" + new Date().getTime(),
            {
                startdate: v_startdate,
                enddate: v_enddate,
                ......
                pageIndex: $.fn.pagination.options.current_page + 1
            },
            function() {
                //在本次查询结束后解冻查询按钮
                setWarnTipDisappear();
                $("#btnQuery").attr("disabled", false);
                jquery_pager();
                
                //当结果集大于页大小时再显示分页dataTotalAmount              
                var v_RecordCount = $("#pageCount").val();
                v_RecordCount = (v_RecordCount == undefined) ? (0) : (v_RecordCount);
                var v_RecordTotalAmount = $("#dataTotalAmount").val();
                v_RecordTotalAmount = (v_RecordTotalAmount == undefined) ? (0) : (v_RecordTotalAmount);
                $("#pagerInfo").html(" 每页数:"+ $.fn.pagination.options.items_per_page
                    + "&nbsp;&nbsp;总页数:" + Math.ceil(v_RecordCount / $.fn.pagination.options.items_per_page)
                    + "&nbsp;&nbsp;当前页:" + (Number($.fn.pagination.options.current_page) + 1));
                $("#lblHeJiInfo").html("&nbsp;&nbsp;记录总数:" + v_RecordCount
                    + "&nbsp;&nbsp;金额合计:" + v_RecordTotalAmount);
       
            }
            );
        }
        //jquery分页插件
        $(document).ready(function() {
            $.fn.pagination.options =
            {
                items_per_page: 20,
                num_display_entries: 4,
                current_page: 0,
                num_edge_entries: 2,
                link_to: "javascript:void(0)",
                first_text: "第一页",
                prev_text: "上一页",
                next_text: "下一页",
                last_text: "最后一页",
                ellipse_text: "...",
                prev_show_always: true,
                next_show_always: true,
                alway_show: true,
                callback: pageSelected
            }
        });

        /**
        * 翻页
        */
        function pageSelected(page, jq) {
            $.fn.pagination.options.current_page = page;//page从0开始
            list(1);
        }
        function jquery_pager() {
            $("#pager").pagination($("#pageCount").attr("value"), $.fn.pagination.options);        
        
        }

        function ClickDtl() {
            window.open("NoteTypeList.aspx", '_blank', 'width=600,height=400,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no,left=250,top=200');
        }
        //便于服务端得到录入人
        function getddlLuruSelectedText() {
            $("#hidLuru").attr("value", $("#ddlLuru>option:selected").get(0).text);
        }

    </script>
    
</head>
<body>
<form id="form1" runat="server">
<div class="main" style="width:800px">
    <div class="brclum">
        <a href="javascript:void(0);">财务录入</a> &gt;&gt; <a href="#">单据查找</a>
    </div>
    <div id="divTip" class="button_div">
    </div>
    <div class="brclum">
    <table class="table_two" width="100%" border="0" cellpadding="3" cellspacing="0">
      <tr>
        <td height="30px" colspan="8" align="center">
        </td>
      </tr>
      <tr>
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
            <label>号从:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="txtCDanHaoStart" type="text" style="width: 100px" runat="server"/>
        </td>
        <th align="right" valign="middle" style="height: 30px; width: 60px;">
            <label>到:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="txtCDanHaoEnd" type="text" style="width: 100px" runat="server" />
        </td>
        <th align="right" valign="middle" style="height: 30px; width: 60px;">
            <label>日期从:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="txtStartDate" type="text" onfocus="WdatePicker()"  style="width: 100px" runat="server"/>
        </td>
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
            <label>到:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="txtEndDate" type="text" onfocus="WdatePicker()"  style="width: 100px" runat="server" />
        </td>
      </tr>
      <tr>
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
            <label>部门:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="txtDeptText" type="text" style="width: 100px" runat="server" onblur="objNoteQuery.getDepartment(this);"/>
            <input id="txtDeptTextcode" name="txtDeptTextcode" type="hidden" runat="server" />
        </td>
        </tr>
      <tr>
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
            <label>录入人:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <select id="ddlLuru" onchange="getddlLuruSelectedText()">
                <script src="../Common/NoteRecordMan.aspx" type="text/javascript"></script>
            </select>
            <input type="hidden" id="hidLuru" runat="server" value="请选择"/>   
        </td>
       
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
            <label>对帐方式:</label>
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <select id="ddlCFWay" onchange="getddlCFWaySelectedText()">
                <option value="-1">全部</option>
                <option value="1">手工对帐</option>
                <option value="2">系统自动确认汇款</option>
                <option value="3">分期付款</option>
            </select>
            <input type="hidden" id="hidCFWay" runat="server" value="-1"/>   
        </td>
      </tr>
      <tr>
        <th align="right" valign="middle" style="height: 30px; width: 80px;">
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="chkNotHuoKuan" type="checkbox" runat="server"/><label for="chkNotHuoKuan">不包含货款</label>
        </td>
        <th align="right" valign="middle" style="height: 30px; width: 40px;">
            
        </th>
        <td align="left" valign="middle" style="width: 100px; height: 30px;">
            <input id="chkNotXiaoShou" type="checkbox" runat="server"/><label for="chkNotXiaoShou">不包含销售</label>
        </td>
      </tr>      
      <tr>
        <td align="center" colspan="8">
            <input type="button" id="btnQuery" value="确认" class="button_2" onclick="search();"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input id="pageIndex" value="1" type="hidden" />
        </td>
      </tr>  
      <tr>
        <td colspan="10" align="right" style="height: 10px"></td>
      </tr>
    </table>
    </div>
    <div id="div_Refund" class="table_two">
    </div>
<%--    <div>
        <div class="pages" id="pager" style="text-align:left;overflow:auto;float:left">
        </div>
        <div id="divTotalCount" style="float:left;height: 25px; padding: 10px 0 5px 0px;">
        </div>
    </div>--%>
    <div id="pager" class="Pagination">
    </div>
    <div class="Pagination">
        <div id="lblHeJiInfo" class="Pagination align_center red" style="float:right;">
        </div>        
        <div class="Pagination" align="center" id="pagerInfo" style="float:right;">
        </div>
    </div>     
  </div>
<script src="../Style/JScript/NoteQueryAjax.js" type="text/javascript"></script>
</form>
</body>
</html>

 

公共的下接列表项缓存页面:NoteRecordMan.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoteRecordMan.aspx.cs" Inherits="Common.NoteRecordMan" %>

<%@ OutputCache Duration = "3600" VaryByParam = "none" Location="Client" %>

 

NoteRecordMan.aspx 

    public partial class NoteRecordMan : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindDdl();
        }
        private void BindDdl()
        {
            IList<JibenxinxiModel> list = NewHrmService.Instance.NewHrmService.SelectFinanceDeptEmployee();

            StringBuilder sb = new StringBuilder();
            sb.Append("<option value='-1'>请选择</option>");

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    sb.AppendFormat("<option value='{0}'>{1}</option>", list[i].jbxx_id.ToString(), list[i].jbxx_xm);
                }
            }

            Response.Write("document.write(\"" + sb.ToString() + "\")");
            Response.End();
        }

    }

 

 

操作提示:ProcessBar.js

function showWarnTipNoneTimeOut(oWarnMsg) {
    $("#divTip").empty();
    $("#divTip").show("slow", function() {
        $("#divTip").append("<span style='color:red;font-weight:bold;'>" + oWarnMsg + "</span>");
    });
}

function setWarnTipDisappear() {
    setTimeout(function() { $("#divTip").empty(); }, 1000);
}

 

 得用Json和WS从server得到数据:NoteQueryAjax.js

 var objNoteQuery = new Object();
var intDivTipShowTime = 3000;

objNoteQuery.getDepartment = function(oTxt) {
    try {
        var txtValue = oTxt.value.Trim();
        if (txtValue.length > 0) {
            var jqRequestUrl = "../Page/NoteQueryHandler.ashx";
            $.getJSON(jqRequestUrl + "?action=getDepartment&getTime=" + new Date().getTime(), { inputValue: txtValue }, this.jqDepartmentJsonCallBack);
        }
    }
    catch (e) {
        alert(e.message);
    }
}

objNoteQuery.jqDepartmentJsonCallBack = function(oData) {
   
    var result = oData.result;
    var deptId = oData.resultId;
    if (deptId.length == 0) {
        objNoteQuery.showWarnTip("没有您要查找的所在部门!", intDivTipShowTime);
    }
    else {
        $("#Bumeng").val(result);//此处的待赋值控件id可以从方法传参
        $("#IBumen").val(deptId);
    }
}


处理Json请求:NoteQueryHandler.ashx

    public class NoteQueryHandler1 : IHttpHandler
    {

        #region properties

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }

        #endregion

        #region functions

        public void ProcessRequest(HttpContext context)
        {
            ProcessAjaxRequest(context);
        }

        private void ProcessAjaxRequest(HttpContext context)
        {
            string action = context.Request["action"];
            switch (action)
            {
                default:
                    break;

                case "getDepartment":
                    ProcessDepartmentRequest(context);
                    break;
            }
        }

        /// <summary>
        /// 获取部门和部门id
        /// </summary>
        /// <param name="context"></param>
        private void ProcessDepartmentRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dept = null;
            string deptId = null;
            try
            {
                string strDept = context.Request["inputValue"].Trim();
                if (!string.IsNullOrEmpty(context.Request["isValidate"]))
                {
                    ValidateCorrectDeptById(out dept, out deptId, "部门", strDept);
                }
                else
                {
                    SetNameValue(out dept, out deptId, "部门", strDept);
                }
            }
            catch
            {
                dept = string.Empty;
                deptId = string.Empty;
            }
            string jsonObject = "{" + string.Format("\"result\":\"{0}\",\"resultId\":\"{1}\"", dept, deptId) + "}";
            context.Response.Write(jsonObject.Trim(' ', ','));
            context.Response.Flush();
            context.Response.End();
        }

        private void SetNameValue(out string name, out string value, string jiedai, string classfication)
        {
            IJdClassficationService service = FiFactory.GetClassficationService();
            Classfication model = new Classfication();
            model.Jiedai = jiedai;
            model.Classfication = classfication;
            IList<Classfication> listModels = service.GetClassficationByCondition(model);
            if (listModels.Count > 0)
            {
                name = listModels[listModels.Count - 1].ClassType;
                value = listModels[listModels.Count - 1].Id.Value.ToString();//id
            }
            else
            {
                name = string.Empty;
                value = string.Empty;
            }
        }
        #endregion
    }

 

主界面查询请求处理:NoteQueryHandler.aspx(结果列表)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoteQueryHandler.aspx.cs" Inherits="NoteQueryHandler" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <div id="div_YingFuCaiGou" runat="server">
        <table class="table_two" border="1" frame="void" width="100%">
            <tr class="align_center">
                <th width="100">号</th>
                <th width="50">部门</th>
                <th width="100">备注</th>
                <th width="50">详细</th>
            </tr>
            <asp:Repeater ID="Repeater_YingShouAccount" runat="server">
            <ItemTemplate>
                <tr class="align_center" onmouseover="this.style.backgroundColor='#DAE6F5'" onmouseout="this.style.backgroundColor=''">
                    <td><%# Eval("hao")%></td>
                    <td><%# Eval("remark")%></td>           
                    <td><a id="view" onclick="javascript:window.open('NoteDetail.aspx?id='+<%# Eval("cdanhao")%>)" href="javascript:void(0)">查看</a></td>
                    </tr>
            </ItemTemplate>
            </asp:Repeater>
        </table>
        <input id="pageCount" value='<%=this.DataCount%>' type="hidden" />    
        <input id="dataTotalAmount" value='<%=this.DataTotalAmount%>' type="hidden" />    
    </div>
</body>
</html>

 

NoteQueryHandler.aspx.cs

    public partial class NoteQueryHandler : System.Web.UI.Page
    {
        private int pageSize = 20;

        private const string ACTION_GET_NOTE_LIST = "get_note_list";

        protected int CurrentPageIndex
        {
            get
            {
                return Convert.ToInt32(this.Request.Form["pageIndex"]);
            }
        }

        protected int DataCount
        {
            get;
            set;
        }

        protected decimal DataTotalAmount
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxRespond();
        }

        /// <summary>
        /// 取得参数
        /// </summary>
        private void GetYingShouQueryPara(ref string _action, ref jd_caiwuModel query)
        {
            _action = Request.QueryString["action"];

            query = new Model();
  
            if (String.IsNullOrEmpty(Request.Form["startdate"]))
            {
                query.StartDate = null;
                query.DateStart2EndDiff = null;
            }
            else
            {
                query.StartDate = DateTime.Parse(Request.Form["startdate"]);
            }
           
            //分页
            int? pageIndex = null;
            if (string.IsNullOrEmpty(Request.Form["pageIndex"]))
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Int32.Parse(Request.Form["pageIndex"].ToString());
            }
            if (pageIndex != null)
            {
                query.StartRowIndex = this.pageSize * (pageIndex - 1) + 1;
                query.EndRowIndex = this.pageSize * pageIndex;
            }
            query.bIsPager = true;
        }

        /// <summary>
        /// Ajax响应
        /// </summary>
        private void AjaxRespond()
        {
            string strAction = string.Empty;
            jd_caiwuModel query = null;
            GetYingShouQueryPara(ref strAction, ref query);
            switch (strAction)
            {
                case ACTION_GET_NOTE_LIST:
                    GetRefundList(query);
                    break;
            }
        }


        private void GetList(Model query)
        {
            NoteDB _service = new NoteDB();
            IList<jd_caiwuModel> invoices = _service.SelectFinanceNote(query);
            if (invoices.Count > 0)
            {
                div_YingFuCaiGou.Visible = true;
                Repeater_YingShouAccount.DataSource = invoices;
                Repeater_YingShouAccount.DataBind();
                this.DataCount = invoices.Count == 0 ? 0 : invoices[0].RowCount;
                this.DataTotalAmount = invoices.Count == 0 ? 0 : invoices[0].TotalAmount;
            }
            else
            {
                div_YingFuCaiGou.Visible = false;
            }
        }    
    }


 

 

posted @ 2010-05-19 12:33 DOGNET 阅读(382) 评论(0) 编辑

2010年5月18日 #

.net 3.5+VS 2008

 

页面:AutoCompleted.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AutoCompleted.ascx.cs"
    Inherits="ExpenseManager.Common.Controls.AutoCompleted" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:TextBox ID="txtInput" runat="server"></asp:TextBox>
<div id="listPlacement" runat="server" style="height: 150px; overflow: auto; display: none;">
</div>
<input id="txtValue" type="text" runat="server" style="display: none;" />
<div style="display: none;">
<cc1:AutoCompleteExtender ID="txtInput_AutoCompleteExtender" runat="server" DelimiterCharacters=""
    Enabled="True" ServicePath="AjaxHelper.asmx" CompletionSetCount="20" MinimumPrefixLength="2"
    CompletionListElementID="listPlacement" CompletionInterval="200" ServiceMethod="Get"
    TargetControlID="txtInput">
</cc1:AutoCompleteExtender>
</div>

 

代码: AutoCompleted.ascx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace ExpenseManager.Common.Controls
{
    public partial class AutoCompleted : System.Web.UI.UserControl, IPostBackEventHandler
    {
        protected static object SELECTED = new object();

        public event EventHandler<AotoCompletedEventArgs> Selected
        {
            add
            {
                this.Events.AddHandler(SELECTED, value);
            }
            remove
            {
                this.Events.RemoveHandler(SELECTED, value);
            }
        }

        protected void OnSelected(AotoCompletedEventArgs e)
        {
            EventHandler<AotoCompletedEventArgs> temp = this.Events[SELECTED] as EventHandler<AotoCompletedEventArgs>;
            if(temp != null)
                temp(this, e);
        }

        public string ServicePath
        {
            get
            {
                return this.txtInput_AutoCompleteExtender.ServicePath;
            }
            set
            {
                this.txtInput_AutoCompleteExtender.ServicePath = value;
            }
        }

        public string ServiceMethod
        {
            get
            {
                return this.txtInput_AutoCompleteExtender.ServiceMethod;
            }
            set
            {
                this.txtInput_AutoCompleteExtender.ServiceMethod = value;
            }
        }

        public int CompletionInterval
        {
            get
            {
                return this.txtInput_AutoCompleteExtender.CompletionInterval;
            }
            set
            {
                this.txtInput_AutoCompleteExtender.CompletionInterval = value;
            }
        }

        public int CompletionSetCount
        {
            get
            {
                return this.txtInput_AutoCompleteExtender.CompletionSetCount;
            }
            set
            {
                this.txtInput_AutoCompleteExtender.CompletionSetCount = value;
            }
        }

        public virtual void RaisePostBackEvent(string eventArgument)
        {
            AotoCompletedEventArgs e = new AotoCompletedEventArgs();
            e.Data = new KeyValuePair<string, string>(this.txtInput.Text, this.txtValue.Value);
            this.OnSelected(e);
        }

        protected override void OnPreRender(EventArgs e)
        {
            EventHandler<AotoCompletedEventArgs> temp = this.Events[SELECTED] as EventHandler<AotoCompletedEventArgs>;
            string clientFunction = string.Format("{0}OnItemSelected", this.ClientID);
            if(temp != null)
            {
                this.txtInput_AutoCompleteExtender.OnClientItemSelected = clientFunction;
                string script = string.Format(@"function {0}(source, eventArgs)
                        {{
                                document.getElementById('{1}').value=eventArgs.get_value();
                                __doPostBack('{2}','SELECTED');
                        }}", clientFunction, txtValue.ClientID, this.ClientID);

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), clientFunction, script, true);
            }
        }

        /// <summary>
        /// 合作单位名称绑定
        /// </summary>
        public string CropUnitName
        {
            set
            {
                this.txtInput.Text = value;
            }
        }

        /// <summary>
        /// 合作单位能否编辑
        /// </summary>
        public bool CropUnitEnabled
        {
            set
            {
                this.txtInput.Enabled = value;
            }
        }

        /// <summary>
        /// 控件宽度
        /// </summary>
        public Unit Width
        {
            get
            {
                return this.txtInput.Width;
            }
            set
            {
                this.txtInput.Width = value;
            }
        }
    }

    public class AotoCompletedEventArgs : EventArgs
    {
        public KeyValuePair<string, string> Data
        {
            get;
            set;
        }
    }
}

 

为控件实例添加选中项事件:

        protected void Page_Load(object sender, EventArgs e)
        {
            this.CCDEPaymentUnit.Selected += new EventHandler<ExpenseManager.Common.Controls.AotoCompletedEventArgs>                      (CCPaymentUnit_Selected);

        }

 

        void CCPaymentUnit_Selected(object sender, ExpenseManager.Common.Controls.AotoCompletedEventArgs e)
        {

                //得到选中项的值
                string strValue = e.Data.Value;
        }

 

posted @ 2010-05-18 16:29 DOGNET 阅读(124) 评论(0) 编辑

 .net 3.5环境

页面:ExpenseType.ascx

 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExpenseType.ascx.cs" Inherits="EM.ExpenseManager.Common.Controls.ExpenseType" %>
<asp:DropDownList ID="ddlLevel1" runat="server" DataTextField="CodeName" DataValueField="CodeNum" AutoPostBack="True"
    onselectedindexchanged="ddlLevel1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="ddlLevel2" runat="server" DataTextField="CodeName" DataValueField="CodeNum">
</asp:DropDownList>

 

代码:ExpenseType.ascx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//using UIS = EM.ExpenseManager.Common.BaseInfoAS;
using UIS = EM.ExpenseManager.Common.UIService;


namespace EM.ExpenseManager.Common.Controls
{
    public partial class ExpenseType : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindLevel1();
                Reset();
                Reset(this.Level1SelectedIndex, this.Level2SelectedIndex);
            }
        }

        /// <summary>
        /// 绑定第一级
        /// </summary>
        public void BindLevel1()
        {
            Dictionary<string, string> list = UIS.GetExpenseTypeLevel1Cached();
            //Dictionary<string, string> list = UIS.GetExpenseTypeLevel1();

            this.ddlLevel1.Items.Clear();

            this.ddlLevel1.DataTextField = "value";
            this.ddlLevel1.DataValueField = "key";
            this.ddlLevel1.DataSource = list;
            this.ddlLevel1.DataBind();
            this.ddlLevel1.Items.Insert(0, new ListItem("请选择", "-1"));
        }

        /// <summary>
        /// 根据第一级选中项绑定第二级
        /// </summary>
        /// <param name="level1CodeNum"></param>
        private void BindLevel2(string level1CodeNum)
        {
            this.ddlLevel2.Items.Clear();
            this.ddlLevel2.Enabled = false;

            if (level1CodeNum != "-1")
            {
                Dictionary<string, string> list = UIS.GetExpenseTypeLevel2Cached(level1CodeNum);
                //Dictionary<string, string> list = UIS.GetExpenseTypeLevel2(level1CodeNum);

                if (list.Count > 0)
                {
                    this.ddlLevel2.DataTextField = "value";
                    this.ddlLevel2.DataValueField = "key";

                    this.ddlLevel2.DataSource = list;
                    this.ddlLevel2.DataBind();

                    //this.ddlLevel2.Items.Insert(0, new ListItem("请选择", "-1"));
                    this.ddlLevel2.Enabled = true;
                }
                else
                {
                    this.ddlLevel2.Enabled = false;
                }
            }
        }

        /// <summary>
        /// 设置成初始状态
        /// </summary>
        public void Reset()
        {
            this.ddlLevel1.SelectedIndex = 0;
            this.ddlLevel2.Items.Clear();

            this.ddlLevel2.Enabled = false;
            BindLevel2(this.Level1SelectedValue);
        }

        /// <summary>
        /// 设置成初始状态(指定二级索引)
        /// </summary>
        /// <param name="iIndex1"></param>
        /// <param name="iIndex2"></param>
        public void Reset(int iIndex1,int iIndex2)
        {
            this.ddlLevel1.SelectedIndex = iIndex1;
            this.ddlLevel2.Items.Clear();

            this.ddlLevel2.Enabled = false;
            BindLevel2(this.Level1SelectedValue);
            this.ddlLevel2.SelectedIndex = iIndex2;

            //正常情况下ET控件载入时第一级Enabled为true,第二级为false;
            if (this._ETEnabled != true)
            {
                this.ddlLevel1.Enabled = this._ETEnabled;
                this.ddlLevel2.Enabled = this._ETEnabled;
            }
        }
        /// <summary>
        /// 第一级选中项的Value
        /// </summary>
        public string Level1SelectedValue
        {
            get { return this.ddlLevel1.SelectedValue; }
        }

        /// <summary>
        /// 第二级选中项的Value
        /// </summary>
        public string Level2SelectedValue
        {
            get { return this.ddlLevel2.SelectedValue; }
        }
        ///// <summary>
        ///// 第二级选中项的Value(若当前级不可选则返回空串)
        ///// </summary>
        //public string Level2SelectedValue
        //{
        //    get
        //    {
        //        if (this.ddlLevel2.Enabled == false)
        //        {
        //            return string.Empty;
        //        }
        //        else
        //        {
        //            return this.ddlLevel2.SelectedValue;
        //        }
        //    }
        //}

        ///// <summary>
        ///// 第二级选中项的Text
        ///// </summary>
        //public string Level2SelectedText
        //{
        //    get
        //    {
        //        if (this.ddlLevel2.Enabled == true)
        //        {
        //            return this.ddlLevel2.SelectedItem.Text;
        //        }
        //        else
        //        {
        //            return string.Empty;
        //        }
        //    }
        //}
        /// <summary>
        /// 第二级是否可选
        /// </summary>
        public bool Level2Enabled
        {
            get { return this.ddlLevel2.Enabled; }
        }

        /// <summary>
        /// 第-级选中项改变时重新绑定第二级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlLevel1_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindLevel2(Level1SelectedValue);
        }

        /// <summary>
        /// 得到控件选中项的Value
        /// </summary>
        public string SelectedValue
        {
            get
            {
                if (this.Level2Enabled==true)
                {
                    return this.ddlLevel2.SelectedValue;
                }
                else
                {
                    //若第一级也不可用则说明是通过ETEnabled=false故意将当前控件置为不可用
                    //因为默认情况下第一级是可用的
                    if (this.ddlLevel1.Enabled==false)
                    {
                        return this.ddlLevel2.SelectedValue;
                    }
                    else
                    {
                        return "-1";
                    }
                }
            }
        }


        /// <summary>
        /// 得到控件选中项的Text
        /// </summary>
        public string SelectedText
        {
            get
            {
                if (this.Level2Enabled == true)
                {
                    return this.ddlLevel2.SelectedItem.Text;
                }
                else
                {
                    if (this.ddlLevel1.Enabled == false)
                    {
                        return this.ddlLevel2.SelectedItem.Text;
                    }
                    else
                    {
                        return "-1";
                    }
                }
            }

        }

        /// <summary>
        /// 得到控件第一级选中项的Text
        /// </summary>
        public string Level1SelectedText
        {
            get
            {
                return this.ddlLevel1.SelectedItem.Text;
            }
        }
        /// <summary>
        /// 得到控件第二级选中项的Text
        /// </summary>
        public string Level2SelectedText
        {
            get
            {
                return this.ddlLevel2.SelectedItem.Text;
            }
        }

        /// <summary>
        /// 重新绑定第一级选定项
        /// </summary>
        public void RefreshItemBinding()
        {
            BindLevel1();
            Reset();
        }

        /// <summary>
        /// 选定费用类型第一级和第二级中的指定项
        /// </summary>
        /// <param name="strLevel1Value"></param>
        /// <param name="strLevel2Value"></param>
        public void SetSelectedItem(ExpenseType et, string strLevel1Value, string strLevel2Value)
        {
            et.RefreshItemBinding();

            et.Level1SelectedIndex = et.ddlLevel1.Items.IndexOf(et.ddlLevel1.Items.FindByValue(strLevel1Value));
            et.BindLevel2(strLevel1Value);
            et.Level2SelectedIndex = et.ddlLevel2.Items.IndexOf(et.ddlLevel2.Items.FindByValue(strLevel2Value));
        }

        private bool _ETEnabled = true;
        //private bool _ETEnabled;
        /// <summary>
        /// 控件是否可用
        /// </summary>
        public bool ETEnabled
        {
            get { return this._ETEnabled; }
            set { this._ETEnabled = value; }

        }

        private int _Level1SelectedIndex = 0;
        /// <summary>
        /// 得到或设置第一级的选中索引
        /// </summary>
        public int Level1SelectedIndex
        {
            get { return this._Level1SelectedIndex; }
            set { this._Level1SelectedIndex = value; }
        }

        private int _Level2SelectedIndex = 0;
        /// <summary>
        /// 得到或设置第二级的选中索引
        /// </summary>
        public int Level2SelectedIndex
        {
            get { return this._Level2SelectedIndex; }
            set { this._Level2SelectedIndex = value; }
        }

    }

 

 

posted @ 2010-05-18 16:11 DOGNET 阅读(101) 评论(0) 编辑

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;

namespace DogNet.Common
{
    /// <summary>
    /// 枚举类型的服务类
    /// </summary>
    public class EnumTypeService
    {
        /// <summary>
        /// 从枚举类型和它的特性读出并返回一个键值对(枚举值和中文描述)
        /// </summary>
        /// <param name="enumType">Type,该参数的格式为typeof(需要读的枚举类型)</param>
        /// <returns>键值对(枚举值和描述)</returns>
        public static Dictionary<string, string> GetNVCFromEnumValue(Type enumType)
        {
            try
            {
                Dictionary<string, string> nvc = new Dictionary<string, string>();

                Type typeDescription = typeof(DescriptionAttribute);
                FieldInfo[] fields = enumType.GetFields();
                string strText = string.Empty;
                string strValue = string.Empty;
                foreach (FieldInfo field in fields)
                {
                    if (field.FieldType.IsEnum)
                    {
                        strValue = ((int)enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)).ToString();
                        object[] arr = field.GetCustomAttributes(typeDescription, true);
                        if (arr.Length > 0)
                        {
                            DescriptionAttribute aa = (DescriptionAttribute)arr[0];
                            strText = aa.Description;
                        }
                        else
                        {
                            strText = field.Name;
                        }
                        nvc.Add(strValue, strText);
                    }
                }
                return nvc;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 得到值对应的中文状态描述
        /// </summary>
        /// <param name="intKey">状态值</param>
        /// <returns></returns>
        public static string GetDescriptionByKey(Type enumType,int intKey)
        {
            Dictionary<string, string> list = GetNVCFromEnumValue(enumType);

            string strDes = string.Empty;
            list.TryGetValue(intKey.ToString(), out strDes);
            return strDes;
        }
    }

}
posted @ 2010-05-18 12:51 DOGNET 阅读(25) 评论(0) 编辑

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;

namespace DogNet.Common.CacheService
{
    public class DataAccessCached
    {
        private static object markAllEmployee = new object();
        /// <summary>
        /// 得到所有的员工(带缓存)
        /// </summary>
        /// <returns></returns>
        public static IList<object> GetAllEmployees()
        {
            string key = "AllEmployee";
            int cacheTime = Convert.ToInt32(ConfigurationManager.AppSettings["secondOfoutTime"]);
            IList<object> listResult = HttpRuntime.Cache[key] as List<object>;
            if (listResult == null)
            {
                lock (markAllEmployee)
                {
                    if (listResult == null)
                    {
                        //从DB或其它持久访问层得到需要缓存的数据
                        //JDHrmDB hrDB = new JDHrmDB();
                        //listResult = hrDB.GetAllEmployee();
                        HttpRuntime.Cache.Add(key, listResult, null, DateTime.Now.AddSeconds(cacheTime)
                            , Cache.NoSlidingExpiration, CacheItemPriority.High, new CacheItemRemovedCallback(CacheItemRemovedCallback));
                    }
                }
            }
            return listResult;
        }

        static void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
        {
            if (key == "AllEmployee")
            {
                System.Threading.Thread th = new System.Threading.Thread(ReLoadAllEmployees);
                th.Start();
            }
        }

        public static void ReLoadAllEmployees()
        {
            try
            {
                GetAllEmployees();
            }
            catch (Exception ex)
            {
            }
        }
    }
}
posted @ 2010-05-18 11:07 DOGNET 阅读(90) 评论(0) 编辑

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Web;

namespace DogNet.Common.AppConfig
{
    /// <summary>
    /// 提供所有Xml配置文件的内存对象
    /// </summary>
    public static class XmlDataSource
    {
        #region 私有字段
        private static XmlFileConfig _AllComDeptConfig;
        #endregion

        #region 构造函数
        static XmlDataSource()
        {
            //string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase) + "\\Config\\";
            //path = path.Replace("file:\\", "");

            string path = HttpContext.Current.Request.PhysicalApplicationPath + "Config\\";
            _AllComDeptConfig = new XmlFileConfig(path, "AllComDept.xml");
        }
        #endregion


        #region 公有属性
        /// <summary>
        /// 所有公司级部门
        /// </summary>
        public static XDocument AllComDeptConfig
        {
            get
            {
                return _AllComDeptConfig.XmlDocument;
            }
        }

        #endregion
    }
}

posted @ 2010-05-18 10:39 DOGNET 阅读(79) 评论(0) 编辑

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;

namespace DogNet.Common.AppConfig

{

     /// <summary>
    /// Xml配置文件加载,监听
    /// </summary>

    public class XmlFileConfig
    {
        private string _fullPath;
        private object _lockObject;
        private XDocument _xmlDocument;

        #region 构造函数
        public XmlFileConfig(string path, string name)
        {
            this._fullPath = Path.Combine(path, name);
            this._lockObject = new object();

            // 添加监视
            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = path;
            watcher.Filter = name;
            watcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
            watcher.Changed += new FileSystemEventHandler(WatchHandler_OnChanged);
            watcher.EnableRaisingEvents = true;
        }
        #endregion

        public XDocument XmlDocument
        {
            get
            {
                if (_xmlDocument == null)
                {
                    lock (_lockObject)
                    {
                        if (_xmlDocument == null)
                        {
                            this._xmlDocument = LoadConfig();
                        }
                    }
                }
                return _xmlDocument;
            }
        }

        private XDocument LoadConfig()
        {
            try
            {
                return XDocument.Load(this._fullPath);
            }
            catch
            {
                return this._xmlDocument;
            }
        }

        private void WatchHandler_OnChanged(object source, FileSystemEventArgs e)
        {            
            lock (this._lockObject)
            {
                this._xmlDocument = LoadConfig();
            }
        }
    }
}
posted @ 2010-05-18 10:32 DOGNET 阅读(80) 评论(0) 编辑