private int BuscaIdVendedor(string EmailVendedor) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); int result = -1; try { FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("EMAIL", "System.String", "=", EmailVendedor)); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(RowRelatorio); if (FUNCIONARIOColl.Count > 0) { result = FUNCIONARIOColl[0].IDFUNCIONARIO; } this.Cursor = Cursors.Default; return(result); } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show("Erro Técnico: " + ex.Message); return(result); } }
private Boolean VerificaExisteFuncionario(int IDFUNCIONARIO) { Boolean result = false; try { RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", IDFUNCIONARIO.ToString())); FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(RowRelatorio); if (FUNCIONARIOColl.Count > 0) { result = true; } return(result); } catch (Exception ex) { MessageBox.Show("Erro ao Verificar se AMBIENTE Existe"); MessageBox.Show("Erro técnico: " + ex.Message); return(result); } }
private void GetFuncionario() { try { FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(null, "NOME"); cbFuncionario.DisplayMember = "NOME"; cbFuncionario.ValueMember = "IDFUNCIONARIO"; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy.NOME = ConfigMessage.Default.MsgDrop; FUNCIONARIOTy.IDFUNCIONARIO = -1; FUNCIONARIOColl.Add(FUNCIONARIOTy); Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity>(cbFuncionario.DisplayMember); FUNCIONARIOColl.Sort(comparer.Comparer); cbFuncionario.DataSource = FUNCIONARIOColl; cbFuncionario.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); } }
private void GetDropVendedor() { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(null, "NOME"); cbVendedor.DisplayMember = "NOME"; cbVendedor.ValueMember = "IDFUNCIONARIO"; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy.NOME = ConfigMessage.Default.MsgDrop; FUNCIONARIOTy.IDFUNCIONARIO = -1; FUNCIONARIOColl.Add(FUNCIONARIOTy); Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity>(cbVendedor.DisplayMember); FUNCIONARIOColl.Sort(comparer.Comparer); cbVendedor.DataSource = FUNCIONARIOColl; this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show("Erro técnico: " + ex.Message); } }
private void GetDropFuncionario() { FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); FUNCIONARIOCollection FuncionarioColl = FUNCIONARIOP.ReadCollectionByParameter(null, "NOME"); cbFuncionario.DisplayMember = "NOME"; cbFuncionario.ValueMember = "IDFUNCIONARIO"; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy.NOME = ConfigMessage.Default.MsgDrop; FUNCIONARIOTy.IDFUNCIONARIO = -1; FuncionarioColl.Add(FUNCIONARIOTy); Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <FUNCIONARIOEntity>(cbFuncionario.DisplayMember); FuncionarioColl.Sort(comparer.Comparer); cbFuncionario.DataSource = FuncionarioColl; }
private Boolean VerificaCPFExistNew(string CPF) { Boolean result = false; if (CPF != " . . -") { RowsFiltro FiltroProfileCNPJ = new RowsFiltro("CPF", "System.String", "=", CPF); RowsFiltroCollection FiltroCNPJ = new RowsFiltroCollection(); FUNCIONARIOCollection FUNCIONARIOCollCPF = new FUNCIONARIOCollection(); FiltroCNPJ.Insert(0, FiltroProfileCNPJ); FUNCIONARIOCollCPF = FUNCIONARIOP.ReadCollectionByParameter(FiltroCNPJ); if (FUNCIONARIOCollCPF.Count > 0) { result = true; } } return(result); }
private static FUNCIONARIOCollection ExecuteReader(ref FUNCIONARIOCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new FUNCIONARIOCollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
private void PreencheGrid() { try { // Primeiro, criando a DataTable que vai alimentar a grid. DataTable dt = new DataTable("nomeTabela"); //criando as Colunas dt.Columns.Add("HORA: "); //Busca os funcionarios da agenda FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("FLAGEXIBIRAGENDA", "System.String", "=", "S")); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(RowRelatorio); NumFuncionario = FUNCIONARIOColl.Count; foreach (var item in FUNCIONARIOColl) { dt.Columns.Add(item.NOME); } ////Criando as Linhas int Hora = 8; for (int i = 0; i < 17; i++) { dt.Rows.Add(Hora.ToString().PadLeft(2, '0') + ":00"); Hora++; } // Setando a fonte de dados da DataGrid apontando pra DataTable que criamos acima. dataGridViewAgenda2.DataSource = dt; // Agora criando os TableStyles para cada coluna existente na DataTable! DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = dt.TableName; int j = 1; foreach (DataColumn column in dt.Columns) { dataGridViewAgenda2.Columns[0].Width = 40; dataGridViewAgenda2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; if (j <= (dt.Columns.Count - 1)) { dataGridViewAgenda2.Columns[j].Width = 150; dataGridViewAgenda2.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable; } DataGridTextBoxColumn dtgColumn = new DataGridTextBoxColumn(); dtgColumn.MappingName = dtgColumn.HeaderText = column.ColumnName; tableStyle.GridColumnStyles.Add(dtgColumn); j++; } //Loop no Grid for (int i = 0; i < NumFuncionario; i++) { LoopGrid(i); } } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); } }
public FUNCIONARIOCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; FUNCIONARIOCollection collection = null; string strSqlCommand = String.Empty; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM FUNCIONARIO WHERE ("; ArrayList _rowsFiltro = new ArrayList(); RowsFiltro.ForEach(delegate(RowsFiltro i) { string[] item = { i.Condicao.ToString(), i.Campo.ToString(), i.Tipo.ToString(), i.Operador.ToString(), i.Valor.ToString() }; _rowsFiltro.Add(item); }); int _count = 1; foreach (string[] item in _rowsFiltro) { strSqlCommand += "(" + item[1] + " " + item[3]; switch (item[2]) { case ("System.String"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int16"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int32"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int64"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Double"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Decimal"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Float"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Byte"): strSqlCommand += " " + item[4] + ")"; break; case ("System.SByte"): strSqlCommand += " " + item[4] + ")"; break; case ("System.Char"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.DateTime"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Guid"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Boolean"): strSqlCommand += " " + item[4] + ")"; break; } if (_rowsFiltro.Count > 1) { if (_count < _rowsFiltro.Count) { strSqlCommand += " " + item[0] + " "; } _count++; } } strSqlCommand += ") order by " + FieldOrder; } else { strSqlCommand = "SELECT * FROM FUNCIONARIO order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM FUNCIONARIO order by " + FieldOrder; } //Verificando a existência de um transação if (dbTransaction != null) { if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand(strSqlCommand, dbCnn); dbCommand.CommandType = CommandType.Text; dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = new FbConnection(connectionString); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand(strSqlCommand, dbCnn); dbCommand.CommandType = CommandType.Text; dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } collection = ExecuteReader(ref collection, ref dataReader, dbCommand); if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction == null) { dbCommand.Transaction.Commit(); dbCnn.Close(); } return(collection); } catch (Exception ex) { // Deleta reader if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction != null) { this.RollbackTransaction(); } else { if (dbCommand.Transaction != null) { dbCommand.Transaction.Rollback(); } if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } throw ex; } }
public void CriaArquivoCSV() { try { System.IO.StreamWriter sw = null; try { //Pega o caminho do arquivo string caminho = BmsSoftware.ConfigSistema1.Default.PathInstall + @"\sicronizacao.csv"; //Cria um StreamWriter no local sw = new System.IO.StreamWriter(caminho, false, System.Text.Encoding.GetEncoding(1252)); //Dados de Status STATUSCollection STATUSColl = new STATUSCollection(); STATUSColl = STATUSP.ReadCollectionByParameter(null); foreach (var item in STATUSColl) { //Dados de Status string IDSTATUS = Convert.ToInt32(item.IDSTATUS).ToString().PadLeft(6, '0'); string IDGRUPOSTATUS = "000000"; if (ValidacoesLibrary.ValidaTipoInt32(item.IDGRUPOSTATUS.ToString())) { IDGRUPOSTATUS = Convert.ToInt32(item.IDGRUPOSTATUS).ToString().PadLeft(6, '0'); string NOMESTATUS = item.NOME; //grava dados de Status sw.WriteLine("STA" + ";" + IDSTATUS + ";" + IDGRUPOSTATUS + ";" + NOMESTATUS); } } //Categoria Produto GRUPOCATEGORIACollection GRUPOCATEGORIAColl = new GRUPOCATEGORIACollection(); GRUPOCATEGORIAColl = GRUPOCATEGORIAP.ReadCollectionByParameter(null); foreach (var item2 in GRUPOCATEGORIAColl) { //Dados de Categoria Produto string IDGRUPOCATEGORIA = Convert.ToInt32(item2.IDGRUPOCATEGORIA).ToString().PadLeft(6, '0'); string NOMEGRUPOCATEGORIA = item2.NOME; //grava dados de Categoria Produto sw.WriteLine("GSA" + ";" + IDGRUPOCATEGORIA + ";" + NOMEGRUPOCATEGORIA); } //Categoria Produto UNIDADECollection UNIDADEColl = new UNIDADECollection(); UNIDADEColl = UNIDADEP.ReadCollectionByParameter(null); foreach (var item3 in UNIDADEColl) { //Dados Unidade string IDUNIDADE = Convert.ToInt32(item3.IDUNIDADE).ToString().PadLeft(6, '0'); string NOMEUNIDADE = item3.NOME; //grava dados da Unidade sw.WriteLine("UNI" + ";" + IDUNIDADE + ";" + NOMEUNIDADE); } //Dados da Marca MARCACollection MARCAColl = new MARCACollection(); MARCAColl = MARCAP.ReadCollectionByParameter(null); foreach (var item5 in MARCAColl) { //Dados MARCA string IDMARCA = Convert.ToInt32(item5.IDMARCA).ToString().PadLeft(6, '0'); string NOMEMARCA = item5.NOME; //grava dados da MARCA sw.WriteLine("MAR" + ";" + IDMARCA + ";" + NOMEMARCA); } //Cor CORCollection CORColl = new CORCollection(); CORColl = CORP.ReadCollectionByParameter(null); foreach (var item9 in CORColl) { //Dados Cor string IDCOR = Convert.ToInt32(item9.IDCOR).ToString().PadLeft(6, '0'); string NOMECOR = item9.NOME; //grava dados da Cor sw.WriteLine("COR" + ";" + IDCOR + ";" + NOMECOR); } //Ambiente AMBIENTECollection AMBIENTEColl = new AMBIENTECollection(); AMBIENTEColl = AMBIENTEP.ReadCollectionByParameter(null); foreach (var item8 in AMBIENTEColl) { //Dados AMBIENTE string IDAMBIENTE = Convert.ToInt32(item8.IDAMBIENTE).ToString().PadLeft(6, '0'); string NOMEAMBIENTE = item8.NOME; //grava dados do Ambiente sw.WriteLine("AMB" + ";" + IDAMBIENTE + ";" + NOMEAMBIENTE); } //Vendedor FUNCIONARIOCollection FUNCIONARIOColl = new FUNCIONARIOCollection(); FUNCIONARIOColl = FUNCIONARIOP.ReadCollectionByParameter(null); foreach (var item10 in FUNCIONARIOColl) { //Dados FUNCIONARIO string IDFUNCIONARIO = Convert.ToInt32(item10.IDFUNCIONARIO).ToString().PadLeft(6, '0'); string NOMEFUNCINAROIO = item10.NOME; string ENDERECO = item10.ENDERECO; string CIDADE = item10.CIDADE; string UF = item10.UF; string CEP = item10.CEP; string BAIRRO = item10.BAIRRO; string CPF = item10.CPF; string EMAIL = item10.EMAIL; string TELEFONE1 = item10.TELEFONE1; string TELEFONE2 = item10.TELEFONE2; string FUNCAO = item10.FUNCAO; //grava dados do FUNCIONARIO sw.WriteLine("FUNC" + ";" + IDFUNCIONARIO + ";" + NOMEFUNCINAROIO + ";" + ENDERECO + ";" + CIDADE + ";" + UF + ";" + CEP + ";" + BAIRRO + ";" + CPF + ";" + EMAIL + ";" + TELEFONE1 + ";" + TELEFONE2 + ";" + FUNCAO); } //Cadastro de Produto PRODUTOSCollection PRODUTOSColl = new PRODUTOSCollection(); PRODUTOSColl = PRODUTOSP.ReadCollectionByParameter(null); foreach (var item4 in PRODUTOSColl) { //Dados Produto string IDPRODUTO = Convert.ToInt32(item4.IDPRODUTO).ToString().PadLeft(6, '0'); string NOMEPRODUTO = item4.NOMEPRODUTO; string CODPRODUTOFORNECEDOR = item4.CODPRODUTOFORNECEDOR.ToString().PadLeft(10, '0'); string VALORVENDA1 = Convert.ToDecimal(item4.VALORVENDA1).ToString("n2"); string IDUNIDADE = "000000"; if (ValidacoesLibrary.ValidaTipoInt32(item4.IDUNIDADE.ToString())) { IDUNIDADE = item4.IDUNIDADE.ToString().PadLeft(6, '0'); } string IDGRUPOCATEGORIA = "000000"; if (ValidacoesLibrary.ValidaTipoInt32(item4.IDGRUPOCATEGORIA.ToString())) { IDGRUPOCATEGORIA = item4.IDGRUPOCATEGORIA.ToString().PadLeft(6, '0'); } string IDSTATUS = "000000"; if (ValidacoesLibrary.ValidaTipoInt32(item4.IDSTATUS.ToString())) { IDSTATUS = item4.IDSTATUS.ToString().PadLeft(6, '0'); } string IDMARCA = "000000"; if (ValidacoesLibrary.ValidaTipoInt32(item4.IDMARCA.ToString())) { IDMARCA = item4.IDMARCA.ToString().PadLeft(6, '0'); } string FLAGINATIVO = item4.FLAGINATIVO; //grava dados da Produto sw.WriteLine("PRO" + ";" + IDPRODUTO + ";" + NOMEPRODUTO + ";" + CODPRODUTOFORNECEDOR + ";" + VALORVENDA1 + ";" + IDUNIDADE + ";" + IDGRUPOCATEGORIA + ";" + IDSTATUS + ";" + IDMARCA + ";" + FLAGINATIVO); } //Cadastro de Cliente CLIENTECollection CLIENTEColl = new CLIENTECollection(); CLIENTEColl = CLIENTEP.ReadCollectionByParameter(null); foreach (var item6 in CLIENTEColl) { string IDCLIENTE = Convert.ToInt32(item6.IDCLIENTE).ToString().PadLeft(6, '0'); string NOMECLIENTE = item6.NOME; string TELEFONE1 = item6.TELEFONE1; string TELEFONE2 = item6.TELEFONE2; string CPF = item6.CPF; string CNPJ = item6.CNPJ; string IE = item6.IE; string ENDERECO1 = item6.ENDERECO1; string NUMEROENDER = item6.NUMEROENDER; string COMPLEMENTO1 = item6.COMPLEMENTO1; string BAIRRO1 = item6.BAIRRO1; string CEP1 = item6.CEP1; string COD_MUN_IBGE = item6.COD_MUN_IBGE.ToString(); string EMAILCLIENTE = item6.EMAILCLIENTE; string FLAGBLOQUEADO = item6.FLAGBLOQUEADO; sw.WriteLine("CLI" + ";" + IDCLIENTE + ";" + NOMECLIENTE + ";" + TELEFONE1 + ";" + TELEFONE2 + ";" + CPF + ";" + CNPJ + ";" + IE + ";" + ENDERECO1 + ";" + NUMEROENDER + ";" + COMPLEMENTO1 + ";" + BAIRRO1 + ";" + CEP1 + ";" + COD_MUN_IBGE + ";" + EMAILCLIENTE + ";" + FLAGBLOQUEADO); } sw.Close(); //Dados da Empresa EMPRESAtY = EMPRESAP.Read(1); //faz o upload do arquivo sicronizado if (File.Exists(caminho)) { Upload(caminho, Util.RetiraLetras(EMPRESAtY.CNPJCPF)); } else { MessageBox.Show("Arquivo: " + caminho + " Não Localizado!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { //Fechar stream SEMPRE sw.Close(); } } catch (Exception ex) { MessageBox.Show("Erro ao criar arquivo de sicronização!"); MessageBox.Show("Erro técnico: " + ex.Message); } }