using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace СУБД_Альфапол { public partial class FormProfile : Form { public FormProfile() { InitializeComponent(); } private void FormProfile_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'dbAlphapolAGDataSet.Manager' table. You can move, or remove it, as needed. this.managerTableAdapter.Fill(this.dbAlphapolAGDataSet.Manager); lblPass.Hide(); try { pbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\photo\\" + lblPhoto.Text); } catch { } lblPhoto.Hide(); } private void BtnSave_Click(object sender, EventArgs e) { if (tbxPass1.Text != "") { if (tbxPass1.Text != tbxPass2.Text) { MessageBox.Show("Пароли должны совпадать!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } lblPass.Text = tbxPass1.Text; } if (OpenPhoto.FileName != "") { string UniqueFileName = Path.GetRandomFileName() + Path.GetExtension(OpenPhoto.FileName); lblPhoto.Text = UniqueFileName; try { File.Copy(OpenPhoto.FileName, Application.StartupPath + "\\photo\\" + lblPhoto.Text); } catch { } } bsMeneger.EndEdit(); this.managerTableAdapter.Update(this.dbAlphapolAGDataSet.Manager); Close(); } private void tbxPass1_TextChanged(object sender, EventArgs e) { } private void tbxPass2_TextChanged(object sender, EventArgs e) { } private void cbxShowPass_CheckedChanged(object sender, EventArgs e) { tbxPass1.UseSystemPasswordChar = !cbxShowPass.Checked; tbxPass2.UseSystemPasswordChar = !cbxShowPass.Checked; } private void btnLoadPhoto_Click(object sender, EventArgs e) { try { if (OpenPhoto.ShowDialog() == DialogResult.OK) pbxPhoto.Image = Image.FromFile(OpenPhoto.FileName); } catch { MessageBox.Show("Не удалось загрузить фотографию!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error); OpenPhoto.FileName = ""; return; } MessageBox.Show("Фотография успешно загружена!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void btnDelPhoto_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить фотографию фотографию?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { pbxPhoto.Image = null; lblPhoto.Text = ""; OpenPhoto.FileName = ""; } } } }