Exemple #1
0
        /// <summary>
        /// 得到数据
        /// </summary>
        public string ConSql(AF_User Model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("User_LoginName = '" + ValueHandler.GetStringValue(Model.User_LoginName) + "', ");

            strSql.Append("User_Password = '******', ");

            strSql.Append("User_Name = '" + ValueHandler.GetStringValue(Model.User_Name) + "', ");

            strSql.Append("User_Sex = '" + ValueHandler.GetStringValue(Model.User_Sex) + "', ");

            strSql.Append("User_Age = " + ValueHandler.GetIntNumberValue(Model.User_Age) + ", ");

            strSql.Append("User_Phone = '" + ValueHandler.GetStringValue(Model.User_Phone) + "', ");

            strSql.Append("User_Post = '" + ValueHandler.GetStringValue(Model.User_Post) + "', ");

            strSql.Append("User_EntryDate = " + ValueHandler.GetMarkStringDateValue(Model.User_EntryDate) + ", ");

            strSql.Append("User_Place = '" + ValueHandler.GetStringValue(Model.User_Place) + "', ");

            strSql.Append("JoinMan = '" + ValueHandler.GetStringValue(Model.JoinMan) + "' ");
            return(strSql.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 保存用户
        /// </summary>
        /// <param name="aF_User"></param>
        /// <returns></returns>
        public string SaveUser(AF_User aF_User)
        {
            StringBuilder strSql = new StringBuilder();

            if (ValueHandler.GetStringValue(aF_User.User_Code) == "")
            {
                DataTable dt = SearchData("SELECT COUNT(0) FROM AF_User WHERE User_LoginName='" + ValueHandler.GetStringValue(aF_User.User_LoginName) + "' OR User_Name='" + ValueHandler.GetStringValue(aF_User.User_Name) + "'");
                if (Convert.ToInt32(dt.Rows[0][0]) > 0)
                {
                    return(null);
                }
            }
            else
            {
                DataTable dt = SearchData("SELECT COUNT(0) FROM AF_User WHERE (User_LoginName='" + ValueHandler.GetStringValue(aF_User.User_LoginName) + "' OR User_Name='" + ValueHandler.GetStringValue(aF_User.User_Name) + "') And User_Code<>'" + ValueHandler.GetStringValue(aF_User.User_Code) + "'");
                if (Convert.ToInt32(dt.Rows[0][0]) > 0)
                {
                    return(null);
                }
            }
            strSql.Append("\r IF NOT EXISTS(SELECT * FROM AF_User WHERE User_Code ='" + ValueHandler.GetStringValue(aF_User.User_Code) + "')");
            strSql.Append("\r BEGIN ");
            strSql.Append("\r INSERT INTO AF_User(");
            strSql.Append("User_Code,User_LoginName,User_Password,User_Name,User_Sex,User_Age,User_Phone,User_Post,User_EntryDate,User_Place,JoinMan");
            strSql.Append(") SELECT ");
            string strCode = ValueHandler.GetStringValue(aF_User.User_Code);

            if (aF_User.User_Code == "")
            {
                strCode = GetCode();
            }
            strSql.Append("\r User_Code = '" + strCode + "',");
            strSql.Append(ConSql(aF_User));
            strSql.Append("\r END");
            strSql.Append("\r ELSE");
            strSql.Append("\r BEGIN ");
            strSql.Append("UPDATE AF_User SET ");
            strSql.Append(ConSql(aF_User));
            strSql.Append(" WHERE User_Code ='" + ValueHandler.GetStringValue(aF_User.User_Code) + "'");
            strSql.Append("\r END");
            UpdateData(strSql.ToString());
            return(strCode);
        }