⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customer.cs

📁 小型的一个简单的系统开发的实现了简---添加--删除--修改---(vs2005和SQl2005)用到了一些JS脚本
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
/// Customer 的摘要说明
/// 客户信息处理
/// </summary>
public class Ccustomer
{
	public Ccustomer()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    string cust_id;
    string name;
    string password;
    string M_email;

    public string email
    {
        get
        {
            return M_email;
        }
        set
        {
            M_email = value;
        }
    }



    DataAccess.CDataAccess ExECustomer = new DataAccess.CDataAccess();
    public bool Add(string userID, string xm, string pwd, string emaill)
    {
        string sqistr = "insert into Customer (cust_id,name,password,email)values ('" + userID + " ','" + xm + "','" + pwd + "','" + emaill + "')";
        DataAccess.CDataAccess DA = new DataAccess.CDataAccess();
        if (DA.ExecuteQuery(sqistr))
        {
            return true;
        }
        else
        {
            return false;
        }

    }

    public DataTable showtab()
    {

        string sqlstr = "select* from Customer ";

        return ExECustomer.GetDataTable(sqlstr);
    }

    /// <summary>
    /// 显示这张 "Catories"表里的满足条件的数
    /// </summary>
    /// <returns></returns>
    public DataTable SelectTable(string cust_id)
    {
        string sqlstr = "select* from Customer where cust_id='" + cust_id + "'";


        return ExECustomer.GetDataTable(sqlstr);

    }
    public bool update(string userID, string xm, string pwd, string emaill)
    {
        string sqistr = "update dbo.Customer SET name='"+xm+"',password='"+pwd+"',email='"+emaill+"'where cust_id='"+userID+"'";
        if (ExECustomer.ExecuteQuery(sqistr))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    public Boolean delete(string cust_id)
    {
        string sqistr = "delete  [Customer] where [cust_id]='" + cust_id + "'";

        if (ExECustomer.ExecuteQuery(sqistr))
        {
            return true;
        }
        else
        {
            return false;
        }

    }



    public DataTable GetTable(string cust_id, string name)
    {

        string strSql = null;
        DataTable dt = null;
        if (cust_id != "" && name != "")
        {
            strSql = "select* from Customer  where cust_id='" + cust_id + "'and name ='" + name + "'";
            dt = ExECustomer.GetDataTable(strSql);
            switch (dt.Rows.Count)
            {
                case 0:
                    strSql = "select* from Customer";
                    dt = ExECustomer.GetDataTable(strSql);
                    break;
            }

        }
       
        if (cust_id == "")
        {
            strSql = "select* from Customer where name like'%" + name + "%'";
            dt = ExECustomer.GetDataTable(strSql);
        }
        if (name == "")
        {
            strSql = "select* from Customer where cust_id like'%" + cust_id + "%'";
           dt=ExECustomer.GetDataTable(strSql);
        }


        return dt;
    }

    public bool Select(string xm, string pwd)
    {

        string srtSql = "select * from Customer where name='" + xm + "' and password='" + pwd + "'";

        if (ExECustomer.ExecuteQueryA(srtSql) != 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    ///  请告诉我 你 需要验证的 值
    /// 验证文本框里的值是否为空,为空就告诉前面(以 真假的 形式 )
    /// </summary>
    /// <param name="txt"></param>
    /// <returns></returns>
    public bool chenked(string txt)
    {
        if (txt.Length == 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -