02
2016
09

C#、Asp.Net 对比两个实体信息前后是否有所改变(结构相同和不相同)

在一些项目中可能需要比较内容是否有所改变,可以使用对比的方法来判断是否内容有所改变(对比某个特定的字段,可以不是所有的都比较),下面是比较笨的方法:

public static string compareStr = "HouseName,HouseType,HouseNum,Status"; //需要对比的字段名
/// <summary>
/// 对比两个实体信息前后是否一致,需要通过compareStr来判断对比那些字段(实体结构不相同)
/// </summary>
/// <param name="oldair">老的乘客信息</param>
/// <param name="newair">新改的乘客信息</param>
/// <returns></returns>
public static int compareAirPassenger<T1, T2>(T1 oldair, T2 newair)

02
2016
09

C#、Asp.Net 将一个实体对象转换为另一个实体对象(结构可以不一样)

直接上调用方法,实体结构不一样的时候只会转换字段名相同的,代码如下:

/// <summary>
/// 将一个实体对象转换为另一个实体对象
/// </summary>
/// <typeparam name="T1">第一个实体对象</typeparam>
/// <typeparam name="T2">第二个实体对象</typeparam>
/// <param name="source">转换的实体对象</param>
/// <returns></returns>
public static T2 CopyToModel<T1, T2>(T1 source)

23
2015
12

【C#、Asp.Net 工具类大全】图片通用操作类

对图片进行操作,常用的就是上传及对图片进行裁剪,生成缩略图等

    /// <summary>

    /// jqueryUpImg 图片上传及裁剪

    /// </summary>

    public class jqueryUpImg : IHttpHandler

    {

        private string urlPath = "";

23
2015
12

【C#、Asp.Net 工具类大全】Request请求工具类

string name = RequestHelper.GetQueryString("name"); //获取请求中的参数name

string param = RequestHelper.GetString("param");

int check_revert = RequestHelper.GetFormInt("check_revert"); //获取请求中的参数check_revert,并转化为整数

string accept_name = RequestHelper.GetFormString("accept_name");

decimal express_fee = RequestHelper.GetFormDecimal("express_fee", 0);

string userip = RequestHelper.GetIP(); //获取IP地址

int click = RequestHelper.GetInt("click", 0); //读取参数click,如果没有返回0

23
2015
12

【C#、Asp.Net 工具类大全】弹出提示操作类

MessageBox工具类是在.Net中使用的后台弹出层,类似C#里面Winform

MessageBox.Show(this, "弹出内容!");

MessageBox.ShowAndRedirect(this, "操作成功,将跳转到:https://www.zhengdecai.com/!", "https://www.zhengdecai.com/");

MessageBox.ResponseScript(this, "alert('弹出内容')");

26
2015
07

【C#、Asp.Net 工具类大全】正则匹配工具类

public class MatchHelper

{

    /// <summary>

    /// 正则匹配结果集中的第一个匹配项

    /// </summary>

    /// <param name="regularString">进行匹配的字符串集</param>

15
2015
07

【C#、Asp.Net 工具类大全】Js常用操作类

/// <summary>

/// Js操作类

/// </summary>

public class JsHelper

{

    #region 页面JS操作

    /// <summary>

    /// 弹出信息,并跳转指定页面。

11
2015
07

【C#、Asp.Net 工具类大全】Html常用帮助类

/// <summary>

/// Html常用帮助类

/// </summary>

public class HtmlHelper

{

    #region 获取页面源代码

    /// <summary>

    /// 获取网页源代码

11
2015
07

C#字符串编码帮助类

/// <summary>

/// 字符串编码帮助类

/// </summary>

public class EncodingHelper

{

    /// <summary>

    /// 字符串编码转换

    /// </summary>

    /// <param name="srcEncoding">原编码</param>

    /// <param name="dstEncoding">目标编码</param>

    /// <param name="srcStr">原字符串</param>

    /// <returns>字符串</returns>

11
2015
07

【C#、Asp.Net 工具类大全】压缩文本、字节或者文件的压缩辅助类

前端页面代码:

<div>
    <asp:Button ID="sBtn6" runat="server" OnClick="sBtn6_Click" Text="ZIP压缩" />&nbsp;
    <asp:Button ID="sBtn7" runat="server" OnClick="sBtn7_Click" Text="ZIP解压缩" /></div>

使用C#实例:

06
2015
07

【C#、Asp.Net-工具类大全】FTP文件操作工具类

前端页面代码:

<input id="fileUpload" type="file" runat="server" visible="false" />
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="sBtn1" runat="server" OnClick="sBtn1_Click" Text="FTP上传" />
<asp:Button ID="sBtn2" runat="server" OnClick="sBtn2_Click" Text="FTP下载" />
<asp:Button ID="sBtn3" runat="server" OnClick="sBtn3_Click" Text="FTP删除" />
<asp:Button ID="sBtn4" runat="server" OnClick="sBtn4_Click" Text="FTP文件读取" />
<asp:Button ID="sBtn5" runat="server" OnClick="sBtn5_Click" Text="FTP操作" />

使用C#实例:

05
2015
07

【C#、Asp.Net-工具类大全】文件上传操作工具类

前端页面代码:

<input id="fileUpload" type="file" runat="server" visible="false" />
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="sBtn" runat="server" OnClick="sBtn_Click" Text="上传" Visible="false" />

使用C#实例:

03
2015
07

【C#、Asp.Net-工具类大全】文件常用操作工具类

使用实例:

private string urlPath = "";

protected void Page_Load(object sender, EventArgs e)

{

    if (!Page.IsPostBack)

    { 

        urlPath = Server.MapPath("~/file/");

        fileInfo();

    }

}

/// <summary>

/// 文件操作

/// </summary>

28
2015
06

【C#、Asp.Net 工具类大全】加密解密工具类

使用实例:

private string urlPath = "";

protected void Page_Load(object sender, EventArgs e)

{

    if (!Page.IsPostBack)

    { 

        urlPath = Server.MapPath("~/file/");

        encryptInfo();

    }

}

/// <summary>

/// 字符串加密解密

/// </summary>

14
2015
06

【C#、Asp.Net 工具类大全】GridView 绑定数据及操作大全工具类

前端页面代码:

<style type="text/css">
    #DataList1 { border:solid 1px #ff0000; width:600px;}
    #GridView1 { border:solid 1px #00ff00; margin-top:10px; width:600px;}
    .Repeater { border:solid 1px #0000ff; margin-top:5px; width:600px;}
</style>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None"
    UseAccessibleHeader="False" OnRowDataBound="GridView1_RowDataBound">
    <Columns>
        <asp:TemplateField HeaderText="站点">
            <ItemTemplate>
                <asp:Label ID="UserSite" runat="server" Text='<%#Bind("UserSite") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center"/>
        </asp:TemplateField>
        <asp:BoundField DataField="UserName" HeaderText="姓名" />
        <asp:BoundField DataField="UserAge" HeaderText="年龄" />
        <asp:BoundField DataField="UserSex" HeaderText="性别" />
    </Columns>
</asp:GridView>

使用C#实例:

13
2015
06

【C#、Asp.Net 工具类大全】绑定服务器数据控件大全工具类

前端页面代码:

<style type="text/css">
    #DataList1 { border:solid 1px #ff0000; width:600px;}
    #GridView1 { border:solid 1px #00ff00; margin-top:10px; width:600px;}
    .Repeater { border:solid 1px #0000ff; margin-top:5px; width:600px;}
</style>
<asp:DataList ID="DataList1" runat="server">
    <ItemTemplate>
        <table border="0">
            <tr>
                <td>
                    <%#Eval("UserSite")%>&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("UserName")%>
                </td>
                <td>
                    <%#Eval("UserAge")%>&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("UserSex")%>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:DataList>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None"
    UseAccessibleHeader="False" OnRowDataBound="GridView1_RowDataBound">
    <Columns>
        <asp:TemplateField HeaderText="站点">
            <ItemTemplate>
                <asp:Label ID="UserSite" runat="server" Text='<%#Bind("UserSite") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center"/>
        </asp:TemplateField>
        <asp:BoundField DataField="UserName" HeaderText="姓名" />
        <asp:BoundField DataField="UserAge" HeaderText="年龄" />
        <asp:BoundField DataField="UserSex" HeaderText="性别" />
    </Columns>
</asp:GridView>
<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <table border="0" class="Repeater">
            <tr>
                <td>
                    <%#Eval("UserSite")%>&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("UserName")%>
                </td>
                <td>
                    <%#Eval("UserAge")%>&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("UserSex")%>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:Repeater>

使用C#实例:

09
2015
06

【C#、Asp.Net 工具类大全】VerCode验证码生成工具类

使用实例:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    { 
        verCodeInfo();
    }
}
/// <summary>
/// 验证码生成
/// </summary>
private void verCodeInfo()
{
    /*方法1*/
    VerCodeHelper v = new VerCodeHelper();
    Response.Write("<IMG alt=\"" + "" + "\" src=\"data:image/png;base64," + FileHelper.ImgToBase64String(v.Image) + "\" border=\"0\">"); //固定生成长度的验证码
    /*方法1*/
    
    /*方法2*/
    string chkCode = VerCodeHelper.MakeCode(5); //根据长度自动生成
    MemoryStream ms = VerCodeHelper.CreateCodeImg(chkCode);
    Response.ClearContent();
    Response.ContentType = "image/gif";
    Response.BinaryWrite(ms.ToArray());
    /*方法2*/
}

类库信息:

07
2015
06

【C#、Asp.Net 工具类大全】QrCode二维码生成工具类

使用实例:

private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        urlPath = Server.MapPath("~/file/");
        qrCodeInfo();
    }
}
/// <summary>
/// 二维码生成
/// </summary>
private void qrCodeInfo()
{
    Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + QrCodeHelper.getQrCodePath("https://www.zhengdecai.com/", "8", urlPath, "zhengdecai_qr.png") + "\" border=\"0\">" + "&nbsp;");
    Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + QrCodeHelper.getQrCodePath("https://www.zhengdecai.com/", "8", urlPath + "zhengdecai_logo.png", urlPath, "zhengdecai_qr_logo.png") + "\" border=\"0\">" + "<br />");
}

类库信息:

06
2015
06

【C#、Asp.Net 工具类大全】BarCode条形码生成工具类

使用实例:

private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        urlPath = Server.MapPath("~/file/");
        barCodeInfo();
    }
}
/// <summary>
/// 图标生成
/// </summary>
private void barCodeInfo()
{
    Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + BarCodeHelper.getBarCodePath("www.zhengdecai.com", "Code128B", urlPath, "zhengdecai_bar.jpg") + "\" border=\"0\">" + "<br />");
}

类库信息:

04
2015
06

【C#、Asp.Net 工具类大全】OWCChart图表展示实例操作类

使用实例:

private DataTable dt = new DataTable();

private string urlPath = "";

protected void Page_Load(object sender, EventArgs e)

{

    if (!Page.IsPostBack)

    {

        dt = new DataTable();

        dt.Columns.Add("UserName");

        dt.Columns.Add("UserAge");

        dt.Columns.Add("UserSex");

        dt.Columns.Add("UserSite");

        DataRow dr = dt.NewRow();

        dr["UserName"] = "郑德才";

        dr["UserAge"] = "27";

        dr["UserSex"] = "男";

        dr["UserSite"] = "http://www.zhengdecai.com";

        dt.Rows.Add(dr);

        dr = dt.NewRow();

        dr["UserName"] = "旺旺";

        dr["UserAge"] = "29";

        dr["UserSex"] = "女";

        dr["UserSite"] = "http://www.zhengdecai.cn";

        dt.Rows.Add(dr);

        dv = new DataView(dt);

        urlPath = Server.MapPath("~/file/");

        oWCChartInfo();

    }

}

/// <summary>

/// 图标生成

/// </summary>