//-------------------------------------------------------- private void bttnOK_Click(object sender, EventArgs e) { if (bttnOK.Text == "Далее") { MySqlCommand cAdd = new MySqlCommand("INSERT INTO клиент(`Номер и серия паспорта`, ФИО, `Дата рождения`, СНИЛС, `Номер телефона`, `Адрес проживания`, `e-mail`) VALUES " + "('" + tbPassport.Text + "', '" + tbFN.Text + "', '" + datePickerBirthday.Text + "', '" + tbSNILS.Text + "', '" + tbNumbPhone.Text + "', '" + tbAdress.Text + "', '" + tbEMail.Text + "')", frmAuthorization.connection); if (cAdd.ExecuteNonQuery() == 1) { DialogResult = DialogResult.OK; string passport = tbPassport.Text; frmAddRequest FAR = new frmAddRequest(passport, UserID); FAR.bttnOK.Text = "Добавить"; FAR.labelPanelReq.Text = "Добавить заявку"; FAR.labelPanelReq.Left = (ClientSize.Width - FAR.labelPanelReq.Width) / 2; FAR.ShowDialog(); } } else if (bttnOK.Text == "Изменить") { MySqlCommand cChng = new MySqlCommand("UPDATE клиент SET `Номер и серия паспорта`= '" + tbPassport.Text + "', ФИО= '" + tbFN.Text + "', `Дата рождения`= '" + datePickerBirthday.Text + "', " + "СНИЛС= '" + tbSNILS.Text + "', `Номер телефона`= '" + tbNumbPhone.Text + "', `Адрес проживания`= '" + tbAdress.Text + "', `e-mail`= '" + tbEMail.Text + "' WHERE `Номер и серия паспорта`= '" + Passport + "'", frmAuthorization.connection); MySqlCommand cChng2 = new MySqlCommand("UPDATE заявка SET `Номер и серия паспорта`= '" + tbPassport.Text + "' WHERE `Номер и серия паспорта`= '" + Passport + "'", frmAuthorization.connection); if (cChng.ExecuteNonQuery() == 1) { cChng2.ExecuteNonQuery(); DialogResult = DialogResult.OK; } } }
/* * Add data */ private void bttnAdd_Click(object sender, EventArgs e) { if (tabMenu.SelectedTab == pageClients) { try { frmAddRequest FAR = new frmAddRequest(dataTableClients.SelectedRows[0].Cells[0].Value.ToString(), UserID); FAR.bttnOK.Text = "Добавить"; FAR.labelPanelReq.Text = "Добавить заявку"; FAR.labelPanelReq.Left = (ClientSize.Width - FAR.labelPanelReq.Width) / 2; FAR.ShowDialog(); if (FAR.DialogResult == DialogResult.OK) { bttnRefresh_Click(sender, e); } } catch { ErrorClient EC = new ErrorClient(); EC.Show(); } } else if (tabMenu.SelectedTab == pageRequests) { frmAddClient FAC = new frmAddClient(UserID, null); FAC.ShowDialog(); if (FAC.DialogResult == DialogResult.OK) { bttnRefresh_Click(sender, e); } } }
/* * Change data */ private void bttnChange_Click(object sender, EventArgs e) { try { if (tabMenu.SelectedTab == pageClients) { frmAddClient FAC = new frmAddClient(dataTableClients.SelectedRows[0].Cells[0].Value.ToString(), UserID); FAC.tbPassport.Text = dataTableClients.SelectedRows[0].Cells[0].Value.ToString(); FAC.tbFN.Text = dataTableClients.SelectedRows[0].Cells[1].Value.ToString(); FAC.datePickerBirthday.Text = dataTableClients.SelectedRows[0].Cells[2].Value.ToString(); FAC.tbSNILS.Text = dataTableClients.SelectedRows[0].Cells[3].Value.ToString(); FAC.tbNumbPhone.Text = dataTableClients.SelectedRows[0].Cells[4].Value.ToString(); FAC.tbAdress.Text = dataTableClients.SelectedRows[0].Cells[5].Value.ToString(); FAC.tbEMail.Text = dataTableClients.SelectedRows[0].Cells[6].Value.ToString(); FAC.ShowDialog(); if (FAC.DialogResult == DialogResult.OK) { bttnRefresh_Click(sender, e); } } else if (tabMenu.SelectedTab == pageRequests) { frmAddRequest FAR = new frmAddRequest(dataTableRequests.SelectedRows[0].Cells[0].Value.ToString(), UserID); FAR.cbNameAnalysis.Text = dataTableRequests.SelectedRows[0].Cells[1].Value.ToString(); FAR.datePickerRequest.Text = dataTableRequests.SelectedRows[0].Cells[4].Value.ToString(); FAR.tbResult.Text = dataTableRequests.SelectedRows[0].Cells[5].Value.ToString(); FAR.bttnOK.Text = "Подтвердить"; FAR.labelPanelReq.Text = "Подтвердить результат анализа"; FAR.labelPanelReq.Left = (ClientSize.Width - FAR.labelPanelReq.Width) / 2; FAR.ShowDialog(); if (FAR.DialogResult == DialogResult.OK) { bttnRefresh_Click(sender, e); } } else if (tabMenu.SelectedTab == pageServices) { frmAddServices FAS = new frmAddServices(dataTableServices.SelectedRows[0].Cells[0].Value.ToString()); FAS.tbName.Text = dataTableServices.SelectedRows[0].Cells[0].Value.ToString(); FAS.tbPrice.Text = dataTableServices.SelectedRows[0].Cells[1].Value.ToString(); FAS.tbTerm.Text = dataTableServices.SelectedRows[0].Cells[2].Value.ToString(); FAS.tbRecommendation.Text = dataTableServices.SelectedRows[0].Cells[3].Value.ToString(); FAS.bttnOK.Text = "Изменить"; FAS.labelPanelAdm.Text = "Изменить данные услуги"; FAS.labelPanelAdm.Left = (ClientSize.Width - FAS.labelPanelAdm.Width) / 2; FAS.ShowDialog(); if (FAS.DialogResult == DialogResult.OK) { bttnRefresh_Click(sender, e); } } } catch { ErrorChangeData errorCD = new ErrorChangeData(); errorCD.Show(); } }