private async void loginButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbEmail.Text) || string.IsNullOrWhiteSpace(tbPassword.Text)) { Notification.Warning("Vui lòng nhập đầy đủ thông tin"); return; } var res = await UserController.Login(tbEmail.Text, tbPassword.Text); if (res == null || !res.IsSuccess) { Notification.Error(res == null ? "Tài khoản hoặc mật khẩu không chính xác" : HandleError <UserErrorMessage> .GetErrorString(res.Messages)); return; } User u = (User)res.Data; Store.user = u; this.Hide(); activeLayout(Store.user.RoleName); }
private async Task getCombo() { var res = await ComboController.GetComboByID(_comboListPage.CurrentEditingCombo.Id); if (res == null || !res.IsSuccess) { Notification.Error(HandleError <ComboErrorMessage> .GetErrorString(res.Messages)); } combo = res.Data; }
public async void DeleteOrder(int id) { var res = await OrderController.DeleteOrder(id); if (res == null || !res.IsSuccess) { Notification.Error(HandleError <OrderErrorMessage> .GetErrorString(res.Messages)); } else { Notification.Success("Success"); renderOrders(); } }
private async Task <bool> getOrderDetail() { var res = await OrderController.GetOrderByID(orderID); if (res == null) { return(false); } if (!res.IsSuccess) { Notification.Error(HandleError <OrderErrorMessage> .GetErrorString(res.Messages)); return(false); } order = res.Data; return(true); }
private async void button1_Click(object sender, EventArgs e) { string catalogName = tbCatalogName.Text; bool isValid = true; if (string.IsNullOrWhiteSpace(catalogName)) { errorProvider.SetError(tbCatalogName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbCatalogName, null); } if (!isValid) { return; } var res = await CatalogController.UpdateCatalog( _catalogListPage.CurrentEditingCatalog.Id, new Catalog { CatalogName = catalogName, }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <CatalogErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); _catalogListPage.renderCatalogs(); this.Hide(); }
private async void button1_Click(object sender, EventArgs e) { _error.SetError(tbName, string.IsNullOrWhiteSpace(tbName.Text) ? activeError("Bắt buộc") : null); _error.SetError(tbEmail, string.IsNullOrWhiteSpace(tbEmail.Text) ? activeError("Bắt buộc") : null); _error.SetError(tbPhone, string.IsNullOrWhiteSpace(tbPhone.Text) ? activeError("Bắt buộc") : null); _error.SetError(tbAddress, string.IsNullOrWhiteSpace(tbAddress.Text) ? activeError("Bắt buộc") : null); _error.SetError(tbPassword, string.IsNullOrWhiteSpace(tbPassword.Text) ? activeError("Bắt buộc") : null); _error.SetError(tbConfirmPassword, tbConfirmPassword.Equals(tbPassword.Text) ? activeError("Không khớp") : null); if (isError) { isError = false; return; } var res = await UserController.CreateUser(new User { FullName = tbName.Text, Address = tbAddress.Text, Email = tbEmail.Text, RoleName = _role, PhoneNumber = tbPhone.Text, Password = tbPassword.Text }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <UserErrorMessage> .GetErrorString(res.Messages)); } else { Notification.Success("Success"); _callback(); Close(); } }
public async void confirmOrder(int orderID, bool isAccept, DateTime delivaeryDate) { ServerResponse <object, OrderErrorMessage> res; if (isAccept) { res = await OrderController.AcceptOrder( orderID, new ConfirmOrderDTO { EmployeeId = Store.user.Id, DeliveryDate = delivaeryDate }); } else { res = await OrderController.RefuseOrder( orderID, new ConfirmOrderDTO { EmployeeId = Store.user.Id }); } if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <OrderErrorMessage> .GetErrorString(res.Messages)); } else { Notification.Success("Success"); renderOrders(); } }
private async void createComboButton_Click(object sender, EventArgs e) { string comboName = tbComboName.Text; bool isValid = true; if (string.IsNullOrWhiteSpace(comboName)) { errorProvider.SetError(tbComboName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbComboName, null); } if (discountPercentNumber.Value < 0) { errorProvider.SetError(discountPercentNumber, "Ko hop le"); isValid = false; } else { errorProvider.SetError(discountPercentNumber, null); } if (!isValid) { return; } List <int> productIDs = new List <int>(); foreach (Product item in products) { productIDs.Add(item.Id); } var res = await ComboController.CreateCombo( new CreateComboDTO { ComboName = comboName, OriginalPrice = calculateOriginalPrice().ToString(), Price = calculatePrice().ToString(), DiscountPercent = Convert.ToInt32(discountPercentNumber.Value), ProductIds = productIDs }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <ComboErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); _comboListPage.renderCombos(); this.Close(); }
private async void editButton_Click(object sender, EventArgs e) { string productName = tbProductName.Text; string productPrice = tbProductPrice.Text; Catalog productCatalog = (Catalog)cbProductCatalog.SelectedItem; int catalogID = productCatalog == null ? -1 : productCatalog.Id; bool isValid = true; if (string.IsNullOrWhiteSpace(productName)) { errorProvider.SetError(tbProductName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbProductName, null); } if (string.IsNullOrWhiteSpace(productPrice)) { errorProvider.SetError(tbProductPrice, "Ko hop le"); isValid = false; } else { try { Convert.ToDecimal(productPrice); errorProvider.SetError(tbProductName, null); } catch (Exception) { errorProvider.SetError(tbProductPrice, "Ko hop le"); isValid = false; } } if (catalogID == -1) { errorProvider.SetError(cbProductCatalog, "Ko hop le"); isValid = false; } else { errorProvider.SetError(cbProductCatalog, null); } if (!isValid) { return; } var res = await ProductController.UpdateProduct( _productListPage.CurrentEditingProduct.Id, productImage, fileName, new Product { ProductName = productName, Price = Convert.ToDecimal(productPrice), CatalogId = catalogID, InStock = Convert.ToInt32(inStockNumber.Value) }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <ProductErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); _productListPage.renderProducts(); this.Hide(); }
private async void updateComboButton_Click(object sender, EventArgs e) { string comboName = tbComboName.Text; bool isValid = true; if (string.IsNullOrWhiteSpace(comboName)) { errorProvider.SetError(tbComboName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbComboName, null); } if (discountPercentNumber.Value < 0) { errorProvider.SetError(discountPercentNumber, "Ko hop le"); isValid = false; } else { errorProvider.SetError(discountPercentNumber, null); } if (!isValid) { return; } decimal originalPrice = 0; foreach (Product item in combo.products) { originalPrice += item.Price; } var res = await ComboController.UpdateCombo( combo.Id, new UpdateComboDTO { ComboName = comboName, OriginalPrice = originalPrice.ToString(), Price = (originalPrice - (originalPrice * discountPercentNumber.Value / 100)).ToString(), DiscountPercent = Convert.ToInt32(discountPercentNumber.Value), DeletedProductIds = deletedProductIds, InsertedProductIds = insertedProductIds }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <ComboErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); deletedProductIds = new List <int>(); insertedProductIds = new List <int>(); _comboListPage.renderCombos(); this.renderCombo(true); }
private async void button1_Click(object sender, EventArgs e) { string productName = tbProductName.Text; string productPrice = tbProductPrice.Text; Catalog productCatalog = (Catalog)cbProductCatalog.SelectedItem; int catalogID = productCatalog == null ? -1 : productCatalog.Id; bool isValid = true; if (string.IsNullOrWhiteSpace(productName)) { errorProvider.SetError(tbProductName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbProductName, null); } if (string.IsNullOrWhiteSpace(productPrice) || !productPrice.All(char.IsNumber)) { errorProvider.SetError(tbProductPrice, "Ko hop le"); isValid = false; } else { errorProvider.SetError(tbProductName, null); } if (catalogID == -1) { errorProvider.SetError(cbProductCatalog, "Ko hop le"); isValid = false; } else { errorProvider.SetError(cbProductCatalog, null); } if (!isValid) { return; } if (productImage == null) { Notification.Error("Vui lòng chọn hình ảnh"); return; } var res = await ProductController.CreateProduct( productImage, fileName, new Product { ProductName = productName, Price = Convert.ToDecimal(productPrice), InStock = 0, CatalogId = catalogID }); if (!res.IsSuccess) { Notification.Error(HandleError <ProductErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); _productListPage.renderProducts(); this.Hide(); }