public static void OnThreadException(object sender, ThreadExceptionEventArgs t) { var e = t.Exception; new Log().Add("EXCEPTIONS", e.GetBaseException() + Environment.NewLine + "######################################", Log.LogType.fatal); if (Support.CheckForInternetConnection()) { object obj = new { token = Program.TOKEN, usuario = Settings.Default.user_name + " " + Settings.Default.user_lastname, empresa = Settings.Default.empresa_razao_social, name = e.GetType().Name, error = e.ToString(), message = e.Message }; new RequestApi().URL(Program.URL_BASE + "/api/error").Content(obj, Method.POST).Response(); } Error.ErrorMessage = e.Message; var result = new Error(); // Exit the program when the user clicks Abort. if (result.ShowDialog() == DialogResult.OK) { Application.Exit(); } }
/// <summary> /// Realiza cadastro nota salva - tecnospeed /// </summary> private void CadastroNotaSalva() { if (!Support.CheckForInternetConnection()) { return; } if (string.IsNullOrEmpty(IniFile.Read("encodeNS", "DEV"))) { var cnpjLimpo = Settings.Default.empresa_cnpj.Replace("-", "").Replace(".", "").Replace("/", ""); dynamic obj = new { corporate_name = Settings.Default.empresa_razao_social, name = Settings.Default.empresa_nome_fantasia, cnpj = cnpjLimpo, email = Settings.Default.user_email, password = "******" }; if (cnpjLimpo != "00000000000000") { new RequestApi() .URL( "https://app.notasegura.com.br/api/users/?softwarehouse=f278b338e853ed759383cca7da6dcf22e1c61301") .Content(obj, Method.POST) .AddHeader("Accept", "application/json") .AddHeader("Content-Type", "application/x-www-form-urlencoded") .Response(); IniFile.Write("encodeNS", Validation.Base64Encode($"{Settings.Default.empresa_email}:123@emiplus"), "DEV"); } } }
public Sync() { InitializeComponent(); if (Support.CheckForInternetConnection()) { Eventos(); } }
private void Eventos() { Load += (s, e) => { Hide(); }; Shown += (s, e) => { timer1.Enabled = true; timer1.Interval = 600000; if (Support.CheckForInternetConnection()) { f.SendNota(); timer1.Start(); } }; timer1.Tick += (s, e) => { if (Support.CheckForInternetConnection()) { if (!Home.syncActive) { backWork.RunWorkerAsync(); IniFile.Write("Sync", "true", "APP"); Home.syncActive = true; } } timer1.Stop(); }; backWork.DoWork += async(s, e) => { await f.StartSync(); }; backWork.RunWorkerCompleted += (s, e) => { new Log().Add("SYNC", "Sincronização", Log.LogType.fatal); Home.syncActive = false; IniFile.Write("Sync", "false", "APP"); timer1.Start(); }; }
private void Eventos() { Load += (s, e) => { if (File.Exists("C:\\Sincronizador\\Sincronizador.exe")) { if (Process.GetProcessesByName("Sincronizador").Length == 0) { System.Diagnostics.Process.Start("C:\\Sincronizador\\Sincronizador.exe"); } } if (Support.CheckForInternetConnection()) { if (IniFile.Read("Update", "APP") == "true" && Directory.Exists(IniFile.Read("Path", "LOCAL") + "\\Update")) { RunUpdate = true; WindowState = FormWindowState.Normal; } } backWorker.RunWorkerAsync(); }; backWorker.DoWork += (s, e) => { if (RunUpdate) { var version = new Update().GetVersionWebTxt(); IniFile.Write("Version", version, "APP"); // Atualiza a versão no INI new CreateTables().CheckTables(); // Atualiza o banco de dados } }; backWorker.RunWorkerCompleted += (s, e) => { var f = new Login(); f.Show(); Hide(); }; }
private void timer_tick() { if (Support.CheckForInternetConnection()) { if (!string.IsNullOrEmpty(Settings.Default.user_dbhost)) { if (!Home.syncActive) { if (IniFile.Read("syncAuto", "APP") == "True") { backWork.RunWorkerAsync(); Home.syncActive = true; } } } } timer1.Stop(); }
public static void SetPermissions() { if (Support.CheckForInternetConnection()) { var jo = new RequestApi().URL($"{URL_BASE}/api/permissions/{TOKEN}/{Settings.Default.user_id}") .Content().Response(); if (jo["error"] != null && jo["error"].ToString() != "") { Alert.Message("Opss", jo["error"].ToString(), Alert.AlertType.error); return; } if (string.IsNullOrEmpty(jo["telas"]?.ToString())) { UserPermissions.Add(new { all = 1 }); } else { foreach (dynamic item in jo["telas"]) { UserPermissions.Add(new { Key = item.Name, Value = item.Value.ToString() }); } } var data = JsonConvert.SerializeObject(UserPermissions); //gravando informação em um arquivo na pasta raiz do executavel var writerJson = File.CreateText($".\\P{Settings.Default.user_id}.json"); writerJson.Write(data); writerJson.Flush(); writerJson.Dispose(); } else { if (File.Exists($".\\P{Settings.Default.user_id}.json")) { var dataJson = File.ReadAllText($".\\P{Settings.Default.user_id}.json", Encoding.UTF8); UserPermissions = JsonConvert.DeserializeObject <ArrayList>(dataJson); } } }
private void Eventos() { Load += (s, e) => { if (Support.CheckForInternetConnection()) { SendNota(); if (!string.IsNullOrEmpty(Settings.Default.user_dbhost)) { timer1.Start(); } } }; timer1.Tick += (s, e) => { timer_tick(); }; backWork.DoWork += async(s, e) => { new Log().Add("SYNC", "Sincronização iniciada", Log.LogType.info); if (sync_start == 0) { await StartSync(); } }; backWork.RunWorkerCompleted += (s, e) => { new Log().Add("SYNC", "Sincronização concluída", Log.LogType.info); timer1.Enabled = true; timer1.Start(); Home.syncActive = false; }; }
private void LoadTable(DataGridView Table) { SetHeadersTable(GridLista); Table.Rows.Clear(); if (Support.CheckForInternetConnection()) { var idUser = Settings.Default.user_sub_user != 0 ? Settings.Default.user_sub_user : Settings.Default.user_id; var jo = new RequestApi().URL($"{Program.URL_BASE}/api/empresas/{Program.TOKEN}/{idUser}").Content() .Response(); if (jo["error"] != null && jo["error"].ToString() != "") { Alert.Message("Opss", jo["error"].ToString(), Alert.AlertType.error); return; } foreach (dynamic item in jo) { if (item.Value.id_unique != Settings.Default.empresa_unique_id) { Table.Rows.Add( item.Value.id_unique, item.Value.razao_social, item.Value.cnpj ); } } } else { Alert.Message("Opps", "Você precisa estar conectado a internet.", Alert.AlertType.error); } Table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
private void KeyDowns(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Escape: Close(); break; case Keys.F9: if (UserPermission.SetControlVisual(btnCFeSat, pictureBox6, "fiscal_emissaocfe")) { return; } Cfe(); break; case Keys.F10: if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } if (UserPermission.SetControlVisual(btnNfe, pictureBox4, "fiscal_emissaonfe")) { return; } Nfe(); break; case Keys.F11: new PedidoImpressao().Print(idPedido); e.SuppressKeyPress = true; break; } }
private void LoadEmpresas() { if (Support.CheckForInternetConnection()) { var idUser = Settings.Default.user_sub_user != 0 ? Settings.Default.user_sub_user : Settings.Default.user_id; var jo = new RequestApi().URL($"{Program.URL_BASE}/api/empresas/{Program.TOKEN}/{idUser}").Content() .Response(); if (jo["error"] != null && jo["error"].ToString() != "") { Alert.Message("Opss", jo["error"].ToString(), Alert.AlertType.error); return; } var data = new ArrayList { new { Id = "0", Nome = "SELECIONE A EMPRESA" } }; foreach (dynamic item in jo) { if (item.Value.id_unique != Settings.Default.empresa_unique_id) { string id = item.Value.id_unique.ToString(); string nome = item.Value.razao_social.ToString(); data.Add(new { Id = id, Nome = nome }); } } Empresas.DataSource = data; Empresas.DisplayMember = "Nome"; Empresas.ValueMember = "Id"; } else { Alert.Message("Opps", "Você precisa estar conectado a internet.", Alert.AlertType.error); } }
private void LoginAsync() { if (string.IsNullOrEmpty(email.Text) || string.IsNullOrEmpty(password.Text)) { Alert.Message("Opps", "Preencha todos os campos.", Alert.AlertType.error); return; } if (Support.CheckForInternetConnection()) { dynamic obj = new { token = Program.TOKEN, email = email.Text, password = password.Text, id_empresa = IniFile.Read("idEmpresa", "APP") }; var jo = new RequestApi().URL(Program.URL_BASE + "/api/user").Content(obj, Method.POST).Response(); if (jo["error"] != null && jo["error"].ToString() != "") { Alert.Message("Opss", jo["error"].ToString(), Alert.AlertType.error); return; } Settings.Default.login_remember = remember.Checked; Settings.Default.login_email = email.Text; if (Validation.ConvertToInt32(jo["user"]["status"]) <= 0) { Alert.Message("Opss", "Você precisa ativar sua conta, acesse seu e-mail!", Alert.AlertType.info); return; } if (Validation.ConvertToInt32(jo["user"]["plan_status"]) <= 0) { if (Validation.ConvertToInt32(jo["user"]["plan_trial"]) <= 0) { Alert.Message("Opss", "Seus dias de avaliação acabou, contrate um plano.", Alert.AlertType.info); return; } } Settings.Default.user_id = Validation.ConvertToInt32(jo["user"]["id"]); Settings.Default.user_name = jo["user"]["name"].ToString(); Settings.Default.user_lastname = jo["user"]["lastname"].ToString(); Settings.Default.user_document = jo["user"]["document"].ToString(); Settings.Default.user_thumb = jo["user"]["thumb"].ToString(); Settings.Default.user_email = jo["user"]["email"].ToString(); Settings.Default.user_password = password.Text; Settings.Default.user_sub_user = Validation.ConvertToInt32(jo["user"]["sub_user"]); Settings.Default.user_cell = jo["user"]["cell"]?.ToString(); Settings.Default.user_level = Validation.ConvertToInt32(jo["user"]["level"]); Settings.Default.user_status = Validation.ConvertToInt32(jo["user"]["status"]); Settings.Default.user_plan_id = jo["user"]["plan_id"].ToString(); Settings.Default.user_plan_trial = Validation.ConvertToInt32(jo["user"]["plan_trial"]); Settings.Default.user_plan_status = Validation.ConvertToInt32(jo["user"]["plan_status"]); Settings.Default.user_plan_recorrencia = jo["plano"]["recorrencia"].ToString(); Settings.Default.user_plan_fatura = jo["plano"]["proxima_fatura"].ToString(); Settings.Default.user_comissao = Validation.ConvertToInt32(jo["user"]["comissao"]); Settings.Default.user_dbhost = jo["user"]["db_host"].ToString(); Settings.Default.empresa_id = Validation.ConvertToInt32(jo["empresa"]["id"]); Settings.Default.empresa_unique_id = jo["empresa"]["id_unique"].ToString(); Settings.Default.empresa_logo = jo["empresa"]["logo"].ToString(); Settings.Default.empresa_razao_social = jo["empresa"]["razao_social"].ToString(); Settings.Default.empresa_nome_fantasia = jo["empresa"]["nome_fantasia"].ToString(); Settings.Default.empresa_cnpj = jo["empresa"]["cnpj"].ToString(); Settings.Default.empresa_email = jo["empresa"]["email"].ToString(); Settings.Default.empresa_inscricao_estadual = jo["empresa"]["inscricao_estadual"].ToString(); Settings.Default.empresa_inscricao_municipal = jo["empresa"]["inscricao_municipal"].ToString(); Settings.Default.empresa_telefone = jo["empresa"]["telefone"].ToString(); Settings.Default.empresa_rua = jo["empresa"]["rua"].ToString(); Settings.Default.empresa_cep = jo["empresa"]["cep"].ToString(); Settings.Default.empresa_nr = jo["empresa"]["nr"].ToString(); Settings.Default.empresa_cidade = jo["empresa"]["cidade"].ToString(); Settings.Default.empresa_bairro = jo["empresa"]["bairro"].ToString(); Settings.Default.empresa_estado = jo["empresa"]["estado"].ToString(); Settings.Default.empresa_ibge = jo["empresa"]["ibge"].ToString(); Settings.Default.empresa_nfe_ultnfe = jo["empresa"]["ultnfe"].ToString(); Settings.Default.empresa_nfe_serienfe = jo["empresa"]["serienfe"].ToString(); Settings.Default.empresa_nfe_servidornfe = Validation.ConvertToInt32(jo["empresa"]["servidornfe"]); Settings.Default.empresa_crt = jo["empresa"]["crt"].ToString(); Settings.Default.empresa_servidornfse = Validation.ConvertToInt32(jo["empresa"]["servidornfse"]); Settings.Default.empresa_rps = jo["empresa"]["rps"].ToString(); Settings.Default.empresa_serienfse = jo["empresa"]["serienfse"].ToString(); Settings.Default.empresa_codigoitemnfse = jo["empresa"]["codigoitemnfse"].ToString(); Settings.Default.empresa_codigotributacaonfse = jo["empresa"]["codigotributacaonfse"].ToString(); Settings.Default.empresa_aliquotanfse = Validation.ConvertToDouble(jo["empresa"]["aliquotanfse"]); Settings.Default.empresa_calculanfse = Validation.ConvertToInt32(jo["empresa"]["calculanfse"]); Settings.Default.empresa_issretido = Validation.ConvertToInt32(jo["empresa"]["issretido"]); Settings.Default.empresa_infadnfse = jo["empresa"]["infadnfse"].ToString(); Settings.Default.Save(); //var usuarios = new Usuarios(); int idUser = Validation.ConvertToInt32(jo["user"]["id"]); _mUsuarios = _mUsuarios.FindByUserId(idUser).FirstOrDefault <Usuarios>(); if (_mUsuarios == null) { _mUsuarios = new Usuarios(); _mUsuarios.Id = 0; _mUsuarios.Excluir = 0; _mUsuarios.Nome = $@"{jo["user"]["name"].ToString()} {jo["user"]["lastname"].ToString()}"; _mUsuarios.Id_User = Validation.ConvertToInt32(jo["user"]["id"]); _mUsuarios.Comissao = Validation.ConvertToInt32(jo["user"]["comissao"]); _mUsuarios.Sub_user = Validation.ConvertToInt32(jo["user"]["sub_user"]); _mUsuarios.email = jo["user"]["email"].ToString(); _mUsuarios.senha = password.Text; } else { _mUsuarios.Nome = $@"{jo["user"]["name"].ToString()} {jo["user"]["lastname"].ToString()}"; _mUsuarios.Id_User = Validation.ConvertToInt32(jo["user"]["id"]); _mUsuarios.Comissao = Validation.ConvertToInt32(jo["user"]["comissao"]); _mUsuarios.Sub_user = Validation.ConvertToInt32(jo["user"]["sub_user"]); _mUsuarios.email = jo["user"]["email"].ToString(); _mUsuarios.senha = password.Text; } _mUsuarios.Save(_mUsuarios); //var userId = Settings.Default.user_sub_user == 0 // ? Settings.Default.user_id // : Settings.Default.user_sub_user; //var dataUser = new RequestApi().URL($"{Program.URL_BASE}/api/listall/{Program.TOKEN}/{userId}") // .Content().Response(); //usuarios.Delete("excluir", 0); //foreach (var item in dataUser) //{ // var nameComplete = $"{item.Value["name"]} {item.Value["lastname"]}"; // var exists = usuarios.FindByUserId(Validation.ConvertToInt32(item.Value["id"])).FirstOrDefault(); // if (exists == null) // { // usuarios.Id = 0; // usuarios.Excluir = Validation.ConvertToInt32(item.Value["excluir"]); // usuarios.Nome = nameComplete; // usuarios.Id_User = Validation.ConvertToInt32(item.Value["id"]); // usuarios.Comissao = Validation.ConvertToInt32(item.Value["comissao"]); // usuarios.Sub_user = Validation.ConvertToInt32(item.Value["sub_user"]); // usuarios.email = item.Value["email"]?.ToString(); // usuarios.senha = item.Value["senha"]?.ToString(); // } // else // { // usuarios.Id = exists.ID; // usuarios.Excluir = Validation.ConvertToInt32(item.Value["excluir"]); // usuarios.Nome = nameComplete; // usuarios.Id_User = Validation.ConvertToInt32(item.Value["id"]); // usuarios.Comissao = Validation.ConvertToInt32(item.Value["comissao"]); // usuarios.Sub_user = Validation.ConvertToInt32(item.Value["sub_user"]); // usuarios.email = item.Value["email"]?.ToString(); // usuarios.senha = item.Value["senha"]?.ToString(); // } // usuarios.Save(usuarios); //} } else { var user = new Usuarios(); var checkUsuarios = user.FindAll().Get(); if (!checkUsuarios.Any()) { Alert.Message("Opps", "Você precisa estar conectado a internet no seu primeiro Login ao sistema.", Alert.AlertType.error); return; } var getUser = user.FindAll().Where("email", email.Text).FirstOrDefault <Usuarios>(); if (getUser != null) { if (getUser.senha != password.Text) { Alert.Message("Opps", "Senha incorreta!", Alert.AlertType.error); return; } Settings.Default.user_id = getUser.Id_User; Settings.Default.empresa_unique_id = getUser.id_empresa; } } Hide(); var form = new Home(); form.ShowDialog(); }
public async Task SendRemessa() { var baseQueryEnviando = connect.Query().Where("id_empresa", "!=", "").Where("campoa", "ENVIANDO"); var dataUpdateEnviando = await baseQueryEnviando.Clone().From("pedido").GetAsync(); if (dataUpdateEnviando != null) { foreach (var item in dataUpdateEnviando) { int idPedido = item.ID; var update = new Pedido().FindById(idPedido).FirstOrDefault <Pedido>(); update.campoa = "ENVIADO"; update.Save(update); } } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pedido"); } var baseQuery = connect.Query().Where("id_empresa", "!=", "").Where("campoa", "ENVIADO"); var dataUpdate = await baseQuery.Clone().From("pedido").GetAsync(); if (dataUpdate != null) { foreach (var item in dataUpdate) { dynamic response = new RequestApi() .URL(Program.URL_BASE + $"/api/pedido/get/{Program.TOKEN}/{idEmpresa}/{item.ID_SYNC}") .Content().Response(); if (response["status"].ToString() == "OK") { if (response.data.campoa == "RECEBIDO") { int idPedido = item.ID; var update = new Pedido().FindById(idPedido).FirstOrDefault <Pedido>(); update.campoa = "RECEBIDO"; update.Save(update); } else { dynamic obj = new { token = Program.TOKEN, id_empresa = idEmpresa }; // atualiza online (UPDATE -> CREATED) var responseP = new RequestApi() .URL(Program.URL_BASE + $"/api/pedido/updateRemessa/{item.ID_SYNC}/ENVIADO") .Content(obj, Method.POST).Response(); if (responseP["status"] != "OK") { new Log().Add("SYNC", $"{responseP["status"]} | Tabela: pedido - {responseP["message"]}", Log.LogType.fatal); } } } } } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pedido_item"); } }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; btnSend.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Oppss", "Você parece estar sem internet no momento e não conseguimos receber sua sugestão :(", Alert.AlertType.error); return; } if (Sugestao.Text.Length < 15) { Alert.Message("Oppss", "Sua sugestão é muito curta, escreva em mais detalhes.", Alert.AlertType.error); return; } Obj = new { token = Program.TOKEN, user = Settings.Default.user_name + " " + Settings.Default.user_lastname, empresa = Settings.Default.empresa_razao_social, comment = Sugestao.Text }; backWorker.RunWorkerAsync(); loading.Visible = true; btnSend.Enabled = false; }; backWorker.DoWork += (s, e) => { var jo = new RequestApi().URL(Program.URL_BASE + "/api/suggestion").Content(Obj, Method.POST) .Response(); if (jo["error"] != null && jo["error"].ToString() != "") { Alert.Message("Opss", jo["error"].ToString(), Alert.AlertType.error); return; } Result = jo["result"]?.ToString() == "True"; }; backWorker.RunWorkerCompleted += (s, e) => { if (Result) { Alert.Message("Obrigado :)", "Sugestão enviada com sucesso.", Alert.AlertType.success); btnSend.Enabled = true; loading.Visible = false; Sugestao.Text = string.Empty; Close(); } else { Alert.Message("Opps", "Algo deu errado.", Alert.AlertType.error); btnSend.Enabled = true; loading.Visible = false; } }; btnFechar.Click += (s, e) => Close(); }
private void Eventos() { email.KeyDown += KeyDowns; password.KeyDown += KeyDowns; Load += (s, e) => { version.Text = @"Versão " + IniFile.Read("Version", "APP"); if (Support.CheckForInternetConnection()) { var update = new Update(); update.CheckUpdate(); update.CheckIni(); if (Data.Core.Update.AtualizacaoDisponivel) { btnUpdate.Visible = true; btnUpdate.Text = $@"Atualizar Versão {update.GetVersionWebTxt()}"; label5.Visible = false; email.Visible = false; label6.Visible = false; password.Visible = false; btnEntrar.Visible = false; label1.Text = @"Antes de continuar.."; } else { btnUpdate.Visible = false; label5.Visible = true; email.Visible = true; label6.Visible = true; password.Visible = true; btnEntrar.Visible = true; label1.Text = @"Entre com sua conta"; } } // Valida a resolução do monitor e exibe uma mensagem Resolution.ValidateResolution(); // Verifica se existe uma empresa vinculada a instalação da aplicação if (string.IsNullOrEmpty(IniFile.Read("idEmpresa", "APP"))) { panelEmpresa.Visible = true; panelEmpresa.Dock = DockStyle.Fill; } InitData(); }; btnEntrar.Click += (s, e) => LoginAsync(); btnUpdate.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { AlertOptions.Message("Atenção!", "Você precisa estar conectado a internet para atualizar.", AlertBig.AlertType.info, AlertBig.AlertBtn.OK); return; } var result = AlertOptions.Message("Atenção!", "Deseja iniciar o processo de atualização?", AlertBig.AlertType.info, AlertBig.AlertBtn.YesNo); if (result) { IniFile.Write("Update", "true", "APP"); if (File.Exists($"{Support.BasePath()}\\Update\\InstalarEmiplus.exe")) { File.Delete($"{Support.BasePath()}\\Update\\InstalarEmiplus.exe"); } if (!Directory.Exists($"{Support.BasePath()}\\Update")) { Directory.CreateDirectory($"{Support.BasePath()}\\Update"); } using (var d = new WebClient()) { d.DownloadFile("https://github.com/lmassi25/files/releases/download/Install/InstallEmiplus.exe", $"{Support.BasePath()}\\Update\\InstalarEmiplus.exe"); } if (!File.Exists($"{Support.BasePath()}\\Update\\InstalarEmiplus.exe")) { Alert.Message("Oopss", "Não foi possível iniciar a atualização. Verifique a conexão com a internet.", Alert.AlertType.error); } Process.Start($"{Support.BasePath()}\\Update\\InstalarEmiplus.exe"); Validation.KillEmiplus(); } }; btnConfirmar.Click += (s, e) => { var id_empresa = idEmpresa.Text; if (id_empresa.Length < 36) { Alert.Message("Opps", "ID da empresa está incorreto! Por favor insira um ID válido.", Alert.AlertType.error); return; } if (Support.CheckForInternetConnection()) { dynamic objt = new { token = Program.TOKEN, id_empresa }; var validar = new RequestApi().URL(Program.URL_BASE + "/api/validarempresa") .Content(objt, Method.POST).Response(); if (validar["error"] == "true") { Alert.Message("Opps", "O ID da empresa informado não existe.", Alert.AlertType.error); return; } IniFile.Write("idEmpresa", id_empresa, "APP"); panelEmpresa.Visible = false; } else { Alert.Message("Opps", "Você precisa estar conectado a internet para continuar.", Alert.AlertType.error); } }; FormClosed += (s, e) => Validation.KillEmiplus(); btnFechar.Click += (s, e) => Close(); linkRecover.Click += (s, e) => Support.OpenLinkBrowser(Program.URL_BASE + "/admin/forgotten"); linkSupport.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda); }
private void KeyDowns(object sender, KeyEventArgs e) { if (!CheckCaixa()) { return; } switch (e.KeyCode) { case Keys.Enter: BSalvar(); e.SuppressKeyPress = true; break; case Keys.F1: TelaEsc = true; JanelasRecebimento("Dinheiro"); e.SuppressKeyPress = true; break; case Keys.F2: TelaEsc = true; JanelasRecebimento("Cheque"); e.SuppressKeyPress = true; break; case Keys.F3: TelaEsc = true; JanelasRecebimento("Cartão de Débito"); e.SuppressKeyPress = true; break; case Keys.F4: TelaEsc = true; JanelasRecebimento("Cartão de Crédito"); e.SuppressKeyPress = true; break; case Keys.F5: TelaEsc = true; JanelasRecebimento("Crediário"); e.SuppressKeyPress = true; break; case Keys.F6: TelaEsc = true; JanelasRecebimento("Boleto"); e.SuppressKeyPress = true; break; case Keys.F7: break; case Keys.F8: break; case Keys.F9: Cfe(); break; case Keys.F10: if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } Nfe(); e.SuppressKeyPress = true; break; case Keys.F11: new Controller.Pedido().Imprimir(idPedido); //new PedidoImpressao().Print(IdPedido); break; case Keys.F12: Concluir(); e.SuppressKeyPress = true; break; case Keys.Escape: if (TelaEsc) { TelaReceber.Visible = false; TelaEsc = false; e.SuppressKeyPress = true; } else { if (_controllerTitulo.GetLancados(idPedido) > 0) { var text = Home.pedidoPage == "Compras" ? "pagamentos" : "recebimentos"; var message = AlertOptions.Message("Atenção", $"Os {text} lançados serão apagados,\ndeseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (message) { foreach (DataGridViewRow row in GridListaFormaPgtos.Rows) { if (Convert.ToString(row.Cells[0].Value) != "") { _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false); } } AtualizarDados(); _mPedido = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); _mPedido.status = 2; _mPedido.Save(_mPedido); Close(); } else { return; } } e.SuppressKeyPress = true; AddPedidos.BtnVoltar = true; Close(); } break; } }
private void Eventos() { Shown += async(s, e) => { if (!UserPermission.SetControl(homeMenuInicio, pictureBox13, "tela_inicial", false)) { StartInicio(); } // Pega versão version.Text = $@"Versão {IniFile.Read("Version", "APP")}"; // Pega nome do usuario label1.Text = $@"Olá, {Validation.FirstCharToUpper(Settings.Default.user_name)} {Validation.FirstCharToUpper(Settings.Default.user_lastname)}"; // Atualiza menu Comercial -> Alimentação if (IniFile.Read("Alimentacao", "Comercial") == "True") { homeMenuComercial.Text = @" Alimentação"; pictureBox4.Image = Resources.waiter; } // Starta ações em segundo plano backWork.RunWorkerAsync(); # region ########### Menu expansivo MenuExpansive = IniFile.Read("MENU_EXPANSIVE", "LAYOUT") != "false"; if (!MenuExpansive) { panel3.Width = 241; btnShowMenu.Image = Resources.seta1; version.Visible = true; MenuExpansive = false; IniFile.Write("MENU_EXPANSIVE", "false", "LAYOUT"); } else { panel3.Width = 47; btnShowMenu.Image = Resources.seta2; version.Visible = false; MenuExpansive = true; IniFile.Write("MENU_EXPANSIVE", "true", "LAYOUT"); } #endregion #region ########### Dados do plano if (string.IsNullOrEmpty(Settings.Default.user_plan_id)) { plano.Text = @"Contrate um Plano"; btnPlano.Text = @"Contratar Plano"; recorrencia.Text = @"Contrate um Plano"; fatura.Visible = false; label3.Visible = false; } else { plano.Text = Validation.FirstCharToUpper(Settings.Default.user_plan_id); recorrencia.Text = Validation.FirstCharToUpper(Settings.Default.user_plan_recorrencia); fatura.Text = Settings.Default.user_plan_fatura; } if (Settings.Default.user_plan_status == 1) { label6.Visible = false; trialdias.Visible = false; } else { trialdias.Text = $@"{Settings.Default.user_plan_trial} dias"; } #endregion #region ########### Menu developer if (IniFile.Read("dev", "DEV") == "true") { developer.Visible = true; } #endregion ToolHelp.Show("Sistema de sincronização em andamento.", syncOn, ToolHelp.ToolTipIcon.Info, "Sincronização!"); timer1.Start(); // Janela de sincronização await Task.Delay(5000); if (Support.CheckForInternetConnection()) { var f = new Sync(); f.Show(); f.Hide(); } };
/// <summary> /// Eventos do form /// </summary> public void Eventos() { Load += (s, e) => { PayVerify = true; if (AddPedidos.PDV) { // btn NF-e btnNfe.Visible = false; button21.Visible = false; pictureBox6.Visible = false; } }; Shown += (s, e) => { Resolution.SetScreenMaximized(this); AddPedidos.BtnFinalizado = false; TelaReceber.Visible = false; switch (Home.pedidoPage) { case "Orçamentos": label13.Text = $@"Dados do Orçamento: {idPedido}"; label10.Text = @"Siga as etapas abaixo para criar um orçamento!"; break; case "Consignações": label13.Text = $@"Dados da Consignação: {idPedido}"; label10.Text = @"Siga as etapas abaixo para criar uma consignãção!"; break; case "Devoluções": label13.Text = $@"Dados da Devolução: {idPedido}"; label10.Text = @"Siga as etapas abaixo para criar uma devolução!"; break; case "Compras": label13.Text = $@"Dados da Compra: {idPedido}"; label10.Text = @"Siga as etapas abaixo para adicionar uma compra!"; label15.Text = @"Á Pagar"; label1.Text = @"Pagamentos"; //enviarEmail.Visible = false; btnNfe.Visible = false; button21.Visible = false; btnCFeSat.Visible = false; button22.Visible = false; break; default: label13.Text = $@"Dados da Venda: {idPedido}"; label10.Text = @"Siga as etapas abaixo para adicionar uma venda!"; break; } if (HideFinalizar) { btnCFeSat.Visible = false; button22.Visible = false; btnNfe.Visible = false; button21.Visible = false; btnConcluir.Visible = false; button19.Visible = false; //btnImprimir.Left = 835; //button20.Left = 830; btnImprimir.Visible = false; button20.Visible = false; } if (IniFile.Read("Alimentacao", "Comercial") == "True") { btnDividir.Visible = true; } mtxt.Visible = false; mtxt2.Visible = false; GridListaFormaPgtos.Controls.Add(mtxt); GridListaFormaPgtos.Controls.Add(mtxt2); AtualizarDados(); AddPedidos.BtnFinalizado = false; Dinheiro.Focus(); Dinheiro.Select(); var taxasSource = new ArrayList(); var dataTaxa = new Taxas().FindAll(new[] { "id", "nome" }).WhereFalse("excluir").Get <Taxas>(); taxasSource.Add(new { Id = 0, Nome = "SELECIONE" }); if (dataTaxa.Any()) { foreach (var item in dataTaxa) { taxasSource.Add(new { item.Id, item.Nome }); } } taxas.DataSource = taxasSource; taxas.DisplayMember = "Nome"; taxas.ValueMember = "Id"; }; FormClosing += (s, e) => { if (AddPedidos.BtnFinalizado) { Application.OpenForms["AddPedidos"]?.Close(); } }; KeyDown += KeyDowns; Dinheiro.KeyDown += KeyDowns; Cheque.KeyDown += KeyDowns; Debito.KeyDown += KeyDowns; Credito.KeyDown += KeyDowns; Crediario.KeyDown += KeyDowns; Boleto.KeyDown += KeyDowns; Desconto.KeyDown += KeyDowns; Acrescimo.KeyDown += KeyDowns; GridListaFormaPgtos.KeyDown += KeyDowns; btnCFeSat.KeyDown += (s, e) => { if (UserPermission.SetControl(btnCFeSat, pictureBox1, "fiscal_emissaocfe")) { return; } KeyDowns(s, e); }; btnNfe.KeyDown += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } if (UserPermission.SetControl(btnNfe, pictureBox6, "fiscal_emissaonfe")) { return; } KeyDowns(s, e); }; btnImprimir.KeyDown += KeyDowns; btnConcluir.KeyDown += KeyDowns; btnSalvar.KeyDown += KeyDowns; btnCancelar.KeyDown += KeyDowns; valor.KeyDown += KeyDowns; parcelas.KeyDown += KeyDowns; iniciar.KeyDown += KeyDowns; btnImprimir.Click += (s, e) => { new Controller.Pedido().Imprimir(idPedido); }; Debito.Click += (s, e) => JanelasRecebimento("Cartão de Débito"); Credito.Click += (s, e) => JanelasRecebimento("Cartão de Crédito"); Dinheiro.Click += (s, e) => JanelasRecebimento("Dinheiro"); Boleto.Click += (s, e) => JanelasRecebimento("Boleto"); Crediario.Click += (s, e) => JanelasRecebimento("Crediário"); Cheque.Click += (s, e) => JanelasRecebimento("Cheque"); Desconto.Click += (s, e) => JanelaDesconto(); Acrescimo.Click += (s, e) => JanelaAcrescimo(); Devolucao.Click += (s, e) => JanelaDevolucao(); btnSalvar.Click += (s, e) => BSalvar(); btnCancelar.Click += (s, e) => { PayVerify = true; TelaReceber.Visible = false; }; btnClose.Click += (s, e) => { if (_controllerTitulo.GetLancados(idPedido) > 0) { var text = Home.pedidoPage == "Compras" ? "pagamentos" : "recebimentos"; var message = AlertOptions.Message("Atenção", $"Os {text} lançados serão apagados,\n deseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (message) { foreach (DataGridViewRow row in GridListaFormaPgtos.Rows) { if (Convert.ToString(row.Cells[0].Value) != "") { _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false); } } AtualizarDados(); _mPedido = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); _mPedido.status = 2; _mPedido.Save(_mPedido); Close(); } else { return; } } AddPedidos.BtnVoltar = true; Close(); }; btnDividir.Click += (s, e) => { var itens = new ArrayList(); if (PayVerify) { var dataItens = _mPedidoItens.FindAll().Where("pedido", idPedido).WhereFalse("excluir") .Get <PedidoItem>(); if (dataItens.Any()) { foreach (var item in dataItens) { itens.Add(new { item.Id, item.Item, item.xProd, item.CEan, item.CProd, item.Quantidade, item.Total }); } } PedidoModalDividirConta.Itens = itens; } var form = new PedidoModalDividirConta { TopMost = true }; if (form.ShowDialog() == DialogResult.OK) { valor.Text = Validation.FormatPrice(PedidoModalDividirConta.ValorDividido); } }; btnConcluir.Click += (s, e) => { Concluir(); }; iniciar.KeyPress += Masks.MaskBirthday; iniciar.KeyPress += Masks.MaskBirthday; valor.KeyPress += (s, e) => Masks.MaskDouble(s, e); valor.TextChanged += (s, e) => { var txt = (TextBox)s; Masks.MaskPrice(ref txt); }; mtxt2.TextChanged += (s, e) => { var txt = (TextBox)s; Masks.MaskPrice(ref txt); }; GridListaFormaPgtos.CellDoubleClick += (s, e) => { if (GridListaFormaPgtos.Columns[e.ColumnIndex].Name == "colExcluir") { if (Convert.ToString(GridListaFormaPgtos.CurrentRow.Cells[4].Value) != "") { var id = Validation.ConvertToInt32(GridListaFormaPgtos.CurrentRow.Cells[0].Value); _mTitulo.Remove(id); AtualizarDados(); } } }; GridListaFormaPgtos.CellBeginEdit += (s, e) => { if (e.ColumnIndex == 2) { //-----mtxt mtxt.Mask = @"##/##/####"; var rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); mtxt.Location = rec.Location; mtxt.Size = rec.Size; mtxt.Text = ""; if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null) { mtxt.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString(); } mtxt.Visible = true; } if (e.ColumnIndex == 3) { //-----mtxt2 var rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); mtxt2.Location = rec.Location; mtxt2.Size = rec.Size; mtxt2.Text = ""; if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null) { mtxt2.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString(); } mtxt2.Visible = true; } }; GridListaFormaPgtos.CellEndEdit += (s, e) => { if (mtxt.Visible) { GridListaFormaPgtos.CurrentCell.Value = mtxt.Text; mtxt.Visible = false; } if (mtxt2.Visible) { GridListaFormaPgtos.CurrentCell.Value = mtxt2.Text; mtxt2.Visible = false; } var ID = Validation.ConvertToInt32(GridListaFormaPgtos.Rows[e.RowIndex].Cells["colID"].Value); if (ID == 0) { return; } var titulo = new Model.Titulo().FindById(ID).FirstOrDefault <Model.Titulo>(); if (titulo == null) { return; } DateTime parsed; if (DateTime.TryParse(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value.ToString(), out parsed)) { titulo.Vencimento = Validation.ConvertDateToSql(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value); } else { GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value = Validation.ConvertDateToForm(titulo.Vencimento); } titulo.Total = Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value); titulo.Recebido = Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value); if (titulo.Save(titulo, false)) { //_controllerTitulo.GetDataTableTitulos(GridListaFormaPgtos, IdPedido); Alert.Message("Pronto!", "Recebimento atualizado com sucesso.", Alert.AlertType.success); AtualizarDados(false); } else { Alert.Message("Opsss!", "Algo deu errado ao atualizar o recebimento.", Alert.AlertType.error); } }; GridListaFormaPgtos.Scroll += (s, e) => { if (mtxt.Visible) { var rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex, GridListaFormaPgtos.CurrentCell.RowIndex, true); mtxt.Location = rec.Location; } if (mtxt2.Visible) { var rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex, GridListaFormaPgtos.CurrentCell.RowIndex, true); mtxt2.Location = rec.Location; } }; btnClearRecebimentos.Click += (s, e) => { foreach (DataGridViewRow row in GridListaFormaPgtos.Rows) { if (Convert.ToString(row.Cells[0].Value) != "") { _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false); } } AtualizarDados(); _mPedido = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); _mPedido.status = 2; _mPedido.Save(_mPedido); }; btnNfe.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } if (UserPermission.SetControl(btnNfe, pictureBox6, "fiscal_emissaonfe")) { return; } Nfe(); }; btnCFeSat.Click += (s, e) => { if (UserPermission.SetControl(btnCFeSat, pictureBox1, "fiscal_emissaocfe")) { return; } Cfe(); }; }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; btnExit.Click += (s, e) => Close(); Load += (s, e) => { LoadStatus(); var pedido = _modelPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); pedido.Id = idPedido; pedido.status = _controllerTitulo.GetLancados(idPedido) < Validation.Round(_modelPedido.Total) ? 2 : 1; if (Home.pedidoPage == "Delivery" || Home.pedidoPage == "Balcao") { Status.SelectedValue = pedido.campoa; label19.Text = GetStatus(pedido.campoa); } pedido.Save(pedido); }; Activated += (s, e) => { LoadData(); }; btnPgtosLancado.Click += (s, e) => { OpenPedidoPagamentos(); }; btnRemove.Click += (s, e) => { if (labelCfe.Text != @"N/D" || labelNfe.Text != @"N/D") { Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!", Alert.AlertType.warning); return; } var result = AlertOptions.Message("Atenção!", "Deseja realmente apagar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { var remove = new Controller.Pedido(); remove.Remove(idPedido); Close(); } }; btnImprimir.Click += (s, e) => { var f = new OptionBobinaA4(); string tipo; f.TopMost = true; var formResult = f.ShowDialog(); switch (formResult) { case DialogResult.OK: tipo = "Folha A4"; new Controller.Pedido().Imprimir(idPedido, tipo); break; case DialogResult.Cancel: tipo = "Bobina 80mm"; new Controller.Pedido().Imprimir(idPedido, tipo); break; } }; btnNfe.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } if (UserPermission.SetControlVisual(btnNfe, pictureBox4, "fiscal_emissaonfe")) { return; } Nfe(); }; btnCFeSat.Click += (s, e) => { if (UserPermission.SetControlVisual(btnCFeSat, pictureBox6, "fiscal_emissaocfe")) { return; } Cfe(); //Cfe(1); }; btnNfse.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning); return; } //if (UserPermission.SetControl(btnNfe, pictureBox4, "fiscal_emissaonfe")) // return; Nfse(); }; btnHelp.Click += (s, e) => Support.OpenLinkBrowser("http://ajuda.emiplus.com.br/"); SelecionarCliente.Click += (s, e) => { var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Nota>(); if (checkNota != null) { if (checkNota.Status == "Autorizada") { Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!", Alert.AlertType.warning); return; } } ModalClientes(); }; SelecionarColaborador.Click += (s, e) => { var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Nota>(); if (checkNota != null) { if (checkNota.Status == "Autorizada") { Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!", Alert.AlertType.warning); return; } } ModalColaborador(); }; impostos.CheckStateChanged += (s, e) => { PedidoItem.impostos = impostos.Checked; _controllerPedidoItem.GetDataTableItens(GridLista, idPedido); }; btnStatus.Click += (s, e) => { pictureBox7.Visible = true; visualPanel1.Visible = true; }; btnCancelStatus.Click += (s, e) => { pictureBox7.Visible = false; visualPanel1.Visible = false; }; btnSaveStatus.Click += (s, e) => { if (Status.SelectedValue.ToString() == "Selecione") { Alert.Message("Opss", "Selecione um status.", Alert.AlertType.error); return; } var pedido = _modelPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>(); pedido.Id = idPedido; pedido.campoa = Status.SelectedValue.ToString(); label19.Text = GetStatus(pedido.campoa); if (pedido.Save(pedido)) { Alert.Message("Pronto", "Status atualizado.", Alert.AlertType.success); pictureBox7.Visible = false; visualPanel1.Visible = false; } }; }
private void Eventos() { Shown += (s, e) => { Refresh(); LoadEmpresas(); }; btnImport.Click += (s, e) => { if (!Support.CheckForInternetConnection()) { Alert.Message("Opps", "Você precisa estar conectado a internet.", Alert.AlertType.error); return; } Logs.Clear(); IdEmpresa = Empresas.SelectedValue.ToString(); if (Empresas.SelectedValue.ToString() != "0") { backWorker.RunWorkerAsync(); } }; backWorker.DoWork += (s, e) => { var idEmpresa = IdEmpresa; var response = new RequestApi().URL(Program.URL_BASE + $"/api/item/{Program.TOKEN}/{idEmpresa}/9999") .Content().Response(); if (response["error"] != null && response["error"].ToString() != "") { Alert.Message("Opss", response["error"].ToString(), Alert.AlertType.error); return; } var i = 0; foreach (dynamic item in response["data"]) { i++; string codebarras = item.Value.codebarras; var dataItem = new Item().FindAll().WhereFalse("excluir").Where("codebarras", codebarras) .Where("tipo", "Produtos").FirstOrDefault <Item>(); if (dataItem != null) { Logs.Invoke((MethodInvoker) delegate { Logs.AppendText( $"({i}) JÁ CADASTRADO: {dataItem.Nome} - Código de Barras: {dataItem.CodeBarras}" + Environment.NewLine); }); } else { var createItem = new Item { Id = 0, Tipo = "Produtos", Excluir = 0, Nome = item.Value.nome, Referencia = item.Value.referencia, ValorCompra = item.Value.valorcompra, ValorVenda = item.Value.valorvenda, EstoqueMinimo = item.Value.estoqueminimo, EstoqueAtual = item.Value.estoqueatual, Medida = item.Value.medida, Cest = item.Value.cest, Ncm = item.Value.ncm, CodeBarras = item.Value.codebarras, Limite_Desconto = Validation.ConvertToDouble(item.Value.limite_desconto), Criado_por = Validation.ConvertToInt32(item.Value.criado_por), Atualizado_por = Validation.ConvertToInt32(item.Value.atualizado_por) }; createItem.Save(createItem, false); Logs.Invoke((MethodInvoker) delegate { Logs.AppendText( $"({i}) CADASTRO REALIZADO: {createItem.Nome} - Código de Barras: {createItem.CodeBarras}" + Environment.NewLine); }); } } Logs.Invoke((MethodInvoker) delegate { Logs.AppendText($"Total de itens filtrado: ({i})"); }); }; backWorker.RunWorkerCompleted += (s, e) => { Alert.Message("Pronto", "Importação concluída.", Alert.AlertType.success); }; btnExit.Click += (s, e) => Close(); }
public async Task StartSync() { if (sync_start == 0) { sync_start = 1; if (Support.CheckForInternetConnection()) { await RunSyncAsync("caixa"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("caixa_mov"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("imposto"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("categoria"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("item"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("item_mov_estoque"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("natureza"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pessoa"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pessoa_contato"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pessoa_endereco"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("titulo"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("nota"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pedido"); } if (Support.CheckForInternetConnection()) { await RunSyncAsync("pedido_item"); } LastSync(); sync_start = 0; } }
public void Eventos() { ToolHelp.Show( "Utilize essa função para sincronizar todos os dados do programa para consulta no sistema web do seus dados.", pictureBox11, ToolHelp.ToolTipIcon.Info, "Ajuda!"); Load += (s, e) => Refresh(); dadosEmpresa.Click += (s, e) => OpenForm.Show <InformacaoGeral>(this); email.Click += (s, e) => OpenForm.Show <Email>(this); sat.Click += (s, e) => OpenForm.Show <Cfesat>(this); comercial.Click += (s, e) => OpenForm.Show <Configuracoes.Comercial>(this); os.Click += (s, e) => OpenForm.Show <OS>(this); impressao.Click += (s, e) => OpenForm.Show <Impressao>(this); system.Click += (s, e) => OpenForm.Show <Sistema>(this); btnBalancas.Click += (s, e) => OpenForm.Show <Balanças>(this); btnImportar.Click += (s, e) => { var f = new ImportarDados(); f.ShowDialog(); }; btnSincronizar.Click += (s, e) => { if (Support.CheckForInternetConnection()) { if (!Home.syncActive) { Home.syncActive = true; pictureBox10.Image = Resources.loader_page; btnSincronizar.Text = @"Sincronizando.."; backWork.RunWorkerAsync(); } else { Alert.Message("Opps", "Sincronização já está rodando.", Alert.AlertType.info); } } else { Alert.Message("Opps", "Parece que você não possui conexão com a internet.", Alert.AlertType.error); } }; backWork.DoWork += async(s, e) => { if (Sync.sync_start == 0) { var f = new Sync(); await f.StartSync(); } }; backWork.RunWorkerCompleted += (s, e) => { new Log().Add("SYNC", "Sincronização", Log.LogType.fatal); pictureBox10.Image = Resources.refresh; btnSincronizar.Text = @"Sincronizar"; Home.syncActive = false; }; /* * Enviar Remessas */ btnRemessaEnviar.Click += (s, e) => { if (Support.CheckForInternetConnection()) { if (!Home.syncActive) { Home.syncActive = true; pictureBox14.Image = Resources.loader_page; label13.Text = @"Enviando.."; backWorkRemessa.RunWorkerAsync(); } else { Alert.Message("Opps", "Sincronização já está rodando.", Alert.AlertType.info); } } }; backWorkRemessa.DoWork += async(s, e) => { var f = new Sync(); Sync.Remessa = true; await f.SendRemessa(); Sync.Remessa = false; }; backWorkRemessa.RunWorkerCompleted += (s, e) => { new Log().Add("SYNC", "Remessa enviada", Log.LogType.fatal); pictureBox14.Image = Resources.caja; label13.Text = @"Remessas"; Home.syncActive = false; }; btnRemessaReceber.Click += async(s, e) => { var f = new Sync(); await f.ReceberRemessa(); }; btnImportProdutos.Click += (s, e) => OpenForm.Show <ImportProdutos>(this); }