private void ButtonUpdate_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxEmail.Text) && !string.IsNullOrEmpty(textBoxPassword.Text) && !string.IsNullOrEmpty(textBoxClientFIO.Text))
            {
                try
                {
                    ClientApi.PostRequest("api/client/updatedata", new ClientBindingModel
                    {
                        Id        = Program.Client.Id,
                        ClientFIO = textBoxClientFIO.Text,
                        Email     = textBoxEmail.Text,
                        Password  = textBoxPassword.Text
                    });

                    MessageBox.Show("Обновление прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Program.Client.ClientFIO = textBoxClientFIO.Text;
                    Program.Client.Email     = textBoxEmail.Text;
                    Program.Client.Password  = textBoxPassword.Text;
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите логин, пароль и ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ButtonRegister_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxEmail.Text) && !string.IsNullOrEmpty(textBoxPassword.Text) && !string.IsNullOrEmpty(textBoxClientFIO.Text))
            {
                try
                {
                    ClientApi.PostRequest("api/client/register", new ClientBindingModel
                    {
                        ClientFIO = textBoxClientFIO.Text,
                        Email     = textBoxEmail.Text,
                        Password  = textBoxPassword.Text
                    });

                    MessageBox.Show("Регистрация прошла успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите логин, пароль и ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCount.Text))
            {
                MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (comboBoxKomlect.SelectedValue == null)
            {
                MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                ClientApi.PostRequest("api/main/createorder", new CreateOrderBindingModel
                {
                    ClientId  = Program.Client.Id,
                    KomlectId = Convert.ToInt32(comboBoxKomlect.SelectedValue),
                    Count     = Convert.ToInt32(textBoxCount.Text),
                    Sum       = Convert.ToInt32(textBoxSum.Text)
                });

                MessageBox.Show("Заказ создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        static void Main()
        {
            ClientApi.Connect();
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new FormEnter();

            form.ShowDialog();
            if (Client != null)
            {
                Application.Run(new FormMain());
            }
        }
 private void FormMessages_Load(object sender, EventArgs e)
 {
     try
     {
         List <MessageInfoViewModel> dataSourse = ClientApi.GetRequest <List <MessageInfoViewModel> >($"api/client/getmessages?clientId={Program.Client.Id}");
         dataGridView.DataSource              = dataSourse;
         dataGridView.Columns[0].Visible      = false;
         dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void FormCreateOrder_Load(object sender, EventArgs e)
 {
     try
     {
         comboBoxKomlect.DisplayMember = "KomlectName";
         comboBoxKomlect.ValueMember   = "Id";
         comboBoxKomlect.DataSource    = ClientApi.GetRequest <List <KomlectViewModel> >("api/main/getproductlist");
         comboBoxKomlect.SelectedItem  = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void CalcSum()
 {
     if (comboBoxKomlect.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
     {
         try
         {
             int id = Convert.ToInt32(comboBoxKomlect.SelectedValue);
             KomlectViewModel product = ClientApi.GetRequest <KomlectViewModel>($"api/main/getproduct?productId={id}");
             int count = Convert.ToInt32(textBoxCount.Text);
             textBoxSum.Text = (count * product.Price).ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void LoadList()
 {
     try
     {
         dataGridView.DataSource              = ClientApi.GetRequest <List <OrderViewModel> >($"api/main/getorders?clientId={Program.Client.Id}");
         dataGridView.Columns[0].Visible      = false;
         dataGridView.Columns[1].Visible      = false;
         dataGridView.Columns[2].Visible      = false;
         dataGridView.Columns[3].Visible      = false;
         dataGridView.Columns[4].Visible      = false;
         dataGridView.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
 private void ButtonLogin_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBoxEmail.Text) && !string.IsNullOrEmpty(textBoxPassword.Text))
     {
         try
         {
             Program.Client = ClientApi.GetRequest <ClientViewModel>($"api/client/login?login={textBoxEmail.Text}&password={textBoxPassword.Text}");
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Введите логин и пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }