Esempio n. 1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            textEdit1.CausesValidation = true;
            textEdit2.CausesValidation = true;

            if (ValidateChildren())
            {
                if (simpleButton1.Text == "Добавить")
                {
                    Gateway.Call(new CreateProduct()
                    {
                        Product = DataSource
                    });
                }
                else
                {
                    var product = DataSource;

                    product.Id = currentProduct.Id;

                    Gateway.Call(new UpdateProduct()
                    {
                        Product = product
                    });
                }

                this.Close();
            }
            else
            {
                XtraMessageBox.Show("Некорректно заполнены поля формы");
                textEdit1.CausesValidation = false;
                textEdit2.CausesValidation = false;
            }
        }
Esempio n. 2
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textEdit1.Text) || string.IsNullOrEmpty(textEdit2.Text))
            {
                XtraMessageBox.Show("Пароль или логин не могут быть пустыми!", "Ошибка", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return;
            }

            var user = new UserLocal()
            {
                UserName = textEdit1.Text, Password = textEdit2.Text, CreatedDate = DateTime.Now
            };

            if (!Gateway.Call(new CreateUser()
            {
                User = user
            }))
            {
                XtraMessageBox.Show("Пользователь с таким логином уже существует!", "Ошибка", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Close();
            }
        }
Esempio n. 3
0
        private void toggleSwitch2_EditValueChanged(object sender, EventArgs e)
        {
            var edit = sender as ToggleSwitch;
            var user = GetCurrentuser();

            if (edit.IsOn)
            {
                if (user.Roles.Contains("Opr"))
                {
                    return;
                }
                else
                {
                    user.Roles.Add("Opr");
                }
            }
            else
            {
                if (!user.Roles.Contains("Opr"))
                {
                    return;
                }
                else
                {
                    user.Roles.Remove("Opr");
                }
            }

            Gateway.Call(new UpdateUser()
            {
                User = user
            });
            RefreshData();
        }
Esempio n. 4
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var user = GetCurrentuser();

            Gateway.Call(new DeleteUser()
            {
                Id = user.Id
            });
            RefreshData();
        }
Esempio n. 5
0
        private void RefreshData()
        {
            OnPrivate();

            clientBindingSource.DataSource   = Gateway.Call(new GetAllClient()).Result;
            clientBindingSource1.DataSource  = Gateway.Call(new GetAllClient()).Result;
            productBindingSource.DataSource  = Gateway.Call(new GetAllProduct()).Result;
            deliveryBindingSource.DataSource = Gateway.Call(new GetAllDelivery()).Result;

            clientBindingSource1.CurrentChanged += ClientBindingSource1_CurrentChanged;
        }
Esempio n. 6
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (!ValidateData())
            {
                return;
            }

            currentDelivery.Date = DateTime.Now;
            Gateway.Call(new RegisterDelivery()
            {
                Delivery = currentDelivery
            });
            this.Close();
        }
Esempio n. 7
0
        private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!(clientBindingSource.Current is Client currentClient) || tabPane1.SelectedPageIndex != 0)
            {
                XtraMessageBox.Show("Сначала выберете клиента", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }

            Gateway.Call(new DeleteClient()
            {
                Client = currentClient
            });
            RefreshData();
        }
Esempio n. 8
0
 private void ClientBindingSource1_CurrentChanged(object sender, System.EventArgs e)
 {
     if (clientBindingSource1.Current is Client buffer)
     {
         accountingBindingSource.DataSource = Gateway.Call(new GetAccountingByOwnerId()
         {
             Id = buffer.Id
         }).Result;
     }
     else
     {
         accountingBindingSource.Clear();
     }
 }
Esempio n. 9
0
        private void barButtonItem11_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!(deliveryBindingSource.Current is Delivery currentDelivery) || tabPane1.SelectedPageIndex != 2)
            {
                XtraMessageBox.Show("Сначала выберете поставку", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }

            Gateway.Call(new DeleteDelivery()
            {
                Delivery = currentDelivery
            });
            RefreshData();
        }
Esempio n. 10
0
        private void barButtonItem7_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!(productBindingSource.Current is Product currentProduct) || tabPane1.SelectedPageIndex == 1)
            {
                XtraMessageBox.Show("Сначала выберете товар", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }

            Gateway.Call(new DeleteProduct()
            {
                Product = currentProduct
            });
            RefreshData();
        }
Esempio n. 11
0
 private void barButtonItem13_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (tabPane1.SelectedPageIndex == 3)
     {
         if (clientBindingSource1.Current is Client buffer)
         {
             buffer.Accountings = Gateway.Call(new GetAccountingByOwnerId()
             {
                 Id = buffer.Id
             }).Result;
             var report = new Report1();
             report.objectDataSource1.DataSource = buffer;
             report.ShowPreview();
         }
     }
     else
     {
         XtraMessageBox.Show("Выберете клиента для вывода в отчёт.");
     }
 }
Esempio n. 12
0
 private void RefrehData()
 {
     productBindingSource.DataSource = Gateway.Call(new GetAllProduct()).Result;
 }
Esempio n. 13
0
 private void RefreshData()
 {
     userLocalBindingSource.DataSource = Gateway.Call(new GetAllUser()).Result;
     UserLocalBindingSource_CurrentChanged(null, null);
 }
Esempio n. 14
0
 private void SelectorClient_Load(object sender, EventArgs e)
 {
     clientBindingSource.DataSource = Gateway.Call(new GetAllClient()).Result;
 }