private async void Btn_save_Click(object sender, RoutedEventArgs e) {//save try { HelpClass.StartAwait(grid_main); if (HelpClass.validateWindow(requiredControlList, this) && HelpClass.IsValidEmailWindow(this)) { tb_custCode.Text = await HelpClass.generateRandomString(5, "", "Customers", customerID); customer.custCode = tb_custCode.Text; customer.custname = tb_custname.Text; customer.lastName = tb_lastName.Text; customer.countryId = Convert.ToInt32(cb_country.SelectedValue); customer.email = tb_email.Text; customer.mobile = cb_areaMobile.Text + "-" + tb_mobile.Text; if (!tb_phone.Text.Equals("")) { customer.phone = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text; } if (!tb_fax.Text.Equals("")) { customer.fax = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text; } if (cb_custlevel.SelectedValue != null) { customer.custlevel = cb_custlevel.SelectedValue.ToString(); } customer.company = tb_company.Text; customer.address = tb_address.Text; customer.notes = tb_notes.Text; customer.isActive = 1; customer.createUserId = MainWindow.userLogin.userId; customer.updateUserId = MainWindow.userLogin.userId; int s = await customer.Save(customer); if (s <= 0) { Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn); } else { Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopSave"), animation: ToasterAnimation.FadeIn); if (isImgPressed) { int customerId = s; string b = await customer.uploadImage(imgFileName, Md5Encription.MD5Hash("Inc-m" + customerId.ToString()), customerId); customer.image = b; isImgPressed = false; } isOk = true; this.Close(); } } HelpClass.EndAwait(grid_main); } catch (Exception ex) { HelpClass.EndAwait(grid_main); HelpClass.ExceptionMessage(ex, this); } }