/// <summary>
        /// 执行SQL
        /// </summary>
        /// <returns></returns>
        public static DataSet DoSqlRetrun(string sqlStr, string UserCode, string UserPwd)
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            try
            {
                ds.Tables.Add(dt);
                dt.Columns.Add("Code", typeof(string));
                dt.Columns.Add("Msg", typeof(string));

                if (UserCode.Trim().Length == 0)
                {
                    DataRow drCode = dt.NewRow();
                    drCode["Code"] = "01";
                    drCode["Msg"]  = "用户名不能为空!";
                    dt.Rows.Add(drCode);
                    return(ds);
                }
                if (UserPwd.Trim().Length == 0)
                {
                    DataRow drPwd = dt.NewRow();
                    drPwd["Code"] = "02";
                    drPwd["Msg"]  = "密码不能为空!";
                    dt.Rows.Add(drPwd);
                    return(ds);
                }
                UserInfo ui = new UserInfo();
                ui.UserPwd  = UserPwd;
                ui.UserCode = UserCode;

                List <UserInfo> listUserInfo = new List <UserInfo>(LoginDao.CheckUserInfo(ui));
                if (listUserInfo != null && listUserInfo.Count != 0)
                {
                    ds.Tables.Add(MyBatis.QueryForDataTable("SelectSql", sqlStr).Copy());
                    DataRow drOk = dt.NewRow();
                    drOk["Code"] = "00";
                    drOk["Msg"]  = "成功!";
                    dt.Rows.Add(drOk);
                    return(ds);
                }
                else
                {
                    DataRow drNull = dt.NewRow();
                    drNull["Code"] = "03";
                    drNull["Msg"]  = "用户名密码错误!";
                    dt.Rows.Add(drNull);
                    return(ds);
                }
            }
            catch (Exception ex)
            {
                DataRow drError = dt.NewRow();
                drError["Code"] = "04";
                drError["Msg"]  = ex.ToString();
                dt.Rows.Add(drError);
                return(ds);
            }
        }
示例#2
0
 /// <summary>
 /// 获得DataTable
 /// </summary>
 /// <param name="key">标志</param>
 /// <param name="o">对象</param>
 /// <returns>数据表</returns>
 public System.Data.DataTable GetTable(string key, Object o)
 {
     return(MyBatis.QueryForDataTable(key, o));
 }
示例#3
0
 /// <summary>
 /// 获得输入SQL
 /// </summary>
 /// <param name="Key">标志</param>
 /// <param name="o">对象</param>
 /// <returns>SQL拼接后的语句</returns>
 public string ShowSQL(string Key, object o)
 {
     return(MyBatis.QueryForSql(Key, o));
 }