zoukankan      html  css  js  c++  java
  • 点滴积累【C#】初始页面自动给站点名称赋值

    初始页面自动给站点名称赋值

    效果:

    说明:点击进入添加页面时,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 /// <summary>
    15         /// 用登录名创建User
    16         /// </summary>
    17         /// <param name="loginID"></param>
    18         /// <returns></returns>
    19         public static Users CreateUserByLoginID(string loginID)
    20         {
    21             Users user = new Users();
    22             string sql = @"select UserID,LoginID,UserName,UserPassword ,zdmc from UserManagement
    23                             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         }
  • 相关阅读:
    tyvjP1078
    红黑树笔记
    红黑树插入代码学习
    tyvjP1082找朋友
    牛棚回声USACO OCT09 3RD
    每日参悟
    全排列学习
    学习1.2
    学习笔记1.1
    学习笔记1.3
  • 原文地址:https://www.cnblogs.com/xinchun/p/2863344.html
Copyright © 2011-2022 走看看