예제 #1
0
    //Check user name and code are right or not
    public bool Check(string strName, string strCode)
    {
        bool bRet = MySqlFunction.QueryUserIdAndCodeMatched(_db, strName, strCode);

        if (!bRet)
        {
            text_edit_username.GetComponentInParent <InputField>().text = "";
            text_edit_code.GetComponentInParent <InputField>().text     = "";
        }

        return(bRet);
    }
예제 #2
0
        /// <summary>
        ///     获取数据库的数据表
        /// </summary>
        /// <returns></returns>
        public List <TableInfo> GetTables()
        {
            if (Global.GetInstance().DB != null)
            {
                if (Global.GetInstance().DB.DbType == SQLDbTypes.SQLServer)
                {
                    return(SqlServerFunction.GetInstance().GetTables());
                }
                if (Global.GetInstance().DB.DbType == SQLDbTypes.MySQL)
                {
                    return(MySqlFunction.GetInstance().GetTables());
                }
            }

            return(new List <TableInfo>());
        }
예제 #3
0
        private bool IsValidData()
        {
            string        userName      = tbUserName.Text;
            string        password      = MD5EncryptionFunction.Encrypt(tbPassword.Text);
            string        selectSql     = @"SELECT * FROM `user` WHERE `status`=1 AND username = @username AND password = @password";
            SqlParameters sqlParameters = new SqlParameters();

            sqlParameters.Add(new SqlParameter("username", userName));
            sqlParameters.Add(new SqlParameter("password", password));
            DataTable resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters));

            if (resultDt.Rows.Count <= 0)
            {
                fncFilter.alert(MessagesVariable.InvalidUserNameOrPasswod);
                ClearData();
                tbUserName.Select();
                return(false);
            }

            string code     = resultDt.Rows[0]["usercode"].ToString();
            string fullName = resultDt.Rows[0]["fullname"].ToString();
            string syncId   = resultDt.Rows[0]["SyncId"].ToString();

            selectSql = @"SELECT * FROM `userauth` WHERE `userid` = @userwid";
            sqlParameters.Clear();
            sqlParameters.Add(new SqlParameter("userwid", syncId));
            resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters));
            List <string> Authorizations = new List <string>();

            foreach (DataRow dr in resultDt.Rows)
            {
                Authorizations.Add(dr["authorization"].ToString());
            }
            User = new cls_user();
            User.setcls_user(code, fullName, Authorizations, Convert.ToInt32(syncId));
            return(true);
        }
예제 #4
0
        /// <summary>
        ///     构造dao层框架
        /// </summary>
        /// <param name="className"></param>
        /// <param name="tableInfo"></param>
        /// <returns></returns>
        private string GetJavaDalClass(string className, TableInfo tableInfo)
        {
            //构造总输出
            var stringBuilder = new StringBuilder();

            //引入常用包
            stringBuilder.AppendLine("import java.util.*;");
            stringBuilder.AppendLine("import java.sql.*;");
            stringBuilder.AppendLine("");

            //写类名
            stringBuilder.AppendLine("/**");
            stringBuilder.AppendLine(" * " + className + "数据访问层");
            stringBuilder.AppendLine(" * @since " + DateTime.Now.ToString("yyyy-MM-dd"));
            stringBuilder.AppendLine(" * @author ");
            stringBuilder.AppendLine(" */");
            stringBuilder.AppendLine("public class " + GetPropertyName(className) + "DAO {");
            stringBuilder.AppendLine("");

            //SQL
            stringBuilder.AppendLine("");

            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetDalFields(tableInfo));
                break;
            }

            //公开方法
            stringBuilder.AppendLine("");
            //添加方法
            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
            {
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetInsertFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetBulkInsertFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetUpdateFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetDeleteFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetSelectFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetAllSelectFunc(className, tableInfo));
            }
            break;
            }

            //私有方法
            stringBuilder.AppendLine("");
            //添加方法
            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
            {
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetPrviateFuncs(className, tableInfo));
            }
            break;
            }


            //构造结束
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("}");
            return(stringBuilder.ToString());
        }
예제 #5
0
        private string GetCharpDalClass(string className, TableInfo tableInfo)
        {
            //构造总输出
            var stringBuilder = new StringBuilder();

            //写类名
            stringBuilder.AppendLine("public class " + className);
            stringBuilder.AppendLine("{");

            //写SQL语句部分
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("\t#region Fields");
            stringBuilder.AppendLine("");
            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetDalFields(tableInfo));
                break;
            }

            //添加字段块标识结束
            stringBuilder.AppendLine("\t#endregion Fields");
            stringBuilder.AppendLine("");

            //添加公共方法块开始
            stringBuilder.AppendLine("\t#region Public Methods");
            stringBuilder.AppendLine("");
            //添加方法
            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
            {
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetInsertFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetBulkInsertFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetUpdateFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetDeleteFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetSelectFunc(className, tableInfo));
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetAllSelectFunc(className, tableInfo));
            }
            break;
            }

            //添加公开方法块结束
            stringBuilder.AppendLine("\t#endregion Public Methods");

            //添加公共方法块开始
            stringBuilder.AppendLine("\t#region Private Methods");
            stringBuilder.AppendLine("");
            //添加方法
            switch (Global.GetInstance().DB.DbType)
            {
            case SQLDbTypes.MySQL:
            {
                stringBuilder.AppendLine(MySqlFunction.GetInstance().GetPrviateFuncs(className, tableInfo));
            }
            break;
            }

            //添加公开方法块结束
            stringBuilder.AppendLine("\t#endregion Private Methods");

            //构造结束
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("}");
            return(stringBuilder.ToString());
        }