FormProfile.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace СУБД_Альфапол
  12. {
  13. public partial class FormProfile : Form
  14. {
  15. public FormProfile()
  16. {
  17. InitializeComponent();
  18. }
  19. private void FormProfile_Load(object sender, EventArgs e)
  20. {
  21. // TODO: This line of code loads data into the 'dbAlphapolAGDataSet.Manager' table. You can move, or remove it, as needed.
  22. this.managerTableAdapter.Fill(this.dbAlphapolAGDataSet.Manager);
  23. lblPass.Hide();
  24. try
  25. {
  26. pbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\photo\\" + lblPhoto.Text);
  27. }
  28. catch { }
  29. lblPhoto.Hide();
  30. }
  31. private void BtnSave_Click(object sender, EventArgs e)
  32. {
  33. if (tbxPass1.Text != "")
  34. {
  35. if (tbxPass1.Text != tbxPass2.Text)
  36. {
  37. MessageBox.Show("Пароли должны совпадать!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  38. return;
  39. }
  40. lblPass.Text = tbxPass1.Text;
  41. }
  42. if (OpenPhoto.FileName != "")
  43. {
  44. string UniqueFileName = Path.GetRandomFileName() + Path.GetExtension(OpenPhoto.FileName);
  45. lblPhoto.Text = UniqueFileName;
  46. try
  47. {
  48. File.Copy(OpenPhoto.FileName, Application.StartupPath + "\\photo\\" + lblPhoto.Text);
  49. }
  50. catch { }
  51. }
  52. bsMeneger.EndEdit();
  53. this.managerTableAdapter.Update(this.dbAlphapolAGDataSet.Manager);
  54. Close();
  55. }
  56. private void tbxPass1_TextChanged(object sender, EventArgs e)
  57. {
  58. }
  59. private void tbxPass2_TextChanged(object sender, EventArgs e)
  60. {
  61. }
  62. private void cbxShowPass_CheckedChanged(object sender, EventArgs e)
  63. {
  64. tbxPass1.UseSystemPasswordChar = !cbxShowPass.Checked;
  65. tbxPass2.UseSystemPasswordChar = !cbxShowPass.Checked;
  66. }
  67. private void btnLoadPhoto_Click(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. if (OpenPhoto.ShowDialog() == DialogResult.OK)
  72. pbxPhoto.Image = Image.FromFile(OpenPhoto.FileName);
  73. }
  74. catch
  75. {
  76. MessageBox.Show("Не удалось загрузить фотографию!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  77. OpenPhoto.FileName = "";
  78. return;
  79. }
  80. MessageBox.Show("Фотография успешно загружена!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  81. }
  82. private void btnDelPhoto_Click(object sender, EventArgs e)
  83. {
  84. if (MessageBox.Show("Удалить фотографию фотографию?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  85. {
  86. pbxPhoto.Image = null;
  87. lblPhoto.Text = "";
  88. OpenPhoto.FileName = "";
  89. }
  90. }
  91. }
  92. }