Example #1
0
        private void Svr_ClientConnected(object sender, ConnectedEventArgs e)
        {
            EzClient client = new EzClient(e.Socket);

            Clients.AddClient(client);
            _logger.Info("Client: {0} connected", client.Identity);
        }
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var lastName    = TextBoxLastName.Text;
                var firstName   = TextBoxFirstName.Text;
                var dateOfBirth = DatePickerDateOfBirth.DisplayDate.Date;
                var nip         = TextBoxNip.Text;
                var phone       = int.Parse(TextBoxPhone.Text);
                var nation      = TextBoxNation.Text;
                var city        = TextBoxCity.Text;
                var street      = TextBoxStreet.Text;
                var number      = TextBoxNumber.Text;

                var discount  = int.Parse(TextBoxDiscount.Text);
                var newClient = new Client(nation, city, street, number, firstName, lastName, dateOfBirth, nip, phone,
                                           discount);
                Clients.AddClient(newClient);
                Close();
                MessageBox.Show("Dodano klienta: " + firstName + " " + lastName, "Sukces!");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Sprawdz poprawność wprowadzonych danych.\nSzczegóły: " + exception.Message, "Błąd!");
            }
        }
Example #3
0
        private void ClientsSaveButton_Click(object sender, EventArgs e)
        {
            if (ClientNameTextBox.Text.Length == 0)
            {
                Infinium.LightMessageBox.Show(ref TopForm, false,
                                              "Введены не все данные: Клиент!",
                                              "Сохранение клиента");
                return;
            }

            string Name          = ClientNameTextBox.Text;
            int    ClientGroupID = Convert.ToInt32(cbClientsGroups.SelectedValue);
            int    ManagerID     = Convert.ToInt32(cbManager.SelectedValue);

            if (Clients.NewClient == true)
            {
                Clients.AddClient(Name, ClientGroupID, ManagerID);
                Clients.SaveShopAddresses();
            }
            else
            {
                Clients.SaveClient(Name, ClientGroupID, ManagerID, ClientID);
                Clients.SaveShopAddresses();
            }

            ClientNameTextBox.Text = string.Empty;

            FormEvent            = eClose;
            AnimateTimer.Enabled = true;
        }
Example #4
0
        public string AddClient(ClientViewModel cvm)
        {
            int id = Clients.AddClient(cvm);

            if (id == -1)
            {
                return("Failure");
            }

            // Newly added client becomes the client being served.
            // Entity Framework will set client.Id to the Id of the inserted client.
            // See: https://stackoverflow.com/questions/5212751/how-can-i-get-id-of-inserted-entity-in-entity-framework
            NowServing(id);

            DailyHub.Refresh();
            return("Success");
        }
Example #5
0
        private void buttonAddClient_Click(object sender, EventArgs e)
        {
            Client client = new Client();

            client.Nume       = textBoxNume.Text.ToString();
            client.Prenume    = textBoxPrenume.Text.ToString();
            client.Adresa     = textBoxAdresa.Text.ToString();
            client.Localitate = textBoxLocalitate.Text.ToString();
            client.Judet      = textBoxJudet.Text.ToString();
            client.Telefon    = textBoxTelefon.Text.ToString();
            client.Email      = textBoxEmail.Text.ToString();

            try
            {
                Clients.AddClient(client);
                MessageBox.Show("Client " + client.Nume + " " + client.Prenume + " a fost adaugat cu succes!");
                textBoxNume.Clear();
                textBoxPrenume.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }

            /*
             * string fName = textBoxNume.Text.ToString();
             * string lName = textBoxPrenume.Text.ToString();
             * string addrs = textBoxAdresa.Text.ToString();
             * string loc = textBoxLocalitate.Text.ToString();
             * string county = textBoxJudet.Text.ToString();
             * string phoneNr = textBoxTelefon.Text.ToString();
             * string email = textBoxEmail.Text.ToString();
             *
             *
             * try
             * {
             *  Clients.Add(fName, lName, addrs, loc, county, phoneNr, email);
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.ToString(),"Error");
             * }
             */
        }
Example #6
0
 public VMClients()
 {
     clientsModel.PropertyChanged += (s, e) => { RaisePropertyChanged(e.PropertyName); };
     // Add new client.
     AddClientCommand = new DelegateCommand(() =>
     {
         clientsModel.AddClient(new Client
         {
             Id         = clientsModel.ClientsCollection.Max(x => x.Id) + 1,
             Surname    = "Tutov",
             Name       = "Tut",
             MiddleName = "Tutovich",
             Phone      = "999999",
             Notes      = "test addClient",
             Fullname   = ""
         });
     });
     GridSelectionChanged = new DelegateCommand(() =>
     {
     });
 }
        /// <summary>
        /// Método para coletar dados e fazer interação com banco para inserção
        /// </summary>
        private void AddClient()
        {
            if (IsValidFields())
            {
                //Recuperando documentos no formato correto
                string doc = docEdit.Text.Replace(".", "").Replace("-", "").Replace("_", ".").Replace("/", "");
                string cep = cepEdit.Text.Replace("-", "").Replace("_", "");

                //Validando os documentos
                if (cbtype.SelectedIndex == 0)
                {
                    if (!Validator.IsCpf(doc))
                    {
                        MessageBox.Show(
                            "CPF Inválido",
                            "Dados incorretos!",
                            MessageBoxButton.OK,
                            MessageBoxImage.Warning);
                        return;
                    }
                }
                else
                {
                    if (!Validator.IsCnpj(doc))
                    {
                        MessageBox.Show(
                            "CNPJ Inválido",
                            "Dados incorretos!",
                            MessageBoxButton.OK,
                            MessageBoxImage.Warning);
                        return;
                    }
                }

                try {
                    //Recuperando dados do cliente
                    Client       cli      = new Client();
                    ComboBoxItem selected = cbState.Items[cbState.SelectedIndex] as ComboBoxItem;
                    cli.adress.street       = AdressEdit.Text;
                    cli.adress.city         = CityEdit.Text;
                    cli.adress.neighborhood = NeighboorhoodEdit.Text;
                    cli.adress.number       = NumberEdit.Text;
                    cli.adress.UF           = selected.Content.ToString();
                    cli.adress.CEP          = cep;
                    cli.name            = NameEdit.Text;
                    cli.docNumber       = doc;
                    cli.cellNumber      = phone2Edit.Text;
                    cli.residenceNumber = phone1Edit.Text;
                    cli.description     = descEdit.Text;
                    cli.stateId         = stateEdit.Text;
                    if (cbActive.SelectedIndex == 1)
                    {
                        cli.Inactivate();
                    }
                    if (cbtype.SelectedIndex == 1)
                    {
                        cli.SetPhysical(false);
                    }

                    //Inserindo registro no banco
                    dao.AddClient(cli);

                    //Registrando log de alteração
                    Model.Log added = new Model.Log();
                    added.employe = _employe;
                    added.action  = $"Cliente {cli.name} foi cadastrado no sistema!";
                    logs.Register(added);

                    //Atualizando grid e limpando campos de texto
                    RefreshGrid();
                    ClearFields();
                    BlockFields();
                    actionIndex = -1;
                    aux         = null;
                }
                catch (DatabaseInsertException err) {
                    MessageBox.Show(
                        err.Message,
                        "Erro ao gravar dados",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error
                        );
                }
            }
            else
            {
                MessageBox.Show(
                    "Há Campos Vazios",
                    "Erro de Prenchimento de Formulário",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning
                    );
            }
        }
Example #8
0
        private void ClientsSaveButton_Click(object sender, EventArgs e)
        {
            if (ClientNameTextBox.Text.Length == 0)
            {
                Infinium.LightMessageBox.Show(ref TopForm, false,
                                              "Введены не все данные: Клиент!",
                                              "Сохранение клиента");
                return;
            }
            if (CityTextBox.Text.Length == 0)
            {
                Infinium.LightMessageBox.Show(ref TopForm, false,
                                              "Введены не все данные Город!",
                                              "Сохранение клиента");
                return;
            }

            string  UNN            = tbUNN.Text;
            string  Name           = ClientNameTextBox.Text;
            int     CountryID      = Convert.ToInt32(cbCountry.SelectedValue);
            int     ClientGroupID  = Convert.ToInt32(cbClientGroups.SelectedValue);
            string  City           = CityTextBox.Text;
            string  Site           = SiteTextBox.Text;
            string  Email          = EmailTextBox.Text;
            int     ManagerID      = Convert.ToInt32(cbManager.SelectedValue);
            int     NonStandard    = Convert.ToInt32(NonStandardComboBox.SelectedIndex);
            decimal PriceGroup     = Convert.ToDecimal(tbPriceGroup.Text);
            int     DelayOfPayment = 0;
            bool    Enabled        = cbClientEnable.Checked;

            if (tbDelayOfPayment.Text.Length > 0)
            {
                DelayOfPayment = Convert.ToInt32(tbDelayOfPayment.Text);
            }
            if (Clients.NewClient == true)
            {
                InfiniumFiles InfiniumFiles = new InfiniumFiles();
                InfiniumFiles.CreateClientFolders(ClientNameTextBox.Text);

                Clients.AddClient(Name,
                                  CountryID, City, ClientGroupID,
                                  Site, Email, ManagerID, UNN,
                                  NonStandard, PriceGroup, DelayOfPayment, Enabled);
                Clients.SaveShopAddresses();
            }
            else
            {
                Clients.SaveClient(Name,
                                   CountryID, City, ClientGroupID,
                                   Site, Email, ManagerID, UNN,
                                   NonStandard, PriceGroup, DelayOfPayment, Enabled, ClientID);
                Clients.SaveShopAddresses();
            }

            if (OldManagerID != ManagerID && ManagerID != 0)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, true,
                                                              "У клиента поменялся менеджер. Уведомить клиента письмом на почту?",
                                                              "Уведомлению клиенту");
                if (OKCancel)
                {
                    string result = string.Empty;
                    result = Clients.NotifyClient(Email, ManagerID);
                    InfiniumTips.ShowTip(this, 50, 85, result, 2500);
                }
            }

            ClientNameTextBox.Text = string.Empty;
            CityTextBox.Text       = string.Empty;
            EmailTextBox.Text      = string.Empty;
            SiteTextBox.Text       = string.Empty;
            tbUNN.Text             = string.Empty;
            FormEvent            = eClose;
            AnimateTimer.Enabled = true;
        }