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; } }
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(); } }
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(); }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var user = GetCurrentuser(); Gateway.Call(new DeleteUser() { Id = user.Id }); RefreshData(); }
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; }
private void simpleButton3_Click(object sender, EventArgs e) { if (!ValidateData()) { return; } currentDelivery.Date = DateTime.Now; Gateway.Call(new RegisterDelivery() { Delivery = currentDelivery }); this.Close(); }
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(); }
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(); } }
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(); }
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(); }
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("Выберете клиента для вывода в отчёт."); } }
private void RefrehData() { productBindingSource.DataSource = Gateway.Call(new GetAllProduct()).Result; }
private void RefreshData() { userLocalBindingSource.DataSource = Gateway.Call(new GetAllUser()).Result; UserLocalBindingSource_CurrentChanged(null, null); }
private void SelectorClient_Load(object sender, EventArgs e) { clientBindingSource.DataSource = Gateway.Call(new GetAllClient()).Result; }