示例#1
0
        /// <summary>
        /// 添加字典
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        public MsgEntity AddDict(T_Sys_Dict dict)
        {
            MsgEntity me = new MsgEntity();

            if (dict == null || string.IsNullOrEmpty(dict.DICT_CODE))
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "字典编码不能为空";
                return(me);
            }
            //查找关键字是否有相同值
            int count = dao.Count <T_Sys_Dict>(Predicates.Field <T_Sys_Dict>(f => f.DICT_CODE, Operator.Eq, dict.DICT_CODE));

            if (count > 0)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "字典编码重复";
                return(me);
            }
            dynamic result = dao.Insert <T_Sys_Dict>(dict);

            if (result != null)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Success;
                me.MsgDes  = MsgEntity.MsgCodeEnum.Success.GetDescription();
            }
            return(me);
        }
示例#2
0
        public ApiResponse Create(TipoUsuario tipoUsuario)
        {
            ApiResponse resp = this.ValidateTipoUsuario(tipoUsuario);

            if (resp.Success == false)
            {
                return(resp);
            }
            else
            {
                resp = new ApiResponse();
            }

            try
            {
                DAOBase <TipoUsuario> daoA = new DAOBase <TipoUsuario>();
                daoA.Insert(tipoUsuario);

                resp.Success = true;
                resp.data    = tipoUsuario;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
        public ApiResponse Create(Empresa empresa)
        {
            ApiResponse resp = this.ValidateEmpresa(empresa);

            if (resp.Success == false)
            {
                return(resp);
            }
            else
            {
                resp = new ApiResponse();
            }

            try
            {
                DAOBase <Empresa> daoA = new DAOBase <Empresa>();
                daoA.Insert(empresa);

                resp.Success = true;
                resp.data    = empresa;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
示例#4
0
        public void InsertNFeDataBase(Entity.ReceivedResponse respAPI)
        {
            int i = 0;

            try
            {
                Console.WriteLine("Inserindo notas na base de dados...");

                //Para cada nota devolvida.
                //Obtem a chave de acesso e o valor total da nota.
                //Sava a nota no banco de dados.
                foreach (Entity.ReceivedResponse.Datum item in respAPI.data)
                {
                    i += 1;

                    //Obtem a chave de acesso.
                    string accessKey = item.access_key;
                    try
                    {
                        //Obtem o valor total da nota.
                        double valorNF = GetNFTotalValue(item.xml);
                        Console.WriteLine("AccessKey(" + i + "):" + accessKey);
                        Console.WriteLine("NFe Value: " + valorNF);

                        //Atribui os valores ao objeto nota fiscal.
                        NotaFiscal nf = new NotaFiscal();
                        nf.access_key = accessKey;
                        nf.total_nota = valorNF;

                        //Insere a nota(chave e valor) na base de dados.
                        DAOBase <NotaFiscal> dao = new DAOBase <NotaFiscal>();
                        dao.Insert(nf);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("AccessKey(" + i + "):" + accessKey);
                        Console.WriteLine("Error: " + e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Erro ao inserir nota na base de dados: {0}", e);
                throw;
            }
        }
示例#5
0
        public ApiResponse Create(Alcada alcada)
        {
            ApiResponse resp = new ApiResponse();

            if (alcada == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Conteudo vazio");
                return(resp);
            }

            if (string.IsNullOrEmpty(alcada.s_descricao) == true)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Descricao nao informada");
                return(resp);
            }

            try
            {
                DAOBase <Alcada> daoA = new DAOBase <Alcada>();
                daoA.Insert(alcada);

                resp.Success = true;
                resp.data    = alcada;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
        public ApiResponse Create(TipoParticipante tipoParticipante)
        {
            ApiResponse resp = new ApiResponse();

            if (tipoParticipante == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Conteudo vazio");
                return(resp);
            }

            if (string.IsNullOrEmpty(tipoParticipante.s_descricao) == true)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Descricao nao informada");
                return(resp);
            }

            try
            {
                DAOBase <TipoParticipante> daoA = new DAOBase <TipoParticipante>();
                daoA.Insert(tipoParticipante);

                resp.Success = true;
                resp.data    = tipoParticipante;

                return(resp);
            }
            catch (Exception e)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add(e.Message);
                return(resp);
            }
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public MsgEntity Add(T_EC_KWCategory category)
        {
            MsgEntity me = new MsgEntity();

            if (category == null || string.IsNullOrEmpty(category.CATEGORY_CODE) || string.IsNullOrEmpty(category.CATEGORY_NAME))
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "编码或名称不能为空";
                return(me);
            }
            //查找关键字是否有相同值
            int count = dao.Count <T_EC_KWCategory>(Predicates.Field <T_EC_KWCategory>(f => f.CATEGORY_CODE, Operator.Eq, category.CATEGORY_CODE));

            if (count > 0)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "编码重复";
                return(me);
            }
            dynamic result = null;

            try
            {
                result = dao.Insert <T_EC_KWCategory>(category);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (result != null)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Success;
                me.MsgDes  = MsgEntity.MsgCodeEnum.Success.GetDescription();
            }
            return(me);
        }