private void выходToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("Выйти?", "Выход", MessageBoxButtons.YesNo)) { LoginForm.GetInstance().Close(); } }
public void buttonSubmit_Click(object sender, EventArgs e) { if (isEditMode)//если включен режим редактирования { if (surnameBox.Text == "" || nameBox.Text == "" || patronymicBox.Text == "" || emailBox.Text == "" || passportID.Text == "" || erroremail.Visible == true) { MessageBox.Show("Некоторые поля заполнены неверно!"); } else { bool updateSucces = db.RunInsert("update Employees set Surname='" + surnameBox.Text + "', Name='" + nameBox.Text + "', Patronymic='" + patronymicBox.Text + "', Email='" + emailBox.Text + "', Passport_Seria='" + passportID.Text + "', Passport_GivenBy='" + givenByRichText.Text + "', Passport_GivenWhen='" + dateGiven.Value.ToString("yyyy-MM-dd") + "', Passport_RegistrationAddress='" + regAddressText.Text + "' where ID_Employee = " + userID); if (updateSucces) { if (Owner is ClientsCatalog) //если была открыта из справочника { (Owner as ClientsCatalog).UpdateTable(); (Owner as ClientsCatalog).SelectRowWithID(userID); } this.Close(); } else { MessageBox.Show("Ошибка записи"); } } } else { if (surnameBox.Text == "" || nameBox.Text == "" || patronymicBox.Text == "" || emailBox.Text == "" || passportID.Text == "" || errorPassPic.Visible == true || loginErrorPic.Visible == true || erroremail.Visible == true) { MessageBox.Show("Не все данные заполнены верно!", "Ошибка"); } else { //if(db.RunInsert()) if (db.AddNewEmployee(loginBox.Text, passwordBox.Text, surnameBox.Text, nameBox.Text, patronymicBox.Text, dateBirth.Value, emailBox.Text, passportID.Text, givenByRichText.Text, dateGiven.Value, regAddressText.Text)) { MessageBox.Show("Регистрация прошла успешно"); this.Close(); if (Owner is ClientsCatalog) { (Owner as ClientsCatalog).InitializeDatagrid(); (Owner as ClientsCatalog).SelectLastRow(); } else { LoginForm.GetInstance().Show(); } } else { MessageBox.Show("Ошибка"); } } } if (bollean) { try { byte[] img = null; FileStream fs = new FileStream(imgLoc, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); img = br.ReadBytes((int)fs.Length); DataTable dt = db.RunSelect("Select * From Image where ID_employee = '" + UserID + "' "); if (dt.Rows.Count > 0) { connection.Open(); string sqlQuery = "update Image set Image = @images where ID_employee = '" + UserID + "' "; cmd = new SqlCommand(sqlQuery, connection); cmd.Parameters.Add(new SqlParameter("@images", img)); int N = cmd.ExecuteNonQuery(); connection.Close(); MessageBox.Show(N.ToString() + " Фотография изменена"); } else { connection.Open(); string sqlQuery = "insert into Image values('" + UserID + "', @images)"; cmd = new SqlCommand(sqlQuery, connection); cmd.Parameters.Add(new SqlParameter("@images", img)); int N = cmd.ExecuteNonQuery(); MessageBox.Show(N.ToString() + " Фотография добавлена"); connection.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { LoginForm.GetInstance().Hide(); new RegForm().Show(this); }
private void ClientForm_FormClosed(object sender, FormClosedEventArgs e) { LoginForm.GetInstance().Show(); }
private void выходToolStripMenuItem_Click(object sender, EventArgs e) { LoginForm.GetInstance().Close(); }