FormEdit.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace Zoo
  5. {
  6. public class FormEdit : Form
  7. {
  8. TextBox txtName;
  9. TextBox txtPhone;
  10. TextBox txtEmail;
  11. TextBox txtComment;
  12. Button btnSave;
  13. Button btnCancel;
  14. public FormEdit()
  15. {
  16. InitializeComponent();
  17. }
  18. private void InitializeComponent()
  19. {
  20. Text = "Редактирование записи";
  21. StartPosition = FormStartPosition.CenterParent;
  22. Size = new Size(420, 370);
  23. FormBorderStyle = FormBorderStyle.FixedSingle;
  24. MaximizeBox = false;
  25. BackColor = Color.WhiteSmoke;
  26. Font = new Font("Segoe UI", 10);
  27. Label lblTitle = new Label();
  28. lblTitle.Text = "Данные пользователя";
  29. lblTitle.Font = new Font("Segoe UI", 15, FontStyle.Bold);
  30. lblTitle.AutoSize = true;
  31. lblTitle.Location = new Point(90, 20);
  32. Label lblName = new Label();
  33. lblName.Text = "ФИО";
  34. lblName.Location = new Point(30, 70);
  35. lblName.AutoSize = true;
  36. txtName = new TextBox();
  37. txtName.Location = new Point(130, 66);
  38. txtName.Size = new Size(230, 30);
  39. Label lblPhone = new Label();
  40. lblPhone.Text = "Телефон";
  41. lblPhone.Location = new Point(30, 115);
  42. lblPhone.AutoSize = true;
  43. txtPhone = new TextBox();
  44. txtPhone.Location = new Point(130, 111);
  45. txtPhone.Size = new Size(230, 30);
  46. Label lblEmail = new Label();
  47. lblEmail.Text = "Email";
  48. lblEmail.Location = new Point(30, 160);
  49. lblEmail.AutoSize = true;
  50. txtEmail = new TextBox();
  51. txtEmail.Location = new Point(130, 156);
  52. txtEmail.Size = new Size(230, 30);
  53. Label lblComment = new Label();
  54. lblComment.Text = "Комментарий";
  55. lblComment.Location = new Point(30, 205);
  56. lblComment.AutoSize = true;
  57. txtComment = new TextBox();
  58. txtComment.Location = new Point(130, 201);
  59. txtComment.Size = new Size(230, 60);
  60. txtComment.Multiline = true;
  61. btnSave = new Button();
  62. btnSave.Text = "Сохранить";
  63. btnSave.Location = new Point(60, 285);
  64. btnSave.Size = new Size(120, 40);
  65. btnSave.BackColor = Color.DodgerBlue;
  66. btnSave.ForeColor = Color.White;
  67. btnSave.FlatStyle = FlatStyle.Flat;
  68. btnSave.Click += BtnSave_Click;
  69. btnCancel = new Button();
  70. btnCancel.Text = "Отмена";
  71. btnCancel.Location = new Point(220, 285);
  72. btnCancel.Size = new Size(120, 40);
  73. btnCancel.BackColor = Color.Gray;
  74. btnCancel.ForeColor = Color.White;
  75. btnCancel.FlatStyle = FlatStyle.Flat;
  76. btnCancel.Click += (s, e) => Close();
  77. Controls.Add(lblTitle);
  78. Controls.Add(lblName);
  79. Controls.Add(txtName);
  80. Controls.Add(lblPhone);
  81. Controls.Add(txtPhone);
  82. Controls.Add(lblEmail);
  83. Controls.Add(txtEmail);
  84. Controls.Add(lblComment);
  85. Controls.Add(txtComment);
  86. Controls.Add(btnSave);
  87. Controls.Add(btnCancel);
  88. }
  89. private void BtnSave_Click(object sender, EventArgs e)
  90. {
  91. MessageBox.Show(
  92. "Данные успешно сохранены!",
  93. "Информация",
  94. MessageBoxButtons.OK,
  95. MessageBoxIcon.Information);
  96. Close();
  97. }
  98. }
  99. }