Beispiel #1
0
        public bool Update(Model.T_Manager model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();

            SqlConnection myconn = new SqlConnection(setting);

            myconn.Open();

            SqlCommand cmd = new SqlCommand("update T_Manager set PassWord=@password where Id=@id", myconn);

            cmd.Parameters.AddWithValue("@password", model.PassWord);
            cmd.Parameters.AddWithValue("@id", model.Id);

            if (cmd.ExecuteNonQuery() > 0)
            {
                cmd.Dispose();
                myconn.Dispose();

                return(true);
            }
            else
            {
                cmd.Dispose();
                myconn.Dispose();

                return(false);
            }
        }
    //确定修改密码
    protected void UpDate_Click(object sender, EventArgs e)
    {
        //输入数据存入Model
        Model.T_Manager Manager = new Model.T_Manager();

        Manager.Id       = Convert.ToInt32(S_Id.Value);
        Manager.UserName = U_Name.Text.Trim();
        Manager.PassWord = NewPWD2.Text.Trim();
        //Singer.ClassNO = ddlClass.SelectedValue.ToString();

        BLL.T_Manager ManagerBll = new BLL.T_Manager();


        if (ManagerBll.Update(Manager))
        {
            Response.Write("FAILURE");
            Add.Visible    = true;
            UpDate.Visible = false;

            BindDate();
        }
        else
        {
            Response.Write("FAILURE");
        }
    }
Beispiel #3
0
        public bool Add(Model.T_Manager model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();
            //创建数据库对象
            SqlConnection myconn = new SqlConnection(setting);

            //打开连接
            myconn.Open();
            //创建命令对象,并准备好操作数据库的SQL语句
            SqlCommand cmd = new SqlCommand("insert into T_Manager([UserName],[PassWord]) values (@username,@password )", myconn);

            //为SQL语句匹配相关参数,并赋值
            cmd.Parameters.AddWithValue("@username", model.UserName);
            cmd.Parameters.AddWithValue("@password", model.PassWord);

            //执行相关SQL语句并返回受影响的行数,若受影响行数大于0,则表示执行成功,否者,执行失败
            if (cmd.ExecuteNonQuery() > 0)
            {
                cmd.Dispose();
                myconn.Dispose();
                return(true);
            }
            else
            {
                cmd.Dispose();
                myconn.Dispose();
                return(false);
            }
        }
    protected void Add_Click(object sender, EventArgs e)
    {
        Model.T_Manager Manager = new Model.T_Manager();

        Manager.UserName = U_Name.Text.Trim();
        Manager.PassWord = NewPWD2.Text.Trim();

        BLL.T_Manager ManagerBll = new BLL.T_Manager();
        if (ManagerBll.Add(Manager))
        {
            //上传成功,给出提示
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "DONE", true);
            BindDate();
            //Response.Write("<script><alert>上传成功</alert></script>");
            Response.Redirect("Manager.aspx");
        }
    }
    protected void GVManager_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Model.T_Manager model      = new Model.T_Manager();
        BLL.T_Manager   ManagerBll = new BLL.T_Manager();

        model.Id = Convert.ToInt32(ManagerBll.Select(Convert.ToInt32(GVManager.Rows[e.RowIndex].Cells[0].Text)).Tables[0].Rows[0][0].ToString());


        if (ManagerBll.Delete(model.Id))
        {
            Response.Write("FAILURE");
            BindDate();
        }
        else
        {
            Response.Write("FAILURE");
        }
    }
    protected void login_Click(object sender, ImageClickEventArgs e)
    {
        Model.T_Manager model = new Model.T_Manager();
        model.UserName = username.Text;
        model.PassWord = password.Text;


        BLL.T_Manager Login = new BLL.T_Manager();
        if (Login.select(model))
        {
            Session.Add("username", model.UserName);
            Response.Redirect("Default.aspx");
        }
        else
        {
            Label1.Visible = true;
            Label1.Text    = "用户名或密码错误!";
        }
    }
Beispiel #7
0
        public bool select(Model.T_Manager model)
        {
            //读取配置文件中的相关节点信息:数据库连接字符串
            string setting = ConfigurationManager.ConnectionStrings["connstring"].ToString();

            SqlConnection myconn = new SqlConnection(setting);

            myconn.Open();

            string username = model.UserName;
            //string password = model.PassWord;

            string str = "SELECT [Id] FROM T_Manager WHERE UserName=@username AND PassWord=@password ";

            SqlCommand cmd = new SqlCommand(str, myconn);

            cmd.Parameters.AddWithValue("@username", model.UserName.ToString());
            cmd.Parameters.AddWithValue("@password", model.PassWord);


            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            DataSet ds = new DataSet();

            sda.Fill(ds);

            sda.Dispose();

            myconn.Dispose();

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
 //有参查找
 public bool select(Model.T_Manager model)
 {
     return(manger.select(model));
 }
Beispiel #9
0
 //修改,更新
 public bool Update(Model.T_Manager model)
 {
     return(manger.Update(model));
 }
Beispiel #10
0
 //增加
 public bool Add(Model.T_Manager model)
 {
     return(manger.Add(model));
 }