初始页面自动给站点名称赋值
效果:
说明:点击进入添加页面时,Textbox文本框中自动给站点名称赋值
代码:
1 private string userzdmc; 2 public string Userzdmc 3 { 4 get 5 { 6 return userzdmc; 7 } 8 set 9 {10 userzdmc = value;11 }12 }13 14 ///15 /// 用登录名创建User16 /// 17 /// 18 ///19 public static Users CreateUserByLoginID(string loginID)20 {21 Users user = new Users();22 string sql = @"select UserID,LoginID,UserName,UserPassword ,zdmc from UserManagement23 WHERE LoginID=@LoginID";24 DbCommand sqlCommand = ERPDataBase.ERPDB.GetSqlStringCommand(sql);25 ERPDataBase.ERPDB.AddInParameter(sqlCommand, "@LoginID", DbType.String, loginID);26 DataSet ds = new DataSet();27 ERPDataBase.ERPDB.LoadDataSet(sqlCommand, ds, new string[] { "user" });28 if (ds.Tables["user"].Rows.Count > 0)29 {30 DataRow row = ds.Tables["user"].Rows[0];31 GiveUserValue(row, user);32 }33 return user;34 }35 36 protected static void GiveUserValue(DataRow row, Users user)37 {38 user.userID = row["UserID"] == DBNull.Value ? string.Empty : row["UserID"].ToString();39 user.userName = row["UserName"] == DBNull.Value ? string.Empty : row["UserName"].ToString();40 user.userPass = row["UserPassword"] == DBNull.Value ? string.Empty : row["UserPassword"].ToString();41 user.loginID = row["LoginID"] == DBNull.Value ? string.Empty : row["LoginID"].ToString();42 user.userzdmc = row["zdmc"] == DBNull.Value ? string.Empty : row["zdmc"].ToString();43 }
调用:
1 protected void Page_Load(object sender, EventArgs e) 2 { 3 Response.Expires = -1; 4 if (!IsPostBack) 5 { 6 7 if (ActionType == CommonEnum.ActionLevel.Write) 8 { 9 tbzdmc.Text = ERPUser.Userzdmc;10 }11 }12 }