コード例 #1
0
ファイル: LoginEdit.xaml.cs プロジェクト: Dekai/zdk
        public void LoadData(int id)
        {
            m_Model = Library.Controller.SystemManager.Instance.Services.LoginUserService.GetModel(id);
            this.txtF_LoginName.Text    = m_Model.F_LoginName;
            this.txtF_PassWord.Password = m_Model.F_PassWord;

            foreach (NameValue nameValue in this.txtF_UserID.Items)
            {
                if (nameValue.IntValue.Equals(m_Model.F_UserID))
                {
                    this.txtF_UserID.SelectedItem = nameValue;
                    break;
                }
            }

            foreach (NameValue nameValue in this.txtF_RoleID.Items)
            {
                if (nameValue.IntValue.Equals(m_Model.F_RoleID))
                {
                    this.txtF_RoleID.SelectedItem = nameValue;
                    break;
                }
            }

            if (m_Model.F_IsActive == 1)
            {
                txtF_IsActive.IsChecked = true;
            }
            else
            {
                txtF_IsActive.IsChecked = false;
            }
        }
コード例 #2
0
ファイル: LoginUser.cs プロジェクト: Dekai/zdk
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Library.Model.LoginUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_LoginUser(");
            strSql.Append("F_LoginName,F_PassWord,F_UserID,F_RoleID,F_IsActive)");
            strSql.Append(" values (");
            strSql.Append("@F_LoginName,@F_PassWord,@F_UserID,@F_RoleID,@F_IsActive)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_LoginName", SqlDbType.VarChar, 50),
                new SqlParameter("@F_PassWord",  SqlDbType.VarChar, 50),
                new SqlParameter("@F_UserID",    SqlDbType.Int,      4),
                new SqlParameter("@F_RoleID",    SqlDbType.Int,      4),
                new SqlParameter("@F_IsActive",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_LoginName;
            parameters[1].Value = model.F_PassWord;
            parameters[2].Value = model.F_UserID;
            parameters[3].Value = model.F_RoleID;
            parameters[4].Value = model.F_IsActive;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
ファイル: LoginUser.cs プロジェクト: Dekai/zdk
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Library.Model.LoginUser DataRowToModel(DataRow row)
 {
     Library.Model.LoginUser model = new Library.Model.LoginUser();
     if (row != null)
     {
         if (row["F_ID"] != null && row["F_ID"].ToString() != "")
         {
             model.F_ID = int.Parse(row["F_ID"].ToString());
         }
         if (row["F_LoginName"] != null)
         {
             model.F_LoginName = row["F_LoginName"].ToString();
         }
         if (row["F_PassWord"] != null)
         {
             model.F_PassWord = row["F_PassWord"].ToString();
         }
         if (row["F_UserID"] != null && row["F_UserID"].ToString() != "")
         {
             model.F_UserID = int.Parse(row["F_UserID"].ToString());
         }
         if (row["F_RoleID"] != null && row["F_RoleID"].ToString() != "")
         {
             model.F_RoleID = int.Parse(row["F_RoleID"].ToString());
         }
         if (row["F_IsActive"] != null && row["F_IsActive"].ToString() != "")
         {
             model.F_IsActive = int.Parse(row["F_IsActive"].ToString());
         }
     }
     return(model);
 }
コード例 #4
0
ファイル: LoginUser.cs プロジェクト: Dekai/zdk
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Library.Model.LoginUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_LoginUser set ");
            strSql.Append("F_LoginName=@F_LoginName,");
            strSql.Append("F_PassWord=@F_PassWord,");
            strSql.Append("F_UserID=@F_UserID,");
            strSql.Append("F_RoleID=@F_RoleID,");
            strSql.Append("F_IsActive=@F_IsActive");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_LoginName", SqlDbType.VarChar, 50),
                new SqlParameter("@F_PassWord",  SqlDbType.VarChar, 50),
                new SqlParameter("@F_UserID",    SqlDbType.Int,      4),
                new SqlParameter("@F_RoleID",    SqlDbType.Int,      4),
                new SqlParameter("@F_IsActive",  SqlDbType.Int,      4),
                new SqlParameter("@F_ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_LoginName;
            parameters[1].Value = model.F_PassWord;
            parameters[2].Value = model.F_UserID;
            parameters[3].Value = model.F_RoleID;
            parameters[4].Value = model.F_IsActive;
            parameters[5].Value = model.F_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
ファイル: LoginUser.cs プロジェクト: Dekai/zdk
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Library.Model.LoginUser GetModel(int F_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_ID,F_LoginName,F_PassWord,F_UserID,F_RoleID,F_IsActive from T_LoginUser ");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_ID;

            Library.Model.LoginUser model = new Library.Model.LoginUser();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
ファイル: LoginEdit.xaml.cs プロジェクト: Dekai/zdk
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            bool b = false;

            if (string.IsNullOrEmpty(this.txtF_LoginName.Text.Trim()))
            {
                this.txtF_LoginNameTip.Text = "(必须填写!)";
                b = true;
            }
            if (string.IsNullOrEmpty(this.txtF_PassWord.Password.Trim()))
            {
                this.txtF_PassWordTip.Text = "(必须填写!)";
                b = true;
            }

            if (txtF_UserID.SelectedItem == null)
            {
                this.txtF_UserIDTip.Text = "(必须选择!)";
                b = true;
            }

            if (txtF_RoleID.SelectedItem == null)
            {
                this.txtF_RoleIDTip.Text = "(必须选择!)";
                b = true;
            }

            if (b)
            {
                return;
            }

            if (m_Model == null)
            {
                Library.Model.LoginUser model = new Library.Model.LoginUser();
                model.F_LoginName = this.txtF_LoginName.Text.Trim();
                model.F_PassWord  = this.txtF_PassWord.Password.Trim();
                model.F_UserID    = (txtF_UserID.SelectedItem as NameValue).IntValue.Value;
                model.F_RoleID    = (txtF_RoleID.SelectedItem as NameValue).IntValue.Value;
                model.F_IsActive  = txtF_IsActive.IsChecked == true ? 1 : 0;

                if (SystemManager.Instance.Services.LoginUserService.GetList("F_UserID =" + model.F_UserID).Tables[0].Rows.Count > 0)
                {
                    this.txtF_UserIDTip.Text = "(用户已经存在!)";
                    return;
                }

                Library.Controller.SystemManager.Instance.Services.LoginUserService.Add(model);
                if (SaveComplete != null)
                {
                    SaveComplete(model);
                }
            }
            else
            {
                m_Model.F_LoginName = this.txtF_LoginName.Text.Trim();
                m_Model.F_PassWord  = this.txtF_PassWord.Password.Trim();
                m_Model.F_UserID    = (txtF_UserID.SelectedItem as NameValue).IntValue.Value;
                m_Model.F_RoleID    = (txtF_RoleID.SelectedItem as NameValue).IntValue.Value;
                m_Model.F_IsActive  = txtF_IsActive.IsChecked == true ? 1 : 0;

                if (SystemManager.Instance.Services.LoginUserService.GetList("F_UserID =" + m_Model.F_UserID + " and F_ID !=" + m_Model.F_ID).Tables[0].Rows.Count > 0)
                {
                    this.txtF_UserIDTip.Text = "(用户已经存在!)";
                    return;
                }

                Library.Controller.SystemManager.Instance.Services.LoginUserService.Update(m_Model);
                if (SaveComplete != null)
                {
                    SaveComplete(m_Model);
                }
            }


            this.Close();
        }