private void ButtonAcceptPId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericPId.Value); string query = Commands.SelectPatientWhereId(id); string[] data = new string[5]; ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusPId.Text = "Выбрано"; TextBoxStatusPId.ForeColor = Color.Green; data = ConnectedData.GetRowFromTable(); TextBoxPName.Text = data[1]; } else { TextBoxStatusPId.Text = "Не выбрано"; TextBoxStatusPId.ForeColor = Color.Red; TextBoxPName.ResetText(); MessageBox.Show("Пациента с таким id не существует!"); } }
private void PrescriptionsButtonDelete_Click(object sender, EventArgs e) { DeletePrescriptions deletePrescriptions = new DeletePrescriptions(); DialogResult status = deletePrescriptions.ShowDialog(); if (status == DialogResult.OK) { query = Commands.DeletePrescriptions(Models.Prescriptions.id1, Models.Prescriptions.id2, Models.Prescriptions.patientName); MessageBox.Show(query); int count; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); } else { count = DisconnectedData.DeleteData(query); } MessageBox.Show("Удалено: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); } }
private void MedicationButtonEdit_Click(object sender, EventArgs e) { UpdateMedications updateMedications = new UpdateMedications(connectionType); DialogResult status = updateMedications.ShowDialog(); if (status == DialogResult.OK) { query = Commands.UpdateMedications(Models.Medications.id1, Models.Medications.Name, Models.Medications.Price, Models.Medications.Quantity, Models.Medications.Volume, Models.Medications.MedicationType, Models.Medications.UsesType, Models.Medications.ManufactureType, Models.Medications.MixableList, Models.Medications.PreparationTime, Models.Medications.FiltrationTime); MessageBox.Show(query); int count; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); } else { count = DisconnectedData.UpdateData(query); } MessageBox.Show("Обновлено: " + count.ToString()); MedicationsPrint(SortTypes.IdAsc); } }
private void StorehouseFButtonEdit_Click(object sender, EventArgs e) { UpdateStorehouseFields updateStorehouseFields = new UpdateStorehouseFields(connectionType); DialogResult status = updateStorehouseFields.ShowDialog(); if (status == DialogResult.OK) { query = Commands.UpdateStorehouseF(Models.StorehouseField.id1, Models.StorehouseField.Quantity, Models.StorehouseField.Critical_quantity, Models.StorehouseField.StorehouseRequestsId, Models.StorehouseField.ManufactureDate, Models.StorehouseField.ShelfLife); MessageBox.Show(query); int count; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); } else { count = DisconnectedData.UpdateData(query); } MessageBox.Show("Обновлено: " + count.ToString()); StorehouseFPrint(SortTypes.IdAsc); } }
private void ButtonAcceptRId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int RId = Convert.ToInt32(NumericRId.Value); string query = Commands.SelectStorehouseRWhereId(RId); ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { data = ConnectedData.GetRowFromTable(); if (Convert.ToInt32(data[2]) == Convert.ToInt32(NumericMId.Value)) { TextBoxStatusRId.ForeColor = Color.Green; TextBoxStatusRId.Text = "Выбрано"; } else { TextBoxStatusRId.ForeColor = Color.Red; TextBoxStatusRId.Text = "Не выбрано"; MessageBox.Show("Записи с таким id для такого лекарства не существует!"); } } else { TextBoxStatusRId.ForeColor = Color.Red; TextBoxStatusRId.Text = "Не выбрано"; MessageBox.Show("Записи с таким id не существует!"); } }
private void InitializeDGVs(int id) { //if (connectionType == ConnectionTypes.Connected) //{ //} DGVDiagnoses.DataSource = null; DGVMedications.DataSource = null; diagnosesId.Clear(); medicationsId.Clear(); string query = Commands.SelectPrescriptionsDiagnosesWhereId(id); ConnectedData.SetCommand(query); int[] size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); int row = size[0]; int column = size[1]; dataDiagnoses = new string[row, column]; dataDiagnoses = ConnectedData.GetTableData(); DGVDiagnoses.RowCount = row + 1; for (int i = 0; i < row; i++) { diagnosesId.Add(Convert.ToInt32(dataDiagnoses[i, 1])); DGVDiagnoses[0, i].Value = Convert.ToInt32(dataDiagnoses[i, 1]); } query = Commands.SelectPrescriptionsMedicationsWhereId(id); ConnectedData.SetCommand(query); size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); row = size[0]; column = size[1]; dataMedications = new string[row, column]; dataMedications = ConnectedData.GetTableData(); DGVMedications.RowCount = row + 1; for (int i = 0; i < row; i++) { medicationsId.Add(Convert.ToInt32(dataMedications[i, 1]), Convert.ToInt32(dataMedications[i, 2])); DGVMedications[0, i].Value = Convert.ToInt32(dataMedications[i, 1]); DGVMedications[1, i].Value = Convert.ToInt32(dataMedications[i, 2]); } }
private void ButtonAcceptMId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericMId.Value); string query = Commands.SelectMedicationsWhereId(id); ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusMId.Text = "Выбрано"; TextBoxStatusMId.ForeColor = Color.Green; } else { TextBoxStatusMId.Text = "Не выбрано"; TextBoxStatusMId.ForeColor = Color.Red; MessageBox.Show("Лекарства с таким id не существует!"); } }
private void StorehouseFButtonDelete_Click(object sender, EventArgs e) { DeleteStorehouseFields deleteStorehouseFields = new DeleteStorehouseFields(); DialogResult status = deleteStorehouseFields.ShowDialog(); if (status == DialogResult.OK) { query = Commands.DeleteStorehouseF(Models.StorehouseField.id1, Models.StorehouseField.id2, Models.StorehouseField.MedicationsName); MessageBox.Show(query); int count; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); } else { count = DisconnectedData.DeleteData(query); } MessageBox.Show("Удалено: " + count.ToString()); StorehouseFPrint(SortTypes.IdAsc); } }
private void PrescriptionsButtonEdit_Click(object sender, EventArgs e) { UpdatePrescriptions updatePrescriptions = new UpdatePrescriptions(connectionType); DialogResult status = updatePrescriptions.ShowDialog(); if (status == DialogResult.OK) { query = Commands.UpdatePrescriptions(Models.Prescriptions.id1, Models.Prescriptions.doctorName, Models.Prescriptions.doctorSignature, Models.Prescriptions.doctorStamp, Models.Prescriptions.patientId); int count; MessageBox.Show(query); if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Обновлено основ: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.DeleteDiagnosesPrescriptions(Models.Prescriptions.id1); MessageBox.Show(query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Удалено диагнозов: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.DeletePrescriptionsMedications(Models.Prescriptions.id1); MessageBox.Show(query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Удалено лекарств: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.InsertDiagnosesPrescriptions(Models.Prescriptions.diagnosesId, Models.Prescriptions.id1); MessageBox.Show("3\n" + query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Добавлено диагнозов: " + count.ToString()); query = Commands.InsertPrescriptionsMedications(Models.Prescriptions.medicationsId, Models.Prescriptions.id1); MessageBox.Show("4\n" + query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Добавлено лекарств: " + count.ToString()); } else { count = DisconnectedData.UpdateData(query); MessageBox.Show("Обновлено основ: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.DeleteDiagnosesPrescriptions(Models.Prescriptions.id1); MessageBox.Show(query); count = DisconnectedData.DeleteData(query); MessageBox.Show("Удалено диагнозов: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.DeletePrescriptionsMedications(Models.Prescriptions.id1); MessageBox.Show(query); count = DisconnectedData.DeleteData(query); MessageBox.Show("Удалено лекарств: " + count.ToString()); PrescriptionsPrint(SortTypes.IdAsc); query = Commands.InsertDiagnosesPrescriptions(Models.Prescriptions.diagnosesId, Models.Prescriptions.id1); MessageBox.Show("3\n" + query); count = DisconnectedData.InsertData(query); MessageBox.Show("Добавлено диагнозов: " + count.ToString()); query = Commands.InsertPrescriptionsMedications(Models.Prescriptions.medicationsId, Models.Prescriptions.id1); MessageBox.Show("4\n" + query); count = DisconnectedData.InsertData(query); MessageBox.Show("Добавлено лекарств: " + count.ToString()); } PrescriptionsPrint(SortTypes.IdAsc); } }
private void PrescriptionsButtonAdd_Click(object sender, EventArgs e) { AddPrescriptions addPrescriptions = new AddPrescriptions(connectionType); DialogResult status = addPrescriptions.ShowDialog(); if (status == DialogResult.OK) { query = Commands.InsertPrescriptions(Models.Prescriptions.doctorName, Models.Prescriptions.doctorSignature, Models.Prescriptions.doctorStamp, Models.Prescriptions.patientId); int count; if (connectionType == ConnectionTypes.Connected) { MessageBox.Show("1\n" + query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Добавлено: " + count.ToString()); string[] data = new string[1]; query = Commands.SelectLastId("dbo.prescriptions"); MessageBox.Show("2\n" + query); ConnectedData.SetCommand(query); data = ConnectedData.GetRowFromTable(); int id = Convert.ToInt32(data[0]); query = Commands.InsertDiagnosesPrescriptions(Models.Prescriptions.diagnosesId, id); MessageBox.Show("3\n" + query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Добавлено: " + count.ToString()); query = Commands.InsertPrescriptionsMedications(Models.Prescriptions.medicationsId, id); MessageBox.Show("4\n" + query); ConnectedData.SetCommand(query); count = ConnectedData.UpdateData(); MessageBox.Show("Добавлено: " + count.ToString()); } else { count = DisconnectedData.InsertData(query); MessageBox.Show("Добавлено: " + count.ToString()); query = Commands.SelectLastId("dbo.prescriptions"); MessageBox.Show("2\n" + query); dataSet = DisconnectedData.GetTableData(query); DataTable dataTable = dataSet.Tables[0]; DataRow dataRow = dataTable.Rows[0]; int id = Convert.ToInt32(dataRow[0]); query = Commands.InsertDiagnosesPrescriptions(Models.Prescriptions.diagnosesId, id); MessageBox.Show("3\n" + query); count = DisconnectedData.InsertData(query); MessageBox.Show("Добавлено: " + count.ToString()); query = Commands.InsertPrescriptionsMedications(Models.Prescriptions.medicationsId, id); MessageBox.Show("4\n" + query); count = DisconnectedData.InsertData(query); MessageBox.Show("Добавлено: " + count.ToString()); } PrescriptionsPrint(SortTypes.IdAsc); } }
public Dictionary <int, string> GetPrescriptionsMedications() { query = Commands.SelectPrescriptionsMedications(); ConnectedData.SetCommand(query); Dictionary <int, string> list = new Dictionary <int, string>(); if (connectionType == ConnectionTypes.Connected) { int[] size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); int row = size[0]; int column = size[1]; string[,] data = new string[row, column]; data = ConnectedData.GetTableData(); int key = Convert.ToInt32(data[0, 0]); string str = ""; for (int i = 0; i < row; i++) { if (Convert.ToInt32(data[i, 0]) == key) { str += data[i, 1] + " " + data[i, 2] + "шт, "; } else { str = str.Remove(str.Length - 2); list.Add(key, str); str = ""; key = Convert.ToInt32(data[i, 0]); str += data[i, 1] + " " + data[i, 2] + "шт, "; } } str = str.Remove(str.Length - 2); list.Add(key, str); } else { dataSet = DisconnectedData.GetTableData(query); DataTable dataTable = dataSet.Tables[0]; DataRow dataRow = dataTable.Rows[0]; int key = Convert.ToInt32(dataRow[0]); string str = ""; for (int i = 0; i < dataTable.Rows.Count; i++) { dataRow = dataTable.Rows[i]; if (Convert.ToInt32(dataRow[0]) == key) { str += dataRow[1] + " " + dataRow[2] + "шт, "; } else { str = str.Remove(str.Length - 2); list.Add(key, str); str = ""; key = Convert.ToInt32(dataRow[0]); str += dataRow[1] + " " + dataRow[2] + "шт, "; } } str = str.Remove(str.Length - 2); list.Add(key, str); } return(list); }
public void PrescriptionsPrint(SortTypes sort, string name = "") { PrescriptionsListView.Items.Clear(); if (name != "") { query = Commands.SelectPrescriptions(sort, name); } else { query = Commands.SelectPrescriptions(sort); } ListViewItem item; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); int[] size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); int row = size[0]; int column = size[1]; string[,] data = new string[row, column]; data = ConnectedData.GetTableData(); Dictionary <int, string> list = GetPrescriptionsDiagnoses(); Dictionary <int, string> list2 = GetPrescriptionsMedications(); for (int i = 0; i < row; i++) { item = new ListViewItem(data[i, 0]); for (int j = 1; j < column; j++) { if (j == 4 || j == 5) { bool value = Convert.ToBoolean(data[i, j]); if (value == true) { item.SubItems.Add("+"); } else { item.SubItems.Add("-"); } } else { item.SubItems.Add(data[i, j]); } } if (list.ContainsKey(Convert.ToInt32(data[i, 0]))) { item.SubItems.Add(list[Convert.ToInt32(data[i, 0])]); } else { item.SubItems.Add("-"); } if (list2.ContainsKey(Convert.ToInt32(data[i, 0]))) { item.SubItems.Add(list2[Convert.ToInt32(data[i, 0])]); } else { item.SubItems.Add("-"); } PrescriptionsListView.Items.Add(item); } } else { dataSet = DisconnectedData.GetTableData(query); DataTable dataTable = dataSet.Tables[0]; for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dataRow = dataTable.Rows[i]; item = new ListViewItem(dataRow[0].ToString()); for (int j = 1; j < dataTable.Columns.Count; j++) { if (j == 4 || j == 5) { bool value = Convert.ToBoolean(dataRow[j]); if (value == true) { item.SubItems.Add("+"); } else { item.SubItems.Add("-"); } } else { item.SubItems.Add(dataRow[j].ToString()); } } Dictionary <int, string> list = GetPrescriptionsDiagnoses(); Dictionary <int, string> list2 = GetPrescriptionsMedications(); if (list.ContainsKey(Convert.ToInt32(dataRow[0]))) { item.SubItems.Add(list[Convert.ToInt32(dataRow[0])]); } else { item.SubItems.Add("-"); } if (list2.ContainsKey(Convert.ToInt32(dataRow[0]))) { item.SubItems.Add(list2[Convert.ToInt32(dataRow[0])]); } else { item.SubItems.Add("-"); } PrescriptionsListView.Items.Add(item); } } }
public void StorehouseFPrint(SortTypes sort, string name = "") { StorehouseFListView.Items.Clear(); if (name != "") { query = Commands.SelectStorehouseF(sort, name); } else { query = Commands.SelectStorehouseF(sort); } ListViewItem item; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); int[] size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); int row = size[0]; int column = size[1]; string[,] data = new string[row, column]; data = ConnectedData.GetTableData(); for (int i = 0; i < row; i++) { item = new ListViewItem(data[i, 0]); for (int j = 1; j < column; j++) { if (j == 5 || j == 6) { DateTime value = Convert.ToDateTime(data[i, j]); item.SubItems.Add(value.ToShortDateString()); } else { item.SubItems.Add(data[i, j]); } } StorehouseFListView.Items.Add(item); } } else { dataSet = DisconnectedData.GetTableData(query); DataTable dataTable = dataSet.Tables[0]; for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dataRow = dataTable.Rows[i]; item = new ListViewItem(dataRow[0].ToString()); for (int j = 1; j < dataTable.Columns.Count; j++) { if (j == 5 || j == 6) { DateTime value = Convert.ToDateTime(dataRow[j]); item.SubItems.Add(value.ToShortDateString()); } else { item.SubItems.Add(dataRow[j].ToString()); } } StorehouseFListView.Items.Add(item); } } }
private void ButtonAcceptId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericId.Value); string query = Commands.SelectPrescriptionsWhereId(id); ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusId.Text = "Выбрано"; TextBoxStatusId.ForeColor = Color.Green; TextBoxStatusPId.Text = "Выбрано"; TextBoxStatusPId.ForeColor = Color.Green; ButtonUpdate.Enabled = true; LabelPId.Enabled = true; LabelStatusPId.Enabled = true; NumericPId.Enabled = true; ButtonAcceptPId.Enabled = true; TextBoxStatusPId.Enabled = true; TextBoxDName.Enabled = true; TextBoxPName.Enabled = true; CheckBoxDSignature.Enabled = true; CheckBoxDStamp.Enabled = true; DGVDiagnoses.Enabled = true; DGVMedications.Enabled = true; ConnectedData.SetCommand(query); dataPrescription = ConnectedData.GetRowFromTable(); TextBoxDName.Text = dataPrescription[1]; CheckBoxDSignature.Checked = Convert.ToBoolean(dataPrescription[2]); CheckBoxDStamp.Checked = Convert.ToBoolean(dataPrescription[3]); pId = Convert.ToInt32(dataPrescription[4]); NumericPId.Value = pId; string query2 = Commands.SelectPatientWhereId(pId); ConnectedData.SetCommand(query2); dataPatient = ConnectedData.GetRowFromTable(); TextBoxPName.Text = dataPatient[1]; InitializeDGVs(id); this.Refresh(); } else { TextBoxStatusId.Text = "Не выбрано"; TextBoxStatusId.ForeColor = Color.Red; ButtonUpdate.Enabled = false; LabelPId.Enabled = false; LabelStatusPId.Enabled = false; NumericPId.Enabled = false; ButtonAcceptPId.Enabled = false; TextBoxStatusPId.Enabled = false; TextBoxDName.Enabled = false; TextBoxPName.Enabled = false; CheckBoxDSignature.Enabled = false; CheckBoxDStamp.Enabled = false; DGVDiagnoses.Enabled = false; DGVMedications.Enabled = false; this.Refresh(); MessageBox.Show("Записи с таким id не существует!"); } }
public void MedicationsPrint(SortTypes sort, string name = "") { double sum = 0; int countPills = 0; int countSolutes = 0; MedicationsListView.Items.Clear(); if (name != "") { query = Commands.SelectMedications(sort, name); } else { query = Commands.SelectMedications(sort); } ListViewItem item; if (connectionType == ConnectionTypes.Connected) { ConnectedData.SetCommand(query); int[] size = new int[2]; size = ConnectedData.GetRowAndColumnCount(); int row = size[0]; int column = size[1]; string[,] data = new string[row, column]; data = ConnectedData.GetTableData(); for (int i = 0; i < row; i++) { item = new ListViewItem(data[i, 0]); for (int j = 1; j < column; j++) { if (j == 2) { double value = Convert.ToDouble(data[i, j]); item.SubItems.Add(Math.Round(value, 2).ToString() + " грн"); sum += value; } else { item.SubItems.Add(data[i, j]); } if (j == 5 && data[i, j] == "Таблетки") { countPills++; } else if (j == 5 && data[i, j] == "Раствор") { countSolutes++; } } MedicationsListView.Items.Add(item); } } else { dataSet = DisconnectedData.GetTableData(query); DataTable dataTable = dataSet.Tables[0]; for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dataRow = dataTable.Rows[i]; item = new ListViewItem(dataRow[0].ToString()); for (int j = 1; j < dataTable.Columns.Count; j++) { if (j == 2) { double value = Convert.ToDouble(dataRow[j]); item.SubItems.Add(Math.Round(value, 2).ToString() + " грн"); sum += value; } else { item.SubItems.Add(dataRow[j].ToString()); } if (j == 5 && dataRow[j].ToString() == "Таблетки") { countPills++; } else if (j == 5 && dataRow[j].ToString() == "Раствор") { countSolutes++; } } MedicationsListView.Items.Add(item); } } LabelMedicationsSumPriceValue.Text = Math.Round(sum, 2).ToString() + " грн"; LabelMedicationsSumPillsValue.Text = countPills.ToString(); LabelMedicationsSumSolutesValue.Text = countSolutes.ToString(); }
private void ButtonAcceptId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericId.Value); string query = Commands.SelectMedicationsWhereId(id); string[] data = new string[11]; ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusId.Text = "Выбрано"; TextBoxStatusId.ForeColor = Color.Green; ButtonUpdate.Enabled = true; TextBoxName.Enabled = true; TextBoxPrice.Enabled = true; TextBoxQuantity.Enabled = true; TextBoxVolume.Enabled = true; ComboBoxMedType.Enabled = true; ComboBoxUsesType.Enabled = true; ComboBoxManufType.Enabled = true; CheckBoxPrepTime.Enabled = true; CheckBoxFilterTime.Enabled = true; ConnectedData.SetCommand(query); data = ConnectedData.GetRowFromTable(); TextBoxName.Text = data[1]; double price = Convert.ToDouble(data[2]); TextBoxPrice.Text = Math.Round(price, 2).ToString(); TextBoxQuantity.Text = data[3]; TextBoxVolume.Text = data[4]; if (data[5] == "1") { ComboBoxUsesType.SelectedIndex = 0; } else if (data[5] == "2") { ComboBoxUsesType.SelectedIndex = 1; } if (data[6] == "1") { ComboBoxManufType.SelectedIndex = 0; } else if (data[6] == "2") { ComboBoxManufType.SelectedIndex = 1; } else if (data[6] == "4") { ComboBoxManufType.SelectedIndex = 2; } if (data[7] == "1") { ComboBoxMedType.SelectedIndex = 0; } else if (data[7] == "2") { ComboBoxMedType.SelectedIndex = 1; } else if (data[7] == "3") { ComboBoxMedType.SelectedIndex = 2; } else if (data[7] == "4") { ComboBoxMedType.SelectedIndex = 3; } else if (data[7] == "5") { ComboBoxMedType.SelectedIndex = 4; } else if (data[7] == "1002") { ComboBoxMedType.SelectedIndex = 5; } else if (data[7] == "1003") { ComboBoxMedType.SelectedIndex = 6; } TextBoxMixableList.Text = data[8]; TextBoxPrepTime.Text = data[9]; TextBoxFiltrationTime.Text = data[10]; if (ComboBoxManufType.SelectedIndex == 2) { TextBoxMixableList.Enabled = true; } else { TextBoxMixableList.ResetText(); TextBoxMixableList.Enabled = false; } if (TextBoxPrepTime.Text == "-") { CheckBoxPrepTime.Checked = false; TextBoxPrepTime.ResetText(); TextBoxPrepTime.Enabled = false; } else { CheckBoxPrepTime.Checked = true; TextBoxPrepTime.Enabled = true; } if (TextBoxFiltrationTime.Text == "-") { CheckBoxFilterTime.Checked = false; TextBoxFiltrationTime.ResetText(); TextBoxFiltrationTime.Enabled = false; } else { CheckBoxFilterTime.Checked = true; TextBoxFiltrationTime.Enabled = true; } this.Refresh(); } else { TextBoxStatusId.Text = "Не выбрано"; TextBoxStatusId.ForeColor = Color.Red; TextBoxName.ResetText(); TextBoxPrice.ResetText(); TextBoxQuantity.ResetText(); TextBoxVolume.ResetText(); ComboBoxMedType.SelectedIndex = -1; ComboBoxUsesType.SelectedIndex = -1; ComboBoxManufType.SelectedIndex = -1; CheckBoxFilterTime.Checked = false; CheckBoxPrepTime.Checked = false; TextBoxPrepTime.ResetText(); TextBoxFiltrationTime.ResetText(); TextBoxMixableList.ResetText(); ButtonUpdate.Enabled = false; TextBoxName.Enabled = false; TextBoxPrice.Enabled = false; TextBoxQuantity.Enabled = false; TextBoxVolume.Enabled = false; ComboBoxMedType.Enabled = false; ComboBoxUsesType.Enabled = false; ComboBoxManufType.Enabled = false; CheckBoxPrepTime.Enabled = false; CheckBoxFilterTime.Enabled = false; TextBoxPrepTime.Enabled = false; TextBoxFiltrationTime.Enabled = false; TextBoxMixableList.Enabled = false; this.Refresh(); MessageBox.Show("Лекарства с таким id не существует!"); } }
private void ButtonAcceptId_Click(object sender, EventArgs e) { //if (connectionType == ConnectionTypes.Connected) //{ //} int id = Convert.ToInt32(NumericId.Value); string query = Commands.SelectStorehouseFWhereId(id); ConnectedData.SetCommand(query); bool status = ConnectedData.CheckExist(); if (status == true) { TextBoxStatusId.Text = "Выбрано"; TextBoxStatusId.ForeColor = Color.Green; ButtonUpdate.Enabled = true; TextBoxQuantity.Enabled = true; TextBoxCriticalQuantity.Enabled = true; TextBoxManufactureDate.Enabled = true; TextBoxShelfLife.Enabled = true; CheckBoxRId.Enabled = true; ConnectedData.SetCommand(query); data = ConnectedData.GetRowFromTable(); TextBoxQuantity.Text = data[4]; TextBoxCriticalQuantity.Text = data[2]; DateTime manufactureDate = Convert.ToDateTime(data[5]); DateTime shelfLife = Convert.ToDateTime(data[6]); TextBoxManufactureDate.Text = manufactureDate.ToShortDateString(); TextBoxShelfLife.Text = shelfLife.ToShortDateString(); if (data[3] != "-") { NumericRId.Value = Convert.ToInt32(data[3]); CheckBoxRId.Checked = true; NumericRId.Enabled = true; ButtonAcceptRId.Enabled = true; TextBoxStatusRId.ForeColor = Color.Green; TextBoxStatusRId.Text = "Выбрано"; } else { CheckBoxRId.Checked = false; TextBoxStatusRId.ForeColor = Color.Red; TextBoxStatusRId.Text = "Не выбрано"; } this.Refresh(); } else { TextBoxStatusId.Text = "Не выбрано"; TextBoxStatusId.ForeColor = Color.Red; ButtonUpdate.Enabled = false; TextBoxQuantity.Enabled = false; TextBoxCriticalQuantity.Enabled = false; TextBoxManufactureDate.Enabled = false; TextBoxShelfLife.Enabled = false; CheckBoxRId.Checked = false; CheckBoxRId.Enabled = false; TextBoxStatusRId.ForeColor = Color.Red; TextBoxStatusRId.Text = "Не выбрано"; this.Refresh(); MessageBox.Show("Записи с таким id не существует!"); } }