示例#1
0
        public void GravaNovaConta(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_CONTA_CORRENTE> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_CONTA_CORRENTE>();

                    Doran_Servicos_ORM.TB_CONTA_CORRENTE novo = new Doran_Servicos_ORM.TB_CONTA_CORRENTE();

                    novo.NUMERO_AGENCIA        = dados["NUMERO_AGENCIA"].ToString();
                    novo.NUMERO_CONTA          = dados["NUMERO_CONTA"].ToString();
                    novo.NUMERO_BANCO          = Convert.ToDecimal(dados["NUMERO_BANCO"]);
                    novo.ULTIMA_REMESSA        = Convert.ToDecimal(dados["ULTIMA_REMESSA"]);
                    novo.CONTROLE_NOSSO_NUMERO = dados["CONTROLE_NOSSO_NUMERO"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#2
0
        public void GravaNovaRegiao(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_REGIAO_VENDA> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_REGIAO_VENDA>();

                    Doran_Servicos_ORM.TB_REGIAO_VENDA novo = new Doran_Servicos_ORM.TB_REGIAO_VENDA();

                    novo.CODIGO_REGIAO = dados["CODIGO_REGIAO"].ToString();
                    novo.NOME_REGIAO   = dados["NOME_REGIAO"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
 private static bool CheckEntityIsAttached <TContext, TEntity>(TContext dbContext, TEntity entity)
     where TContext : System.Data.Linq.DataContext
     where TEntity : rsEntityBase
 {
     System.Data.Linq.Table <TEntity> entityTbl = dbContext.GetTable <TEntity>();
     return(entityTbl.GetOriginalEntityState(entity) != null);
 }
示例#4
0
        public void GravaNovoCusto(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_CUSTO_VENDA> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_CUSTO_VENDA>();

                    Doran_Servicos_ORM.TB_CUSTO_VENDA novo = new Doran_Servicos_ORM.TB_CUSTO_VENDA();

                    novo.DESCRICAO_CUSTO_VENDA       = dados["DESCRICAO_CUSTO_VENDA"].ToString();
                    novo.CUSTO_PERMANENTE            = Convert.ToDecimal(dados["CUSTO_PERMANENTE"]);
                    novo.PERCENTUAL_CUSTO_PERMANENTE = Convert.ToDecimal(dados["PERCENTUAL_CUSTO_PERMANENTE"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#5
0
        public void GravaNovoCiclista(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_CICLISTA> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_CICLISTA>();

                    Doran_Servicos_ORM.TB_CICLISTA novo = new Doran_Servicos_ORM.TB_CICLISTA();

                    novo.NOME_CICLISTA  = dados["NOME_CICLISTA"].ToString();
                    novo.CICLISTA_ATIVO = Convert.ToDecimal(dados["CICLISTA_ATIVO"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, "TB_CICLISTA", Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO_ORIGINAL"]));
                throw ex;
            }
        }
示例#6
0
        public void GravaNovaUF(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_UF> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_UF>();

                    Doran_Servicos_ORM.TB_UF novo = new Doran_Servicos_ORM.TB_UF();

                    novo.ID_UF             = Convert.ToDecimal(dados["ID_UF"]);
                    novo.DESCRICAO_UF      = dados["DESCRICAO_UF"].ToString();
                    novo.ALIQ_INTERNA_ICMS = Convert.ToDecimal(dados["ALIQ_INTERNA_ICMS"]);
                    novo.ALIQ_ICMS_UF      = Convert.ToDecimal(dados["ALIQ_ICMS_UF"]);
                    novo.SIGLA_UF          = dados["SIGLA_UF"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#7
0
        public void GravaNovoContato(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_CLIENTE_CONTATO> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_CLIENTE_CONTATO>();

                    Doran_Servicos_ORM.TB_CLIENTE_CONTATO novo = new Doran_Servicos_ORM.TB_CLIENTE_CONTATO();

                    novo.ID_CLIENTE                   = Convert.ToDecimal(dados["ID_CLIENTE"]);
                    novo.NOME_CONTATO_CLIENTE         = dados["NOME_CONTATO_CLIENTE"].ToString();
                    novo.TELEFONE_CONTATO_CLIENTE     = dados["TELEFONE_CONTATO_CLIENTE"].ToString();
                    novo.FAX_CONTATO_CLIENTE          = dados["FAX_CONTATO_CLIENTE"].ToString();
                    novo.EMAIL_CONTATO_CLIENTE        = dados["EMAIL_CONTATO_CLIENTE"].ToString();
                    novo.OBS_CONTATO_CLIENTE          = dados["OBS_CONTATO_CLIENTE"].ToString();
                    novo.RECEBE_COPIA_NOTA_ELETRONICA = Convert.ToDecimal(dados["RECEBE_COPIA_NOTA_ELETRONICA"]);
                    novo.SENHA_PORTAL                 = dados["SENHA_PORTAL"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#8
0
        public void GravaNovoProduto(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_PRODUTO> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_PRODUTO>();

                    Doran_Servicos_ORM.TB_PRODUTO novo = new Doran_Servicos_ORM.TB_PRODUTO();

                    novo.CODIGO_PRODUTO       = dados["CODIGO_PRODUTO"].ToString();
                    novo.DESCRICAO_PRODUTO    = dados["DESCRICAO_PRODUTO"].ToString();
                    novo.UNIDADE_MEDIDA_VENDA = dados["UNIDADE_MEDIDA_VENDA"].ToString();
                    novo.PRECO_PRODUTO        = Convert.ToDecimal(dados["PRECO_PRODUTO"]);
                    novo.ALIQ_ISS             = Convert.ToDecimal(dados["ALIQ_ISS_SERVICO"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#9
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            FormSettings();

            if (!Util.ReadConStr())
            {
                MessageBox.Show("Ошибка при подключении! Проверьте работу сервера и параметры подключения! \n\nПриложение будет закрыто!");
                System.Environment.Exit(0);
            }

            try
            {
                dcont    = new DannieDataClassesDataContext(Util.GetConnectionString());
                tabDanie = dcont.GetTable <danie>();
                tabUsers = dcont.GetTable <User>();

                dGridView.DataSource = tabDanie.OrderByDescending(ob => ob.nomer).ToList();

                GridSettings();

                label1.Text = dGridView.Rows.Count.ToString() + " записей";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка при получении данных! Проверьте работу сервера и параметры подключения! \n\nПриложение будет закрыто! \n" + ex.Message);
                System.Environment.Exit(0);
            }


            this.Cursor = Cursors.Default;
        }
示例#10
0
        public string GravaNovoPAGTO(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_PAGTO_PARCIAL> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_PAGTO_PARCIAL>();

                    Doran_Servicos_ORM.TB_PAGTO_PARCIAL novo = new Doran_Servicos_ORM.TB_PAGTO_PARCIAL();

                    DateTime dt = Convert.ToDateTime(dados["DATA_PAGTO"].ToString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') +
                                                     ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0'));

                    novo.NUMERO_FINANCEIRO = Convert.ToDecimal(dados["NUMERO_FINANCEIRO"]);
                    novo.DATA_PAGTO        = dt;
                    novo.VALOR_PAGTO       = Convert.ToDecimal(dados["VALOR_PAGTO"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria.Th2_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();

                    string soma = SomaPagtoParcial(Convert.ToDecimal(dados["NUMERO_FINANCEIRO"])).ToString();

                    return(soma);
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#11
0
        public void GravaNovoLimite(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_LIMITE> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_LIMITE>();

                    Doran_Servicos_ORM.TB_LIMITE novo = new Doran_Servicos_ORM.TB_LIMITE();

                    novo.VALOR_LIMITE = Convert.ToDecimal(dados["VALOR_LIMITE"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#12
0
        public void Save_Dashboard(lsttbl_Dashboard info)
        {
            var db = GlobalVar.DbBI;

            try
            {
                System.Data.Linq.Table <lsttbl_Dashboard> dashboards = db.lsttbl_Dashboards;
                var objFound = dashboards.FirstOrDefault(p => p.Code == info.Code);
                if (objFound == null)
                {
                    db.lsttbl_Dashboards.InsertOnSubmit(info);
                }
                else
                {
                    objFound.UpdateOnSubmit(info);
                }
                // update IsDefault
                if (info.IsDefault)
                {
                    foreach (lsttbl_Dashboard tbl in dashboards)
                    {
                        if (tbl.Code == info.Code)
                        {
                            continue;
                        }
                        tbl.IsDefault = false;
                    }
                }

                db.SubmitChanges();
            }
            catch { }
        }
示例#13
0
        private void getNameFromDatabase()
        {
            System.Data.Linq.Table <Member> members = DBManager.Instance().GetTable <Member>();
            foreach (Member member in members)
            {
                this.ddlName.Items.Add(member.Name);
                this.ddlName.Items[this.ddlName.Items.Count - 1].Tag = member.Id;

                if (this.type == EDITTRANSACTION)
                {
                    if (this.returnTransaction.MemberId == member.Id)
                    {
                        this.ddlName.SelectedIndex = this.ddlName.Items.Count - 1;
                    }
                }
            }

            if (this.type == NEWTRANSACTION)
            {
                if (this.ddlName.Items.Count > 0)
                {
                    this.ddlName.SelectedIndex = 0;
                }
            }
        }
示例#14
0
        public void GravaNovaTabela(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_TABELA_COMISSAO> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_TABELA_COMISSAO>();

                    Doran_Servicos_ORM.TB_TABELA_COMISSAO novo = new Doran_Servicos_ORM.TB_TABELA_COMISSAO();

                    novo.ID_VENDEDOR         = Convert.ToDecimal(dados["ID_VENDEDOR"]);
                    novo.MARGEM_INICIAL      = Convert.ToDecimal(dados["MARGEM_INICIAL"]);
                    novo.MARGEM_FINAL        = Convert.ToDecimal(dados["MARGEM_FINAL"]);
                    novo.PERCENTUAL_COMISSAO = Convert.ToDecimal(dados["PERCENTUAL_COMISSAO"]);

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#15
0
        public void GravaNovoTipoCobranca(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_TIPO_COBRANCA> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_TIPO_COBRANCA>();

                    Doran_Servicos_ORM.TB_TIPO_COBRANCA novo = new Doran_Servicos_ORM.TB_TIPO_COBRANCA();

                    novo.COD_TIPO_COBRANCA       = Convert.ToDecimal(dados["COD_TIPO_COBRANCA"]);
                    novo.NUMERO_BANCO            = Convert.ToDecimal(dados["NUMERO_BANCO"]);
                    novo.DESCRICAO_TIPO_COBRANCA = dados["DESCRICAO_TIPO_COBRANCA"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
    public void Bind(System.Data.Linq.Table <T> listSource)
    {
        Project.dbClassesDataContext dbc = new Project.dbClassesDataContext();
        tmpDataTable = listSource;
        var query = (from c in listSource select c);

        dgvRecords.DataSource = query.Take(10).ToList();
    }
    List <dynamic> GetDynamicList <T>() where T : class
    {
        System.Data.Linq.Table <T> table = db.GetTable <T>();

        var result = from a in table select a;

        return(result.ToList <dynamic>());
    }
示例#18
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         System.Data.Linq.Table <User> emp = Accessor.GetTable_Users();
         dataGridView_Сотрудники.DataSource = emp;
     }
     catch (Exception ex_) { MessageBox.Show(ex_.Message); this.Close(); }
 }
示例#19
0
        public void GravaNovo(Dictionary <string, object> dados, List <string> DESTINATARIOS, decimal ID_USUARIO, string LOGIN_USUARIO)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    string CLIENTE = (from linha in ctx.TB_PEDIDO_VENDAs
                                      where linha.NUMERO_PEDIDO == Convert.ToDecimal(dados["NUMERO_PEDIDO"])
                                      select linha.TB_ITEM_ORCAMENTO_VENDA.TB_ORCAMENTO_VENDA.TB_CLIENTE.NOMEFANTASIA_CLIENTE).ToList().First();

                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_FOLLOW_UP_PEDIDO> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_FOLLOW_UP_PEDIDO>();

                    Doran_Servicos_ORM.TB_FOLLOW_UP_PEDIDO novo = new Doran_Servicos_ORM.TB_FOLLOW_UP_PEDIDO();

                    novo.NUMERO_PEDIDO        = Convert.ToDecimal(dados["NUMERO_PEDIDO"]);
                    novo.ID_USUARIO_FOLLOW_UP = ID_USUARIO;
                    novo.DATA_HORA_FOLLOW_UP  = DateTime.Now;
                    novo.TEXTO_FOLLOW_UP      = dados["TEXTO_FOLLOW_UP"].ToString();

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert_PEDIDO_VENDA(ctx, novo, Entidade.ToString(),
                                                                                                 Convert.ToDecimal(dados["NUMERO_PEDIDO"]), ID_USUARIO);

                    ctx.SubmitChanges();

                    if (DESTINATARIOS.Count > 0)
                    {
                        using (Doran_Email_Posicao_Pedido email = new Doran_Email_Posicao_Pedido(ID_USUARIO))
                        {
                            string _OBS = string.Concat(LOGIN_USUARIO.ToUpper(), " salvou uma nova mensagem de Follow Up no pedido ", dados["NUMERO_PEDIDO"].ToString(),
                                                        "<br /><br />", dados["TEXTO_FOLLOW_UP"].ToString(), "<br /><br />",
                                                        dados["ASSINATURA"].ToString());

                            email.NUMERO_PEDIDO  = Convert.ToDecimal(dados["NUMERO_PEDIDO"]);
                            email.CLIENTE        = CLIENTE;
                            email.CODIGO_PRODUTO = "";
                            email.HISTORICO      = _OBS;
                            email.DESTINATARIOS  = DESTINATARIOS;
                            email.ID_CONTA_EMAIL = Convert.ToDecimal(dados["ID_CONTA_EMAIL"]);
                            email.FROM_ADDRESS   = dados["FROM_ADDRESS"].ToString();

                            email.Envia_Email_Posicao_Pedido();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, ID_USUARIO);
                throw ex;
            }
        }
示例#20
0
        private void gettableButton_Click(object sender, EventArgs e)
        {
            System.Data.Linq.Table <Employee> emp = db.GetTable <Employee>();
            dataGridView1.DataSource = emp;

            //System.Data.Linq.Table<Shipper> ship = db.GetTable<Shipper>();
            //dataGridView1.DataSource = ship;

            //System.Data.Linq.Table<Order> orders = db.GetTable<Order>();
            //dataGridView1.DataSource = orders;

            //...
        }
示例#21
0
        //newlogs和singlelogs参数二选一
        private void SendToZHIREN_SaveInLOCAL(System.Data.Linq.Table <TFTAttLog> table, LinkedList <TFTAttLog> newLogs, TFTAttLog singlelog)
        {
            //sqlCmd.ExecuteNonQuery();
            if (singlelog != null)
            {
                newLogs = new LinkedList <TFTAttLog>();
                newLogs.AddFirst(singlelog);
            }

            ZhiRenHandler.sendUserVerified(newLogs, response =>
            {
                if (response == null || response.Length == 0)
                {
                    return;
                }

                if (response[0].Code != null)
                {
                    //todo:调试模式下依然按照成功处理 等之人后端搞定之后去除isDebugging判断
                    if (!Log.isDebugging() && response[0].Code.Contains("error"))
                    {
                        Log.e("ZHIREN error" + response[0].ErrorMessage);
                        return;
                    }

                    lock (myObject)
                    {
                        foreach (var log in newLogs)
                        {
                            try
                            {
                                //success
                                table.InsertOnSubmit(log);
                                Log.d("SAVE:" + table.Contains(log));
                                table.Context.SubmitChanges();
                                Log.d("SAVED:" + log);
                            }
                            catch (Exception e)
                            {
                                Log.e(e.Message);
                                if (Log.isDebugging())
                                {
                                    throw new Exception("ERROR");
                                }
                            }
                        }
                    }
                }
            });
        }
示例#22
0
        public decimal Grava_Nota_Entrada(Dictionary <string, object> dados)
        {
            using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
            {
                System.Data.Linq.Table <TB_NOTA_ENTRADA> Entidade = ctx.GetTable <TB_NOTA_ENTRADA>();

                TB_NOTA_ENTRADA novo = new TB_NOTA_ENTRADA();

                novo.NUMERO_NFE = Convert.ToDecimal(dados["NUMERO_NFE"]);
                novo.SERIE_NFE  = dados["SERIE_NFE"].ToString();

                novo.DATA_EMISSAO_NFE = Convert.ToDateTime(dados["DATA_EMISSAO_NFE"]);
                novo.DATA_CHEGADA_NFE = Convert.ToDateTime(dados["DATA_CHEGADA_NFE"]);

                novo.CODIGO_FORNECEDOR = Convert.ToDecimal(dados["CODIGO_FORNECEDOR"]);
                novo.CODIGO_CP_NFE     = Convert.ToDecimal(dados["CODIGO_CP_NFE"]);
                novo.GERA_COBRANCA_NFE = Convert.ToDecimal(dados["GERA_COBRANCA_NFE"]);
                novo.CODIGO_CFOP_NFE   = dados["CODIGO_CFOP_NFE"].ToString();

                novo.BASE_ICMS_NFE       = Convert.ToDecimal(dados["BASE_ICMS_NFE"]);
                novo.VALOR_ICMS_NFE      = Convert.ToDecimal(dados["VALOR_ICMS_NFE"]);
                novo.BASE_ICMS_SUBS_NFE  = Convert.ToDecimal(dados["BASE_ICMS_SUBS_NFE"]);
                novo.VALOR_ICMS_SUBS_NFE = Convert.ToDecimal(dados["VALOR_ICMS_SUBS_NFE"]);
                novo.TOTAL_PRODUTOS_NFE  = Convert.ToDecimal(dados["TOTAL_PRODUTOS_NFE"]);
                novo.VALOR_FRETE_NFE     = Convert.ToDecimal(dados["VALOR_FRETE_NFE"]);
                novo.VALOR_SEGURO_NFE    = Convert.ToDecimal(dados["VALOR_SEGURO_NFE"]);
                novo.OUTRAS_DESP_NFE     = Convert.ToDecimal(dados["OUTRAS_DESP_NFE"]);
                novo.TOTAL_IPI_NFE       = Convert.ToDecimal(dados["TOTAL_IPI_NFE"]);
                novo.TOTAL_NFE           = Convert.ToDecimal(dados["TOTAL_NFE"]);
                novo.OBS_NFE             = dados["OBS_NFE"].ToString();
                novo.CANCELADA_NFE       = 0;
                novo.FRETE_NFE           = Convert.ToDecimal(dados["FRETE_NFE"]);
                novo.STATUS_NFE          = 1;

                novo.PESO_LIQUIDO_NFE = Convert.ToDecimal(dados["PESO_LIQUIDO_NFE"]);
                novo.PESO_BRUTO_NFE   = Convert.ToDecimal(dados["PESO_BRUTO_NFE"]);

                novo.CODIGO_EMITENTE_NFE = ID_EMPRESA;

                Entidade.InsertOnSubmit(novo);

                Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), ID_USUARIO);

                ctx.SubmitChanges();

                return(novo.NUMERO_SEQ_NFE);
            }
        }
示例#23
0
        public void GravaNovoStatus(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <Doran_Servicos_ORM.TB_STATUS_PEDIDO> Entidade = ctx.GetTable <Doran_Servicos_ORM.TB_STATUS_PEDIDO>();

                    Doran_Servicos_ORM.TB_STATUS_PEDIDO novo = new Doran_Servicos_ORM.TB_STATUS_PEDIDO();

                    novo.DESCRICAO_STATUS_PEDIDO = dados["DESCRICAO_STATUS_PEDIDO"].ToString();
                    novo.COR_STATUS                   = dados["COR_STATUS"].ToString();
                    novo.COR_FONTE_STATUS             = dados["COR_FONTE_STATUS"].ToString();
                    novo.NAO_IMPRIMIR_PEDIDO          = Convert.ToDecimal(dados["NAO_IMPRIMIR_PEDIDO"]);
                    novo.NAO_CANCELAR_PEDIDO          = Convert.ToDecimal(dados["NAO_CANCELAR_PEDIDO"]);
                    novo.STATUS_ESPECIFICO            = Convert.ToDecimal(dados["STATUS_ESPECIFICO"]);
                    novo.APARECE_NO_PORTAL_DE_CLIENTE = Convert.ToDecimal(dados["APARECE_NO_PORTAL_DE_CLIENTE"]);
                    novo.INICIO_FIM_DE_FASE           = Convert.ToDecimal(dados["INICIO_FIM_DE_FASE"]);

                    if (dados["SENHA_STATUS_PEDIDO"].ToString().Trim().Length > 0)
                    {
                        Th2_Seguranca.Principal sen = new Th2_Seguranca.Principal(Th2_Seguranca.classes.EncryptionAlgorithm.Des,
                                                                                  ConfigurationManager.AppSettings["ID_Sistema"]);

                        sen.CriptografaDados(dados["SENHA_STATUS_PEDIDO"].ToString().Trim());

                        novo.SENHA_STATUS_PEDIDO = sen.SenhaEncriptada_;
                    }
                    else
                    {
                        novo.SENHA_STATUS_PEDIDO = "";
                    }

                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#24
0
        private void InsertTemperatureSensor(string name, DateTime time, SensorType sensorType, bool isActive)
        {
            int coreSize = 5;

            CoreNumber [] coreIndex = new CoreNumber[coreSize];
            for (int i = 0; i < coreSize; ++i)
            {
                coreIndex[i] = CoreNumber.None;
            }

            if (this.CoreOneCheck.Checked)
            {
                coreIndex[1] = CoreNumber.Core_1;
            }
            if (this.CoreTwoCheck.Checked)
            {
                coreIndex[2] = CoreNumber.Core_2;
            }
            if (this.CoreThreeCheck.Checked)
            {
                coreIndex[3] = CoreNumber.Core_3;
            }
            if (this.CoreFourCheck.Checked)
            {
                coreIndex[4] = CoreNumber.Core_4;
            }
            for (byte i = 1; i < coreSize; ++i)
            {
                if (coreIndex[i] != CoreNumber.None)
                {
                    TempertaureSensorConfig tempConfig = new TempertaureSensorConfig()
                    {
                        Name       = name,
                        MadeTime   = time,
                        SensorType = sensorType,
                        IsActive   = isActive,
                        CoreIndex  = coreIndex[i]
                    };
                    System.Data.Linq.Table <BaseSensorConfig> table = dbManager.dc.BaseSensorConfigs;
                    table.InsertOnSubmit(tempConfig);
                }
            }
        }
示例#25
0
        private void loadData()
        {
            if (invoiceList.Count <= 0)
            {
                viewInvoiceBtn.Hide();
            }
            categoryList = DB.Categories;
            foreach (var item in categoryList)
            {
                categoryDropdown.AddItem(item.name);
            }

            productList = DB.Products;

            pquery = (from p in productList
                      where p.archived == false
                      orderby p.created_at
                      select p).Take(10);
            populateProducts();
        }
示例#26
0
        public void CadastraDireitosParaUmUsuario(decimal ID_USUARIO, decimal ID_USUARIO_ORIGINAL)
        {
            try
            {
                TB_USUARIO _usuario = new TB_USUARIO();

                ArrayList arr1 = arrayMenu;

                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    for (int i = 0; i < arr1.Count; i++)
                    {
                        var query = from linha in ctx.TB_ACESSO_COMERCIALs
                                    where linha.ID_USUARIO == ID_USUARIO &&
                                    linha.MENU == arr1[i].ToString()
                                    select linha;

                        if (query.Count() == 0)
                        {
                            System.Data.Linq.Table <TB_ACESSO_COMERCIAL> Entidade = ctx.GetTable <TB_ACESSO_COMERCIAL>();

                            TB_ACESSO_COMERCIAL novo = new TB_ACESSO_COMERCIAL();

                            novo.ID_USUARIO = ID_USUARIO;
                            novo.MENU       = arr1[i].ToString();

                            Entidade.InsertOnSubmit(novo);

                            Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), ID_USUARIO_ORIGINAL);
                        }
                    }

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, ID_USUARIO_ORIGINAL);
                throw ex;
            }
        }
        //***************************************************************************
        // Private Methods
        //
        private static bool CheckEntityIsAttached <T>(System.Data.Linq.DataContext ctx, T entity)
            where T : rsEntityBase, new()
        {
            // This is *SO* much simpler than the old way I was doing it, it's not even funny.
            System.Data.Linq.Table <T> entityTbl = ctx.GetTable <T>();
            return(entityTbl.GetOriginalEntityState(entity) != null);

            #region DEPRECIATED - This old method is a cluster, and has been deemed stupid, thanks to me realizing the context will give me the table for a given entity
            //// NOTE:  This is a fairly expensive method call, since it's performing
            ////   two seperate reflection lookups.

            //// Get the Type of the passed entity.
            //Type entityType = entity.GetType();
            //string entitiyTypeName = entityType.Name;

            //// Generally, the Linq2Sql table names are the 'plural' form of the entity names.
            //string srchName = (entitiyTypeName.EndsWith("y") ? entitiyTypeName.TrimEnd('y') + "ies" : entitiyTypeName + "s");

            //// Try and find the context's property that the passed entity was queried
            ////   from.  This method is *far* from fool-proof.
            //System.Reflection.PropertyInfo piTableProperty = ctx.GetType().GetProperty(srchName, bindingFlagsPublicInstance);
            //if (piTableProperty == null)
            //    throw new MemberAccessException(string.Format("Unable to locate property '{0}' in data context.", srchName));

            //// If we found the table property, we need to get the value of the property, and
            ////   locate the static 'GetOriginalEntityState' method.
            //object ctxTable = piTableProperty.GetValue(ctx, null);
            //Type ctxTableType = ctxTable.GetType();

            //System.Reflection.MethodInfo miGetEntityState = ctxTableType.GetMethod("GetOriginalEntityState", new Type[] { entityType });
            //if (miGetEntityState == null)
            //    throw new MemberAccessException(string.Format("Unable to locate 'GetOriginalEntityState' method in Type '{0}'.", ctxTableType.Name));

            //// If all of that worked out, we just have to call (invoke) the method, and pass
            ////   the supplied entity as a parameter.  If we get a 'null' back, then the entity
            ////   is not attached to the context.
            //object miReturn = miGetEntityState.Invoke(ctxTable, new object[] { entity });

            //return miReturn != null;
            #endregion
        }
示例#28
0
        public void GravaNovoConfig(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    System.Data.Linq.Table <TB_CONFIG_VENDA> Entidade = ctx.GetTable <TB_CONFIG_VENDA>();

                    TB_CONFIG_VENDA novo = new TB_CONFIG_VENDA();

                    novo.ID_CONFIGURACAO_VENDAS             = 1;
                    novo.ANALISAR_PRIMEIRA_COMPRA           = Convert.ToDecimal(dados["ANALISAR_PRIMEIRA_COMPRA"]);
                    novo.ANALISAR_INATIVIDADE               = Convert.ToDecimal(dados["ANALISAR_INATIVIDADE"]);
                    novo.ANALISAR_COND_PAGTO                = Convert.ToDecimal(dados["ANALISAR_COND_PAGTO"]);
                    novo.ANALISAR_MARGEM_VENDA              = Convert.ToDecimal(dados["ANALISAR_MARGEM_VENDA"]);
                    novo.ANALISAR_LIMITE_CREDITO            = Convert.ToDecimal(dados["ANALISAR_LIMITE_CREDITO"]);
                    novo.ANALISAR_INADIMPLENCIA             = Convert.ToDecimal(dados["ANALISAR_INADIMPLENCIA"]);
                    novo.DIAS_INATIVIDADE                   = Convert.ToDecimal(dados["DIAS_INATIVIDADE"]);
                    novo.LOGOTIPO_ORCAMENTO_VENDAS          = dados["LOGOTIPO_ORCAMENTO_VENDAS"].ToString();
                    novo.ANALISAR_FATURAMENTO_MINIMO        = Convert.ToDecimal(dados["ANALISAR_FATURAMENTO_MINIMO"]);
                    novo.VALOR_FATURAMENTO_MINIMO           = Convert.ToDecimal(dados["VALOR_FATURAMENTO_MINIMO"]);
                    novo.ANALISAR_IMPOSTO                   = Convert.ToDecimal(dados["ANALISAR_IMPOSTO"]);
                    novo.PRAZO_DIAS_ORCAMENTO               = Convert.ToDecimal(dados["PRAZO_DIAS_ORCAMENTO"]);
                    novo.NAO_GERAR_PEDIDO_HAVENDO_RESTRICAO = Convert.ToDecimal(dados["NAO_GERAR_PEDIDO_HAVENDO_RESTRICAO"]);
                    novo.TRABALHAR_COM_MARGEM_GROS          = Convert.ToDecimal(dados["TRABALHAR_COM_MARGEM_GROS"]);


                    Entidade.InsertOnSubmit(novo);

                    Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO"]));
                throw ex;
            }
        }
示例#29
0
 /// <summary>
 /// Extention method for a DataContext object that checks if the object exists in the DataContext
 /// </summary>
 /// <param name="user"></param>
 /// <returns>True or false</returns>
 public static bool IsValid <T>(this System.Data.Linq.Table <T> table, T item) where T : class, System.ComponentModel.INotifyPropertyChanged
 {
     try
     {
         if (null == table)
         {
             return(false);
         }
         if (null == item)
         {
             return(false);
         }
         else
         {
             return(table.Where(i => i == item).FirstOrDefault() != null);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#30
0
        public void GravaNovoAcesso(Dictionary <string, object> dados)
        {
            try
            {
                using (Doran_ERP_Servicos_DadosDataContext ctx = new Doran_ERP_Servicos_DadosDataContext())
                {
                    object[] MENU = (object[])dados["MENU"];

                    for (int i = 0; i < MENU.Length; i++)
                    {
                        var existe = (from linha in ctx.TB_ACESSO_COMERCIALs
                                      where (linha.ID_USUARIO == Convert.ToDecimal(dados["ID_USUARIO"]) &&
                                             linha.MENU == MENU[i].ToString())
                                      select linha).Any();

                        if (!existe)
                        {
                            System.Data.Linq.Table <TB_ACESSO_COMERCIAL> Entidade = ctx.GetTable <TB_ACESSO_COMERCIAL>();

                            TB_ACESSO_COMERCIAL novo = new TB_ACESSO_COMERCIAL();

                            novo.ID_USUARIO = Convert.ToDecimal(dados["ID_USUARIO"]);
                            novo.MENU       = MENU[i].ToString();

                            Entidade.InsertOnSubmit(novo);

                            Doran_Base.Auditoria_ERP_Servicos.Doran_Auditoria.Audita_Insert(ctx, novo, Entidade.ToString(), Convert.ToDecimal(dados["ID_USUARIO"]));
                        }
                    }

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                Doran_Base.Auditoria_ERP_Servicos.Doran_Exception.GravaErro(ex, Convert.ToDecimal(dados["ID_USUARIO_ORIGINAL"]));
                throw ex;
            }
        }
 public static void GetSettings()
 {
     Settings = DC.tblSettings;
     IndicatorSettings = DC.tblIndicatorSettings;
 }
示例#32
0
 public Customers()
 {
     _provider = new DataProvider();
     _customers = _provider.DataContext.Customers;
 }
        /// <summary>
        /// Installs the social intelligence.
        /// </summary>
        private void installSocialIntelligence()
        {
            RegisterTable(typeof(TableModels.System_RegisteredTables), 1);

            _registeredTables = (System.Data.Linq.Table<TableModels.System_RegisteredTables>)LoadTable(typeof(TableModels.System_RegisteredTables));
        }
        /// <summary>
        /// Registers the table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="version">The version.</param>
        public void RegisterTable(Type table, Int32 version)
        {
            if (_context == null) InitializeRepository();

            var metaTable = getMetaTable(table);
            String tablename = metaTable.TableName;

            IEnumerable<String> result = (IEnumerable<String>)_context.ExecuteQuery(typeof(String), string.Format(_INFORMATION_SCHEMA_TABLES, tablename), new object[] { });

            if (result.Count() == 0)
            {
                var sqlAsString = retrieveTableCreationSQL(metaTable);

                _context.ExecuteCommand(sqlAsString);

                TableModels.System_RegisteredTables newTable = new TableModels.System_RegisteredTables();
                newTable.Name = tablename;
                newTable.Version = version;
                _registeredTables.InsertOnSubmit(newTable);

                _context.SubmitChanges();
            }
            else
            {
                if (_registeredTables == null) _registeredTables = (System.Data.Linq.Table<TableModels.System_RegisteredTables>)LoadTable(typeof(TableModels.System_RegisteredTables));

                IEnumerable<TableModels.System_RegisteredTables> updatable = _registeredTables.Where(x => x.Version == version && x.Name == tablename);
                if(updatable.Count() == 0)
                {
                    DeregisterTable(table);
                    RegisterTable(table, version);
                }
            }
        }