private void buttonOk_Click(object sender, EventArgs e) { ClientsCore.EditClient(clientID, textBoxName.Text, textBoxPhone.Text, textBoxEmeil.Text, Convert.ToInt32(textBoxStaticDiscunt.Text), textBoxOther.Text, textBoxDiscountReasone.Text, comboBoxVisible.SelectedItem.ToString() == GeneralConstants.YES ? 1 : 0); ClientsCore.GetClients(); AdminForm.instance.UpdateDataGridViewClients(); this.Close(); }
private void buttonOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxDiscount.Text) && string.IsNullOrEmpty(richTextBoxReasone.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_DISCOUNT_AND_REASONE); } else if (string.IsNullOrEmpty(textBoxDiscount.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_DISCOUNT); } else if (string.IsNullOrEmpty(richTextBoxReasone.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_DISCOUNT_REASONE); } else { bool isOk = true; int discount = 0; try { discount = Convert.ToInt32(textBoxDiscount.Text); if (discount < 0 || discount >= 100) { isOk = false; } } catch { isOk = false; } if (!isOk) { ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_DISCOUNT); } else { ClientsCore.EditClient(client.id, client.name, client.phone, client.email, discount, client.comment, richTextBoxReasone.Text, client.visible); ClientsCore.GetClients(); ClientDetailsForm.instance.UpdateDiscount(); this.Close(); } } }