FormAddEdit.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace СУБД_Альфапол
  11. {
  12. public partial class FormAddEdit : Form
  13. {
  14. public FormAddEdit()
  15. {
  16. InitializeComponent();
  17. }
  18. private void FormAddEdit_Load(object sender, EventArgs e)
  19. {
  20. this.postCodeTableAdapter.Fill(this.alfafloorGDVDataSet1.PostCode);
  21. this.streetTableAdapter.Fill(this.alfafloorGDVDataSet1.Street);
  22. this.cityTableAdapter.Fill(this.alfafloorGDVDataSet1.City);
  23. this.regionTableAdapter.Fill(this.alfafloorGDVDataSet1.Region);
  24. this.typePartnerTableAdapter.Fill(this.alfafloorGDVDataSet1.TypePartner);
  25. this.partnerTableAdapter.Fill(this.alfafloorGDVDataSet1.Partner);
  26. lblIdPartner.Hide();
  27. if (lblTitleForm.Text == "Добавление партнера")
  28. {
  29. bsPartner.AddNew();
  30. }
  31. }
  32. private void btnSave_Click(object sender, EventArgs e)
  33. {
  34. if (tbxNamepartner.Text == "" || tbxEmail.Text == "" || tbxHouse.Text == "" || tbxName.Text == "" || tbxPatronomyc.Text == "" ||
  35. tbxPhone.Text == "" || tbxRating.Text == "" || tbxSurname.Text == "" || cmbCity.SelectedIndex == -1 || cmbPostCode.SelectedIndex == -1 || cmbRegion.SelectedIndex == -1 || cmbStreet.SelectedIndex == -1 || cmbTypePartner.SelectedIndex == -1)
  36. {
  37. MessageBox.Show("Все поля должны быть заполнены!", "Внимание, ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  38. return;
  39. }
  40. if (int.Parse(tbxRating.Text) < 0 || tbxRating.Text == "-0")
  41. {
  42. MessageBox.Show("Рейтинг целое неотрицательное число!", "Внимание, ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  43. return;
  44. }
  45. bsPartner.EndEdit();
  46. this.partnerTableAdapter.Update(this.alfafloorGDVDataSet1.Partner);
  47. this.Close();
  48. }
  49. private void tbxRating_Validating(object sender, CancelEventArgs e)
  50. {
  51. try
  52. {
  53. int.Parse(tbxRating.Text);
  54. }
  55. catch
  56. {
  57. MessageBox.Show("Рейтинг должен быть целым неотрицательным числом!", "Внимание, ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  58. return;
  59. }
  60. //if (tbxRating.Text.Contains(','))
  61. //{
  62. //}
  63. }
  64. }
  65. }