set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER    PROCEDURE [dbo].[T_Consultation_Select] 
    
@ConsultationStyleID TINYINT,
    
@AnswerUserID VARCHAR(30),
    
@IncomeCallBeginTime [DATETIME],
    
@IncomeCallEndTime [DATETIME]
    
AS
    
BEGIN
        
DECLARE @whereStr VARCHAR(8000),
        
@count INT
        
SET @count=0
        
SET @whereStr=''
        
IF  @ConsultationStyleID IS NOT NULL
          
BEGIN
               
IF(@count>0)
                
BEGIN
                 
SELECT @whereStr=@whereStr+'    AND T_Consultation.ConsultationStyleID  ='+Convert(Varchar(10),@ConsultationStyleID)
             
END
        
ELSE
             
BEGIN
                 
SELECT @whereStr=@whereStr+'  T_Consultation.ConsultationStyleID ='+Convert(Varchar(10),@ConsultationStyleID)
               
END
          
SET  @count=@count +1
           
END
           
IF  @AnswerUserID IS NOT NULL
          
BEGIN
               
IF(@count>0)
                
BEGIN
                 
SELECT @whereStr=@whereStr+'    AND T_Consultation.AnswerUserID  ='''+Convert(Varchar(10),@AnswerUserID)''
             
END
        
ELSE
             
BEGIN
                 
SELECT @whereStr=@whereStr+'  T_Consultation.AnswerUserID ='''+Convert(Varchar(10),@AnswerUserID)''
               
END
          
SET  @count=@count +1
           
END
            
IF @IncomeCallBeginTime IS NOT NULL
                
BEGIN
                    
IF(@count>0)
                        
BEGIN
                             
SELECT @whereStr=@whereStr+' AND  T_Consultation.CreateTime >=''+ CONVERT(VARCHAR(10),@IncomeCallBeginTime)'''
                        
END
            
ELSE
                    
BEGIN
                       
SELECT @whereStr=@whereStr+'  T_Consultation.CreateTime >='' + CONVERT(VARCHAR(10),@IncomeCallBeginTime)'''
                    
END        
                
END
             
IF @IncomeCallEndTime IS NOT NULL
                
BEGIN
                    
IF(@count>0)
                        
BEGIN                                                                                                            
                             
SELECT @whereStr=@whereStr+' AND  T_Consultation.CreateTime <='' + CONVERT(VARCHAR(10),@IncomeCallEndTime)'''
                        
END
            
ELSE
                    
BEGIN
                       
SELECT @whereStr=@whereStr+'  T_Consultation.CreateTime <='' + CONVERT(VARCHAR(10),@IncomeCallEndTime)'''
                    
END        
                
END
           
IF(@count>0)
            
SELECT @whereStr='SELECT [CreateTime]
  FROM T_Consultation WHERE T_Consultation.FollowUpMark=
'+'1'+'  And ' + @whereStr
   
ELSE
   
SELECT @whereStr='SELECT ConsultationID,(SELECT ParaName FROM T_SysPara WHERE GroupID=14 AND ParaID=T_Consultation.ConsultationStyleID)AS ConsultationStyleID,
            [ConsultationContent],[ConsultationResults],(SELECT ParaName FROM T_SysPara WHERE GroupID=16 AND ParaID=T_Consultation.HaveOrderingIntention)AS HaveOrderingIntention,[OrderingIntentionContent],
  [CustomerID],[AnswerUserID],[CreateTime]
  FROM T_Consultation where  T_Consultation.FollowUpMark=
'+'1' 
END
select  (@whereStr)
posted @ 2008-07-08 15:08 郑浩宇 阅读(143) | 评论 (0)编辑
     虽然已经有了ASP.NET AJAX了,最近学习ASP.NET控件的时候,逐步理解了原始的控件异步回调(代码取自《ASP.NET 2.0 高级编程》):
     首先,在Render事件中添加好一个事件
     
 protected override void RenderContents(HtmlTextWriter output)
        
{
            output.RenderBeginTag(HtmlTextWriterTag.Div);

            output.AddAttribute(HtmlTextWriterAttribute.Type, 
"text");
            output.AddAttribute(HtmlTextWriterAttribute.Id, 
this.ClientID);
            output.AddAttribute(HtmlTextWriterAttribute.Name, 
this.ClientID);
            output.AddAttribute(HtmlTextWriterAttribute.Value, 
this.Text);

            output.AddAttribute(
"OnBlur""ClientCallback();");
            
this.AddAttributesToRender(output);
            output.RenderBeginTag(HtmlTextWriterTag.Input);
            output.RenderEndTag();
            output.RenderEndTag();
        }

    这里最重要的就是output.AddAttribute("OnBlur","ClientCallback();");
    然后在OnPreRender事件中,添加如下代码:
protected override void OnPreRender(EventArgs e)
        
{
            
//Page.ClientScript.RegisterClientScriptInclude("UtilityFunctions", "JScript.js");
            Page.ClientScript.RegisterStartupScript(typeof(Page), "ControlFocus""document.getElementById('" + this.ClientID + "').focus();"true);
            Page.ClientScript.RegisterStartupScript(
typeof(Page),"ClientCallback","function ClientCallback() {"+"args=document.getElementById('"+this.ClientID+"').value;"+Page.ClientScript.GetCallbackEventReference(this,"args","CallbackHandler",null,"ErrorHandler",true)+"}");
            
//向服务器发送请求,由服务器端生成回调的客户端脚本。
        }

      也就是在服务器端生成客户端代码,注意最后一个方法GetCallbackEventReference,我理解的是在服务器端捕捉了客户端的请求之后,生成相应的客户端脚本,在服务器端回调的时候,客户端决定用什么函数处理回调和错误。
      服务器端实现接口的一个方法,也就是接收到客户端的请求之后,由服务器端先处理,然后再把结果和相应代码发回客户端。
    
 #region ICallbackEventHandler Members
        
public string RaiseCallbackEvent(string eventArgument)
        {
            
int result;
            
if (!Int32.TryParse(eventArgument, out result))
                
throw new Exception("The method is not implemented.");
            
return "Valid Data";
        }
        
#endregion
    最后,在jscript.js文件中写好相应的回调处理函数即可:
var args;
var ctx;


function ValidateText(ctl)
{
   
if(ctl.value=='')
   {
      alert(
"Please enter a value");
      ctl.focus();
   }
}

function CallbackHandler(args,ctx)
{
    alert(
"The data is valid");
}

function ErrorHandler(args,ctx)
{
    alert(
"The data is not a number");
}
posted @ 2007-07-20 00:31 郑浩宇 阅读(190) | 评论 (0)编辑
      以前对于基础知识有些没有很好的掌握,特决定开辟一个日志,专门记录一些基础的问题。一天进步1%,70天就能积累一倍!
     1.ArrayList是类,Array是数据结构,所以ArrayList需要在遍历的时候强制类型转换,Array不用,如果不希望强制类型转换,可以考虑使用范型。
     2.装箱和拆箱
     装箱是:容许将值类型作为引用类型(比如:对象)进行处理的过程,而拆箱是允许将引用作为值类型的进行处理的过程.
比如:
int num=100;
object obj=num;
Console.WriteLine("对象的值={0}",obj);
int变量 num 的值被负给object的变量obj.将值类型转换为引用类型就叫装相.

int num=100;
object obj=num;
int num=(int)obj;
Console.WriteLine("num:{0}",num);
将num的值副给obj对象时,不需要进行显示装相,系统将自动装箱.

posted @ 2007-07-19 10:08 郑浩宇 阅读(167) | 评论 (1)编辑
    这篇文章是我第一次写关于ASP.NET AJAX的文章,关注这个框架已经很长时间了但是一直没有学得很好,主要是刚开始的时候没有理解ASP.NET AJAX,而是受《AJAX IN ACTION》这本书的影响很大,过于关注客户端代码,但是那本书也没有提出如何和服务器端进行交互,看了赵老师的MSDN WebCast之后进步很快,今天就照着官方的例子实现了。
     官方的代码我不愿意再重复了,也没有很多的意义,如果有朋友想看的话,请您访问:http://ajax.asp.net/docs/tutorials/UpdatePanelWithWebService.aspx
     这篇文章只是说明一点,那就是一些需要注意的问题。
     首先,在Web服务之中,在类的前面要加上[ScriptService]标签。
     否则客户端无法调用该Web服务。
     然后就是调试的时候,把IDE和IE相关联 这样的话,VS.NET就可以找到出错的代码行了。
     UserContext用语服务器端和客户端回调的时候保存数据。
posted @ 2007-06-08 21:24 郑浩宇 阅读(433) | 评论 (0)编辑
    今天看《ASP.NET 2.0高级编程》,学会了ADO.NET 2.0中的数据批量更新,把代码发到这里,以供日后之需。
    DemoBulkUpdate.aspx
   
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DemoBulkUpdate.aspx.cs" Inherits="DemoBulkUpdate" %>

<!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>
    
<form id="form1" runat="server">
    
<div>
        
<asp:Button ID="btnUpdateAddress" runat="server" Text="批量更新地址" OnClick="btnUpdateAddress_Click" />
        
<br /><br />
        
<asp:Label ID="lblCounter" runat="server"></asp:Label>&nbsp;<br />
    
</div>
    
</form>
</body>
</html>
   DemoBulkUpdate.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DemoBulkUpdate : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{

    }

    
protected void btnUpdateAddress_Click(object sender, EventArgs e)
    
{
        SqlDataAdapter EmpAdapter 
= new SqlDataAdapter();
        DataTable EmpDT 
= new DataTable();
        SqlConnection DBConSelect 
= new SqlConnection();
        SqlConnection DBConUpdate 
= new SqlConnection();
        SqlCommand SelectCommand 
= new SqlCommand();
        SqlCommand UpdateCommand 
= new SqlCommand();
        
//采用两个不同的数据源供查询和更新使用
        DBConSelect.ConnectionString = ConfigurationManager.ConnectionStrings["DSN_Northwind"].ConnectionString;
        DBConUpdate.ConnectionString 
= ConfigurationManager.ConnectionStrings["DSN_Northwind"].ConnectionString;
        
//获取所有的雇员表中的记录
        SelectCommand.CommandText = "SELECT TOP 500 * FROM EMPLOYEES";
        SelectCommand.CommandType 
= CommandType.Text;
        SelectCommand.Connection 
= DBConSelect;

        UpdateCommand.CommandText 
= "UPDATE EMPLOYEES SET Address=@Address,City=@City,Region=@Region,Country=@Country";
        UpdateCommand.CommandType 
= CommandType.Text;
        UpdateCommand.Connection 
= DBConUpdate;

        SqlParameter AddressParam 
= new SqlParameter("@Address", SqlDbType.VarChar, 15"Address");
        SqlParameter CityParam 
= new SqlParameter("@City", SqlDbType.VarChar, 15"City");
        SqlParameter RegionParam 
= new SqlParameter("@Region", SqlDbType.VarChar, 15"Region");
        SqlParameter CountryParam 
= new SqlParameter("@Country", SqlDbType.VarChar, 15"Region");

        UpdateCommand.Parameters.Add(AddressParam);
        UpdateCommand.Parameters.Add(CityParam);
        UpdateCommand.Parameters.Add(RegionParam);
        UpdateCommand.Parameters.Add(CountryParam);
        
//设置适配器,查询命令用于检索所有的雇员表中的记录,更新命令用于修改地址信息然后
        
//更新回数据库
        EmpAdapter.SelectCommand = SelectCommand;
        EmpAdapter.UpdateCommand 
= UpdateCommand;

        EmpAdapter.Fill(EmpDT);

        DBConSelect.Close();
        
//遍历所有的雇员表记录然后更新地址信息
        foreach (DataRow DR in EmpDT.Rows)
        
{
            DR[
"Address"= "4445 W 77th Street, Suite 140";
            DR[
"City"= "Edina";
            DR[
"Region"= "Minnesota";
            DR[
"Country"= "USA";
        }


        EmpAdapter.RowUpdated
+=new SqlRowUpdatedEventHandler(OnRowUpdated);
        
this.lblCounter.Text = "";
        EmpAdapter.UpdateBatchSize 
= 100;

        UpdateCommand.UpdatedRowSource 
= UpdateRowSource.None;

        
try
        
{
            DBConUpdate.Open();
            EmpAdapter.Update(EmpDT);
        }

        
catch (Exception ex)
        
{
            
this.lblCounter.Text += ex.Message + "<br />";
        }

        
finally
        
{
            
if (DBConUpdate.State == ConnectionState.Open)
            
{
                DBConUpdate.Close();
            }

        }

    }

    
private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args)
    
{
        
this.lblCounter.Text += "Batch is processed till row number= " + args.RowCount.ToString() + "<br />";

    }

}


    没想到这是2007年第一篇文章,希望给我带来好运气!
posted @ 2007-02-22 00:10 郑浩宇 阅读(750) | 评论 (3)编辑
using System;

namespace DstrQueue
{
    
/// <summary>
    
/// Class1 的摘要说明。
    
/// </summary>

    class QueueNode
    
{
        Object item;
        QueueNode link;
    }

    
class Queue
    
{
        
/// <summary>
        
/// 应用程序的主入口点。
        
/// </summary>

        [STAThread]
        
static void Main(string[] args)
        
{
            
//
            
// TODO: 在此处添加代码以启动应用程序
            
//
        }

        
private QueueNode front;
        
private QueueNode rear;
        
private int count;

        
public boolean empty()
        
{
            
return (count==0);
        }


        
public void insert(Object newItem)
        
{
            QueueNode temp
=new QueueNode();
            temp.item
=newItem;
            temp.link
=null;
            
if(rear==null)
            
{
                front
=rear=temp;
            }

            
else
            
{
                rear.link
=temp;
                rear
=temp;
            }

            count
++;
        }

        
public Object remove()
        
{
            
if(count==0)
                
return null;
            
else
            
{
                Object tempItem
=front.item;
                front
=front.link;
                
if(front==null)
                
{
                    rear
=null;
                }

                count
--;
                
return tempItem;
            }

        }

    }

}

posted @ 2006-12-14 19:08 郑浩宇 阅读(94) | 评论 (1)编辑
     摘要: usingSystem;namespaceDataStructure.LinkedList{/**////<summary>///Class1的摘要说明。///</summary>publicclassListNode{publicstringairport;publicListNodelink;publicListNodeprevious;}publicclassLink... 阅读全文
posted @ 2006-12-14 19:07 郑浩宇 阅读(329) | 评论 (0)编辑
栈:
using System;

namespace DataStructure.Stack
{
    
/// <summary>
    
/// Class1 的摘要说明。
    
/// </summary>

    class StackNode
    
{
        Object item;
        StackNode link;
    }

    
class Stack
    
{
        
/// <summary>
        
///