140 lines
5.4 KiB
C#
140 lines
5.4 KiB
C#
// See https://aka.ms/new-console-template for more information
|
|
/*using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data.SqlClient;
|
|
using System.Threading.Tasks;*/
|
|
using System;
|
|
using System.Data.OleDb;
|
|
using System.Diagnostics;
|
|
|
|
internal class Download_BD
|
|
{
|
|
static void Main()
|
|
{
|
|
string nome_entrada;
|
|
string strQRY;
|
|
|
|
nome_entrada = "aaa";
|
|
|
|
Acessar_BD();
|
|
|
|
Console.WriteLine("Programa encerrado.");
|
|
return;
|
|
Environment.Exit(0);
|
|
}
|
|
static void Acessar_BD()
|
|
{
|
|
int cont_result;
|
|
string prt_str;
|
|
int n_cli;
|
|
bool teste_par;
|
|
string teste_cli = "";
|
|
|
|
List<string> lt_cli = new List<string>();
|
|
List<double> lt_codcli = new List<double>();
|
|
|
|
|
|
|
|
string com_usuario;
|
|
string com_categ;
|
|
string com_assunto;
|
|
string com_texto;
|
|
string com_cli;
|
|
Double dat_com;
|
|
Boolean finaliza;
|
|
Double com_codcli;
|
|
var usuario = new Dictionary<string, string>();
|
|
var categ = new Dictionary<int, string>();
|
|
|
|
//loop para adicionar usuarios a partir de nossa planilha de cadastro
|
|
OleDbConnection conUSU = new("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_outros.accdb;Jet OLEDB:Database Password=gds21");
|
|
conUSU.Open();
|
|
OleDbCommand tbUsu = new("SELECT * FROM Gabarito_contatos", conUSU);
|
|
OleDbDataReader reUSU = tbUsu.ExecuteReader();
|
|
|
|
while (reUSU.Read())
|
|
{
|
|
usuario[reUSU["Cod_maquina"].ToString()] = reUSU["Nome_usuario"].ToString();
|
|
}
|
|
conUSU.Close();
|
|
|
|
com_usuario = usuario[Environment.MachineName.ToString()];
|
|
|
|
//categ[0] = "VERIFICAR HISTORICO";
|
|
categ[1] = "CONTRATACAO";
|
|
categ[2] = "CURTO PRAZO";
|
|
categ[3] = "INADIMPLENCIA";
|
|
categ[4] = "MIGRACAO";
|
|
categ[5] = "REDUCAO DE CUSTOS/DISTRIBUIDORAS";
|
|
categ[6] = "RELACIONAMENTO (Tel./Meet)";
|
|
categ[7] = "REUNIÃO PRESENCIAL";
|
|
categ[8] = "OUTROS";
|
|
|
|
com_cli = lt_cli[n_cli - 1];
|
|
com_codcli = lt_codcli[n_cli - 1];
|
|
|
|
finaliza = false;
|
|
while (!finaliza)
|
|
{
|
|
Console.WriteLine("\nCliente {0} selecionado. Escolha a categoria do contato:", com_cli);
|
|
foreach (KeyValuePair<int, string> item in categ)
|
|
{
|
|
Console.WriteLine("{0,-4} | {1,-15}", item.Key, item.Value);
|
|
cont_result++;
|
|
}
|
|
|
|
teste_par = Int32.TryParse(Console.ReadKey(true).KeyChar.ToString(), out n_cli);
|
|
while (!teste_par || n_cli > categ.Count)
|
|
{
|
|
Console.WriteLine("Numero invalido");
|
|
teste_par = Int32.TryParse(Console.ReadKey(true).KeyChar.ToString(), out n_cli);
|
|
}
|
|
com_categ = categ[n_cli];
|
|
|
|
Console.WriteLine("\nCategoria '{0}' selecionada. \nDigite o assunto do contato e pressione ENTER:", com_categ);
|
|
com_assunto = Console.ReadLine();
|
|
|
|
Console.WriteLine("\nDigite o texto do contato e pressione ENTER:");
|
|
com_texto = Console.ReadLine();
|
|
|
|
dat_com = DateTime.Today.ToOADate();
|
|
|
|
Console.WriteLine("\n{0,-10} | {1,-15}", "Usuario", com_usuario);
|
|
Console.WriteLine("{0,-10} | {1,-15}", "Data", DateOnly.FromDateTime(DateTime.FromOADate(dat_com)));
|
|
Console.WriteLine("{0,-10} | {1,-15}", "Cliente", com_cli);
|
|
Console.WriteLine("{0,-10} | {1,-15}", "Categoria", com_categ);
|
|
Console.WriteLine("{0,-10} | {1,-15}", "Assunto", com_assunto);
|
|
Console.WriteLine("{0,-10} | {1,-15}", "Texto", com_texto);
|
|
|
|
Console.WriteLine("\nDeseja finalizar [S/n] ? Digite n para repetir os passos após a escolha do cliente.\n");
|
|
if (Console.ReadKey(true).KeyChar.ToString().ToUpper() == "S")
|
|
{
|
|
finaliza = true;
|
|
string aux_SQL;
|
|
aux_SQL = "INSERT INTO Contatos (Data, usuario, Cod_Smart_cliente, categoria, assunto, texto)";
|
|
aux_SQL += " VALUES (" + dat_com + ",\"" + com_usuario + "\"," + com_codcli + ",\"" + com_categ + "\",\"" + com_assunto + "\",\"" + com_texto + "\"";
|
|
aux_SQL += ")";
|
|
conn.Open();
|
|
OleDbCommand tbContat = new(aux_SQL, conn);
|
|
tbContat.ExecuteNonQuery();
|
|
conn.Close();
|
|
Console.WriteLine("\nCONTATO CADASTRADO COM SUCESSO\n");
|
|
Console.WriteLine("\n-------------------------------------------------------------------------------------------------");
|
|
Console.WriteLine("Reinicio");
|
|
Console.WriteLine("-------------------------------------------------------------------------------------------------\n");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("\nDica: utilizar as setas para cima e baixo caso precise preencher novamente.\n");
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|