Beispiel #1
0
    /**
     * 充值:ChargeAction
     * 参数:1:Token 用户的seeion标示符
     * 2:Money 充值的金额
     * 返回:1:Result 结果(0表示成功,其他均是错误码,
     * -1:用户异地登陆,须管理员先注销上次登陆ip,-2:Token不正确)
     * 2:Money 返回用户充值完后,账户的总余额
     **/
    public void ChargeAction(int Money, Action <object> callBack)
    {
        Dictionary <string, object> param = new Dictionary <string, object>();

        param.Add("money", Money);
        param.Add("token", UserModel.getInstance().UserVo.token);

        PopMaskMaskManager.show(0.5f);
        //测试Action委托
        //Action<object> action;
        Action <object, object> action;

        action = (object data, object str) => {
            BaseVo baseVo = data as BaseVo;
            int    result = baseVo.result;         //System.Convert.ToInt32( data["Result"] );
            if (result == Config.CODE_SUCCESS)
            {
                //UserModel.getInstance().UserVo.money = UserModel.getInstance().UserVo.money + Money;
                JsonData json = JsonMapper.ToObject(str.ToString());
                UserModel.getInstance().UserVo.money = int.Parse(json["money"].ToString());

                if (callBack != null)
                {
                    callBack(result);
                }
            }

            PopMaskMaskManager.hide();
        };

        //Action action
        HttpLoadManager.getInstance.json <BaseVo>("api/v1/users/charge", action, param);
    }
        protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
        {
            CursoVo cursoVo = (CursoVo)vo;
            this.AddParameter(sqlCmd, "@id", cursoVo.id);

            this.AddParametersForInsert(sqlCmd, vo);
        }
Beispiel #3
0
        public bool insert(BaseVo baseVo)
        {
            bool   needInsert = false;
            string tableName  = getTableNameByVo(baseVo);
            Dictionary <string, object> dict = ObjectUtils.EachObjProperties(baseVo);

            string sql    = "insert into " + tableName;
            string fields = " ( ";
            string values = "values ( ";

            foreach (var prop in dict)
            {
                needInsert = true;
                Console.WriteLine(prop.Key, prop.Value);
                fields += prop.Key + ", ";
                values += (prop.Value != null ? "\"" + prop.Value.ToString() + "\""  : "") + ", ";
            }

            if (!needInsert)
            {
                return(false);
            }

            fields = fields.Substring(0, fields.Length - 2) + " ) ";
            values = values.Substring(0, values.Length - 2) + " );";

            sql += fields + values;

            int ret = executeNonQuery(sql);

            return(ret != 0);
        }
 protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
 {
     TipoSalaVo tipoSalaVo = (TipoSalaVo)vo;
     this.AddParameter(sqlCmd, "@id", tipoSalaVo.id);
     this.AddParameter(sqlCmd, "@dscTipoSala", tipoSalaVo.dscTipoSala);
     this.AddParameter(sqlCmd, "@datInativo", tipoSalaVo.datInativo);
 }
Beispiel #5
0
        private string getTableNameByVo(BaseVo baseVo)
        {
            string type  = baseVo.GetType().ToString();
            string table = type.Substring(type.LastIndexOf('.') + 1);

            return(table);
        }
 protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
 {
     DisciplinaVo disciplinaVo = (DisciplinaVo)vo;
     this.AddParameter(sqlCmd, "@id", disciplinaVo.id);
     this.AddParameter(sqlCmd, "@dscDisciplina", disciplinaVo.dscDisciplina);
     this.AddParameter(sqlCmd, "@datInativo", disciplinaVo.datInativo);
 }
        protected override void InsertRow(System.Data.SqlClient.SqlConnection sqlCon, BaseVo vo)
        {
            SqlCommand sqlCmd = base.GetStoredProc(sqlCon, this.GetSqlInsert(vo));
            this.AddParametersForInsert(sqlCmd, vo);

            SqlDataReader dr = sqlCmd.ExecuteReader();
            if (dr.Read()) ((TipoSalaVo) vo).id = ReadInt( dr["id"].ToString() );
            dr.Close();
        }
 protected override void AddParametersForInsert(SqlCommand sqlCmd, BaseVo vo)
 {
     CursoVo cursoVo = (CursoVo)vo;
     this.AddParameter(sqlCmd, "@dscCurso", cursoVo.dscCurso);
     this.AddParameter(sqlCmd, "@dscAbreviatura", cursoVo.dscAbreviatura);
     this.AddParameter(sqlCmd, "@datInicio", cursoVo.datInicio);
     this.AddParameter(sqlCmd, "@idCoordenador", cursoVo.idCoordenador);
     this.AddParameter(sqlCmd, "@datInativo", cursoVo.datInativo);
 }
        public ArrayList FindByCriteria(BaseVo vo)
        {
            SqlConnection sqlCon = null;

            try {
                sqlCon = GetConnection();
                return this.SelectByCriteria(sqlCon, vo);
            } catch (Exception e) {
                throw new SenacMapAdoException("Um erro ocorreu na busca das informações: " + e.Message, e);
            } finally {
                this.CloseConnection(sqlCon);
            }
        }
        protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
        {
            SalaVo salaVo = (SalaVo)vo;

            this.AddParameter(sqlCmd, "@codSala", salaVo.codSala);
            this.AddParameter(sqlCmd, "@numPredio", salaVo.numPredio);
            this.AddParameter(sqlCmd, "@numAndar", salaVo.numAndar);
            this.AddParameter(sqlCmd, "@datInativo", salaVo.datInativo);
            this.AddParameter(sqlCmd, "@dscObs", salaVo.dscObs);
            this.AddParameter(sqlCmd, "@numComputadores", salaVo.numComputadores);
            this.AddParameter(sqlCmd, "@numProjetores", salaVo.numProjetores);
            this.AddParameter(sqlCmd, "@numCadeiras", salaVo.numCadeiras);
            this.AddParameter(sqlCmd, "@idTipoSala", salaVo.idTipoSala);
        }
        public void Delete(BaseVo vo)
        {
            SqlConnection sqlCon = null;

            try
            {
                sqlCon = GetConnection();
                this.DeleteRow(sqlCon, vo);
            }
            catch (Exception e)
            {
                throw new SenacMapAdoException("Um erro ocorreu ao excluir os dados: " + e.Message, e);
            }
            finally
            {
                this.CloseConnection(sqlCon);
            }
        }
Beispiel #12
0
    /**
     * 过滤公共的错误码接口
     * */
    private void Filter(object data)
    {
        BaseVo baseVo = (BaseVo)data;
        int    code   = baseVo.result;

        if (code == Config.CODE_SUCCESS)
        {
            return;
        }
        else if (code == Config.CODE_Remote_login)            //异地登录
        {
            PopMessageManager.show("remote login ");
        }
        else if (code == Config.CODE_Token_Error)            //token 不正确
        {
            PopMessageManager.show("token error ");
        }
        else if (code == Config.CODE_WWW_Error)
        {
            PopMessageManager.show("www error !" + baseVo.msg);             //POST请求失败
            Echo.Log("error is :" + baseVo.msg);
        }
    }
 protected override void AddParametersByCriteria(SqlCommand sqlCmd, BaseVo vo)
 {
     MembroVo membroVo = (MembroVo)vo;
     if (!"".Equals(membroVo.dscNome))
         this.AddParameter(sqlCmd, "@dscNome", membroVo.dscNome);
 }
 protected override void AddParametersByPk(SqlCommand sqlCmd, BaseVo vo)
 {
     this.AddParameter(sqlCmd, "@id", ((MembroVo) vo).id);
 }
 protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
 {
 }
 protected override void AddParametersForUpdate(SqlCommand sqlCmd, BaseVo vo)
 {
     this.AddParameter(sqlCmd, "@id", ((MembroVo)vo).id);
     this.AddParametersForInsert(sqlCmd, vo);
 }
Beispiel #17
0
 public bool update(BaseVo baseVo)
 {
     throw new NotImplementedException();
 }
 protected override string GetSqlInsert(BaseVo vo)
 {
     return "spInSala";
 }
 protected override string GetSqlInsert(BaseVo vo)
 {
     return "spInDisciplina";
 }
 protected override void AddParametersByPk(SqlCommand sqlCmd, BaseVo vo)
 {
     this.AddParameter(sqlCmd, "@codSala", ((SalaVo)vo).codSala);
 }
 protected override string GetSqlSelectByPrimaryKey(BaseVo vo)
 {
     return "spSeSala";
 }
Beispiel #22
0
 public bool remove(BaseVo baseVo)
 {
     throw new NotImplementedException();
 }
 protected override void AddParametersByCriteria(SqlCommand sqlCmd, BaseVo vo)
 {
     DisciplinaVo disciplinaVo = (DisciplinaVo)vo;
     if (!"".Equals(disciplinaVo.dscDisciplina))
         this.AddParameter(sqlCmd, "@dscDisciplina", disciplinaVo.dscDisciplina);
 }
 protected override void AddParametersByPk(SqlCommand sqlCmd, BaseVo vo)
 {
 }
 protected override void AddParametersForInsert(SqlCommand sqlCmd, BaseVo vo)
 {
 }
        protected override void AddParametersForInsert(SqlCommand sqlCmd, BaseVo vo)
        {
            MembroVo membroVo = (MembroVo)vo;

            this.AddParameter(sqlCmd, "@dscNome", membroVo.dscNome);
            this.AddParameter(sqlCmd, "@dscEmail", membroVo.dscEmail);
            this.AddParameter(sqlCmd, "@dscMatricula", membroVo.dscMatricula);
            this.AddParameter(sqlCmd, "@indStatus", membroVo.indStatus);
            this.AddParameter(sqlCmd, "@indTipo", membroVo.indTipo);
            this.AddParameter(sqlCmd, "@datCriacao", membroVo.datCriacao);
            this.AddParameter(sqlCmd, "@datInativo", membroVo.datInativo);
            this.AddParameter(sqlCmd, "@datNascimento", membroVo.datNascimento);
        }
 protected override string GetSqlUpdate(BaseVo vo)
 {
     return "spUpDisciplina";
 }
 protected override void AddParametersByCriteria(SqlCommand sqlCmd, BaseVo vo)
 {
     SalaVo salaVo = (SalaVo)vo;
     if (!"".Equals(salaVo.codSala))
         this.AddParameter(sqlCmd, "@codSala", salaVo.codSala);
 }
 protected override void AddParametersByCriteria(SqlCommand sqlCmd, BaseVo vo)
 {
     TipoSalaVo tipoSalaVo = (TipoSalaVo)vo;
     if (!"".Equals(tipoSalaVo.dscTipoSala))
         this.AddParameter(sqlCmd, "@dscTipoSala", tipoSalaVo.dscTipoSala);
 }
 protected override void AddParametersForInsert(SqlCommand sqlCmd, BaseVo vo)
 {
     this.AddParametersForUpdate(sqlCmd, vo);
 }
        public BaseVo FindByPrimaryKey(BaseVo vo)
        {
            SqlConnection sqlCon = null;

            try
            {
                sqlCon = GetConnection();
                return this.LoadRow(sqlCon, vo);
            }
            catch (Exception e)
            {
                throw new SenacMapAdoException("Um erro ocorreu na busca das informações: " + e.Message, e);
            }
            finally
            {
                this.CloseConnection(sqlCon);
            }
        }
 protected override string GetSqlDelete(BaseVo vo)
 {
     return "spDeSala";
 }
Beispiel #33
0
        public List <BaseVo> getResults(BaseVo baseVo)
        {
            bool          needQuery          = false;
            List <BaseVo> result             = new List <BaseVo>();
            string        tableName          = getTableNameByVo(baseVo);
            Dictionary <string, object> dict = ObjectUtils.EachObjProperties(baseVo);
            string fields = "";

            string where = " where 1=1 ";

            List <string> fieldList = new List <string>();// 字段名列表,有序

            foreach (var prop in dict)
            {
                needQuery = true;
                Console.WriteLine(prop.Key, prop.Value);

                fields += prop.Key + ", ";
                fieldList.Add(prop.Key);

                Console.WriteLine(prop.Value);

                PropertyInfo pInfo = baseVo.GetType().GetProperty(prop.Key);

                if (pInfo.PropertyType == typeof(string))
                {
                    if (prop.Value != null && prop.Value.ToString() != "")
                    {
                        where += " and " + prop.Key + " = " + prop.Value.ToString();
                    }
                }
                else if (pInfo.PropertyType == typeof(int))
                {
                    if (int.Parse(prop.Value.ToString()) != 0)
                    {
                        where += " and " + prop.Key + " = " + prop.Value.ToString();
                    }
                }
            }

            if (!needQuery)
            {
                return(result);
            }

            fields = fields.Substring(0, fields.Length - 2);


            string sql = "select " + fields + " from " + tableName + where;

            string typeName = baseVo.GetType().ToString();
            Type   type     = Type.GetType(typeName);

            SQLiteDataReader sr = executeReader(sql);

            while (sr.Read())
            {
                var obj = type.Assembly.CreateInstance(typeName) as BaseVo;

                for (int i = 0; i < fieldList.Count; i++)
                {
                    string field = fieldList[i];
                    string value = sr[field].ToString();

                    PropertyInfo pInfo = obj.GetType().GetProperty(field);

                    Console.WriteLine(pInfo.PropertyType);
                    if (pInfo.PropertyType == typeof(string))
                    {
                        pInfo.SetValue(obj, value, null);
                    }
                    else if (pInfo.PropertyType == typeof(int))
                    {
                        pInfo.SetValue(obj, int.Parse(value), null);
                    }
                    else
                    {
                        pInfo.SetValue(obj, value, null);
                    }
                }

                result.Add(obj as BaseVo);
            }

            return(result);
        }
 protected override string GetSqlSelectByCriteria(BaseVo vo)
 {
     return "spSeAllSala";
 }
 protected override void AddParametersByCriteria(SqlCommand sqlCmd, BaseVo vo)
 {
     CursoVo cursoVo = (CursoVo)vo;
     if (!"".Equals(cursoVo.dscCurso))
         this.AddParameter(sqlCmd, "@dscCurso", cursoVo.dscCurso);
 }
 protected override string GetSqlUpdate(BaseVo vo)
 {
     return "spUpSala";
 }
 protected override string GetSqlDelete(BaseVo vo)
 {
     return "spDeDisciplina";
 }