Ejemplo n.º 1
0
        private static Tab_UserManager ToModel(DataRow row)
        {
            Tab_UserManager model = new Tab_UserManager();

            model.Idx          = row.IsNull("idx")?null:(System.Int32?)row["idx"];
            model.uName        = row.IsNull("uName")?null:(System.String)row["uName"];
            model.uPwd         = row.IsNull("uPwd")?null:(System.String)row["uPwd"];
            model.uRole        = row.IsNull("uRole")?null:(System.String)row["uRole"];
            model.uCreatedDate = row.IsNull("uCreatedDate")?null:(System.DateTime?)row["uCreatedDate"];
            return(model);
        }
Ejemplo n.º 2
0
        public int AddNew(Tab_UserManager model)
        {
            string sql = "insert into Tab_UserManager(uName,uPwd,uRole,uCreatedDate)  values(@uName,@uPwd,@uRole,@uCreatedDate); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@uName", model.uName)
                                                                 , new SqlParameter("@uPwd", model.uPwd)
                                                                 , new SqlParameter("@uRole", model.uRole)
                                                                 , new SqlParameter("@uCreatedDate", model.uCreatedDate)
                                                                 ));

            return(Idx);
        }
Ejemplo n.º 3
0
        public bool Update(Tab_UserManager model)
        {
            string sql  = "update Tab_UserManager set uName=@uName,uPwd=@uPwd,uRole=@uRole,uCreatedDate=@uCreatedDate where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@uName", model.uName)
                                                    , new SqlParameter("@uPwd", model.uPwd)
                                                    , new SqlParameter("@uRole", model.uRole)
                                                    , new SqlParameter("@uCreatedDate", model.uCreatedDate)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Ejemplo n.º 4
0
    protected void wpsubmit_Click(object sender, EventArgs e)
    {
        string uName = this.txtUserName.Value.Trim();
        string uPwd  = this.txtPassword.Value.Trim();

        DBEntity.Tab_UserManager ent  = new DBEntity.Tab_UserManager();
        DBEntity.Tab_UserManager ent2 = ent.CheckAccount(uName, uPwd);
        if (ent2 != null)
        {
            Cmn.Session.Set("Login_uName", ent2.uName);
            Cmn.Session.Set("Login_uRole", ent2.uRole);
            Response.Redirect("MainIndex.aspx");
        }
        else
        {
            Cmn.Js.ShowAlert("用户名或密码错误,请重新输入!");
        }
    }
Ejemplo n.º 5
0
        public Tab_UserManager Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserManager  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow         row   = dt.Rows[0];
            Tab_UserManager model = ToModel(row);

            return(model);
        }
Ejemplo n.º 6
0
        public Tab_UserManager CheckAccount(string uName, string pwd)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserManager  where uName=@uName and uPwd=@uPwd"
                                                    , new SqlParameter("@uName", uName)
                                                    , new SqlParameter("@uPwd", pwd)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow         row   = dt.Rows[0];
            Tab_UserManager model = ToModel(row);

            return(model);
        }