当前位置:跳过导航链接计算机毕业设计首页 : C#计算机毕业设计 : 详细内容

C#商品进销存销售管理系统(程序下载)(7)

来源:xiaoniu168.com 作者:本站原创 添加时间:2014-12-04 点击数:45334

计算机毕业设计介绍:

7.1.2后台代码
由于系统登陆界面的前台代码相对简单,因此这里不对其前台代码进行过多介绍,仅列出系统登陆界面的后台代码,其代码如下所示:
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.Data.SqlClient;
using System.Web.SessionState;
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.ImageButton3.ImageUrl = "image.aspx";
    }
   
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        //数据库连接字符串
        string cnnstr = ConfigurationManager.ConnectionStrings["ERP之进销存销售报表ConnectionString"].ToString();
        //连接并打开数据库
        SqlConnection cnn = new SqlConnection(cnnstr);
        cnn.Open();//打开数据库
        //从数据库中提取用户名和密码
        string strcmd = "select [姓名] from 系统用户表 where 用户名='" + UserName.Text + "'and 密码='" + PassWord.Text + "'";
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = strcmd;
        cmd.CommandType = CommandType.Text;
        cmd.Connection = cnn;
        //如果存在用户姓名,则登陆成功。
        if (cmd.ExecuteScalar() != null)
        {
            string strName = cmd.ExecuteScalar().ToString();
            Session["TrueName"] = strName;
            Session["UserName"] = this.UserName.Text.ToString().Trim();
            if (CheckBox1.Checked == true)
            {
                HttpCookie cookie = new HttpCookie("Users");
                cookie["Users"]= PassWord.Text.Trim();
                cookie.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(cookie);
            }
            string aa=this.TextBox1.Text.ToString();
            if (aa == Convert.ToString(Session["Image"]))
            {
                Response.Redirect("Index.aspx");
            }
            else
            {
                Response.Write("");
            }
        }
        else
        {
            //错误提示框
            Response.Write("");
        }
        cnn.Close(); //关闭数据库
    }

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/SystemManage/Register.aspx");//转到用户注册页面
    }}

〖资料来源:计算机毕业论文 www.xiaoniu168.com

第8页为计算机毕业论文部分......

【联系方式】

【本站信誉】

用心做计算机毕业设计论文网