diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index fb903b1..50afc2e 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -233,6 +233,94 @@ namespace Louis__Pharmacy_CNSA212_FP } } + + public static void UpdateMedication( + string Medication_id, + string MedicationName, + string IntakeMethod, + string Frequency, + string Dosage, + string Purpose, + string RxNum) + + { + try + { + myConn.Open(); + + cmdString.Parameters.Clear(); + + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + + cmdString.CommandText = "UpdateMedication"; + + cmdString.Parameters.Add("@Medication_id", SqlDbType.VarChar, 7).Value = Medication_id; + cmdString.Parameters.Add("@MedicationName", SqlDbType.VarChar,60).Value = MedicationName; + cmdString.Parameters.Add("@IntakeMethod", SqlDbType.VarChar,30).Value =IntakeMethod ; + cmdString.Parameters.Add("@Frequency", SqlDbType.VarChar,30).Value =Frequency ; + cmdString.Parameters.Add("@Dosage", SqlDbType.VarChar,30).Value = Dosage; + cmdString.Parameters.Add("@Purpose", SqlDbType.VarChar,100).Value = Purpose; + cmdString.Parameters.Add("@RxNum", SqlDbType.VarChar,30).Value = RxNum; + + cmdString.ExecuteNonQuery(); + + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + + } + + public static void CreateMedication( + string Medication_id, + string MedicationName, + string IntakeMethod, + string Frequency, + string Dosage, + string Purpose, + string RxNum) + + { + try + { + myConn.Open(); + + cmdString.Parameters.Clear(); + + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + + cmdString.CommandText = "CreateMedication"; + + cmdString.Parameters.Add("@Medication_id", SqlDbType.VarChar, 7).Value = Medication_id; + cmdString.Parameters.Add("@MedicationName", SqlDbType.VarChar,60).Value = MedicationName; + cmdString.Parameters.Add("@IntakeMethod", SqlDbType.VarChar,30).Value =IntakeMethod ; + cmdString.Parameters.Add("@Frequency", SqlDbType.VarChar,30).Value =Frequency ; + cmdString.Parameters.Add("@Dosage", SqlDbType.VarChar,30).Value = Dosage; + cmdString.Parameters.Add("@Purpose", SqlDbType.VarChar,100).Value = Purpose; + cmdString.Parameters.Add("@RxNum", SqlDbType.VarChar,30).Value = RxNum; + + cmdString.ExecuteNonQuery(); + + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + + } public static void DeletePatient(string Patient_id) @@ -295,6 +383,36 @@ namespace Louis__Pharmacy_CNSA212_FP } + public static void DeleteMedication(string medID) + { + + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "DeleteMedication"; + // Define input parameter + cmdString.Parameters.Add("@MedID", SqlDbType.VarChar, 7).Value = medID; + + cmdString.ExecuteNonQuery(); + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + + } + public static DataSet PatientInfoSearch(string id, string lname, string fname) @@ -493,6 +611,84 @@ namespace Louis__Pharmacy_CNSA212_FP } } + public static DataSet MedicationInfoSearch(string medID, string medicationName) + { + + + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "MedicationInfoSearch"; + // Define input parameter + cmdString.Parameters.Add("@Medication_id", SqlDbType.VarChar, 7).Value = medID; + cmdString.Parameters.Add("@MedicationName", SqlDbType.VarChar, 60).Value = medicationName; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + + public static DataSet MedicationInfoSearch(string medID) + { + + + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "MedicationInfoSearch"; + // Define input parameter + cmdString.Parameters.Add("@Medication_id", SqlDbType.VarChar, 7).Value = medID; + cmdString.Parameters.Add("@MedicationName", SqlDbType.VarChar, 60).Value = ""; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + public static double GetNextPatientID() { @@ -564,6 +760,46 @@ namespace Louis__Pharmacy_CNSA212_FP } + // return dataSet + return value; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + + public static double GetNextMedicationID() + { + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "GetNextMedicationID"; + + object result = cmdString.ExecuteScalar(); + double value = 0; + try + { + value = Convert.ToDouble(result); + + } + catch(Exception e) + { + MessageBox.Show("Error Getting next Patient ID","ERROR",MessageBoxButtons.OK); + } + + // return dataSet return value; } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs index 76ef3b1..d55deac 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs @@ -73,13 +73,13 @@ namespace Louis__Pharmacy_CNSA212_FP this.lblPrescriptionPatID = new System.Windows.Forms.Label(); this.lblDisMedicationNum = new System.Windows.Forms.Label(); this.dgvPrescription = new System.Windows.Forms.DataGridView(); - this.RxNum_id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.numRefills = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.pastNumRefills = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.PrescribedBy = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Physician_id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Medication_id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Patient_id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MedicationName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IntakeMethod = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Frequency = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Dosage = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Purpose = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RxNum = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.cmuRx = new System.Windows.Forms.ContextMenuStrip(this.components); this.cmuRxNew = new System.Windows.Forms.ToolStripMenuItem(); this.cmuRxEdit = new System.Windows.Forms.ToolStripMenuItem(); @@ -138,40 +138,36 @@ namespace Louis__Pharmacy_CNSA212_FP // lblPatientFirst // lblPatientFirst.AutoSize = true; - lblPatientFirst.Location = new System.Drawing.Point(30, 43); - lblPatientFirst.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lblPatientFirst.Location = new System.Drawing.Point(20, 28); lblPatientFirst.Name = "lblPatientFirst"; - lblPatientFirst.Size = new System.Drawing.Size(90, 20); + lblPatientFirst.Size = new System.Drawing.Size(60, 13); lblPatientFirst.TabIndex = 4; lblPatientFirst.Text = "First Name:"; // // lblPatientLast // lblPatientLast.AutoSize = true; - lblPatientLast.Location = new System.Drawing.Point(30, 106); - lblPatientLast.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lblPatientLast.Location = new System.Drawing.Point(20, 69); lblPatientLast.Name = "lblPatientLast"; - lblPatientLast.Size = new System.Drawing.Size(90, 20); + lblPatientLast.Size = new System.Drawing.Size(61, 13); lblPatientLast.TabIndex = 5; lblPatientLast.Text = "Last Name:"; // // lblPhysicianFirst // lblPhysicianFirst.AutoSize = true; - lblPhysicianFirst.Location = new System.Drawing.Point(36, 40); - lblPhysicianFirst.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lblPhysicianFirst.Location = new System.Drawing.Point(24, 26); lblPhysicianFirst.Name = "lblPhysicianFirst"; - lblPhysicianFirst.Size = new System.Drawing.Size(90, 20); + lblPhysicianFirst.Size = new System.Drawing.Size(60, 13); lblPhysicianFirst.TabIndex = 4; lblPhysicianFirst.Text = "First Name:"; // // lblPhysicianLast // lblPhysicianLast.AutoSize = true; - lblPhysicianLast.Location = new System.Drawing.Point(34, 108); - lblPhysicianLast.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lblPhysicianLast.Location = new System.Drawing.Point(23, 70); lblPhysicianLast.Name = "lblPhysicianLast"; - lblPhysicianLast.Size = new System.Drawing.Size(90, 20); + lblPhysicianLast.Size = new System.Drawing.Size(61, 13); lblPhysicianLast.TabIndex = 5; lblPhysicianLast.Text = "Last Name:"; // @@ -180,20 +176,18 @@ namespace Louis__Pharmacy_CNSA212_FP this.tbcInfo.Controls.Add(this.tbpPatient); this.tbcInfo.Controls.Add(this.tbpMedication); this.tbcInfo.Controls.Add(this.tbpPhysician); - this.tbcInfo.Location = new System.Drawing.Point(18, 18); - this.tbcInfo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.tbcInfo.Location = new System.Drawing.Point(12, 12); this.tbcInfo.Name = "tbcInfo"; this.tbcInfo.SelectedIndex = 0; - this.tbcInfo.Size = new System.Drawing.Size(1111, 785); + this.tbcInfo.Size = new System.Drawing.Size(741, 510); this.tbcInfo.TabIndex = 999999; // // tbpPatient // this.tbpPatient.Controls.Add(this.splcPatient); - this.tbpPatient.Location = new System.Drawing.Point(4, 29); - this.tbpPatient.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.tbpPatient.Location = new System.Drawing.Point(4, 22); this.tbpPatient.Name = "tbpPatient"; - this.tbpPatient.Size = new System.Drawing.Size(1103, 752); + this.tbpPatient.Size = new System.Drawing.Size(733, 484); this.tbpPatient.TabIndex = 3; this.tbpPatient.Text = "Patients"; this.tbpPatient.UseVisualStyleBackColor = true; @@ -202,7 +196,6 @@ namespace Louis__Pharmacy_CNSA212_FP // this.splcPatient.Dock = System.Windows.Forms.DockStyle.Fill; this.splcPatient.Location = new System.Drawing.Point(0, 0); - this.splcPatient.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splcPatient.Name = "splcPatient"; this.splcPatient.Orientation = System.Windows.Forms.Orientation.Horizontal; // @@ -221,52 +214,46 @@ namespace Louis__Pharmacy_CNSA212_FP // this.splcPatient.Panel2.AutoScroll = true; this.splcPatient.Panel2.Controls.Add(this.dgvPatient); - this.splcPatient.Size = new System.Drawing.Size(1103, 752); - this.splcPatient.SplitterDistance = 330; - this.splcPatient.SplitterWidth = 6; + this.splcPatient.Size = new System.Drawing.Size(733, 484); + this.splcPatient.SplitterDistance = 211; this.splcPatient.TabIndex = 0; // // txtPatientID // - this.txtPatientID.Location = new System.Drawing.Point(129, 168); - this.txtPatientID.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPatientID.Location = new System.Drawing.Point(86, 109); this.txtPatientID.Name = "txtPatientID"; - this.txtPatientID.Size = new System.Drawing.Size(148, 26); + this.txtPatientID.Size = new System.Drawing.Size(100, 20); this.txtPatientID.TabIndex = 3; // // lblPatientID // this.lblPatientID.AutoSize = true; - this.lblPatientID.Location = new System.Drawing.Point(34, 168); - this.lblPatientID.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblPatientID.Location = new System.Drawing.Point(23, 109); this.lblPatientID.Name = "lblPatientID"; - this.lblPatientID.Size = new System.Drawing.Size(84, 20); + this.lblPatientID.Size = new System.Drawing.Size(57, 13); this.lblPatientID.TabIndex = 7; this.lblPatientID.Text = "Patient ID:"; // // txtPatientLast // - this.txtPatientLast.Location = new System.Drawing.Point(130, 102); - this.txtPatientLast.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPatientLast.Location = new System.Drawing.Point(87, 66); this.txtPatientLast.Name = "txtPatientLast"; - this.txtPatientLast.Size = new System.Drawing.Size(148, 26); + this.txtPatientLast.Size = new System.Drawing.Size(100, 20); this.txtPatientLast.TabIndex = 2; // // txtPatientFirst // - this.txtPatientFirst.Location = new System.Drawing.Point(129, 38); - this.txtPatientFirst.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPatientFirst.Location = new System.Drawing.Point(86, 25); this.txtPatientFirst.Name = "txtPatientFirst"; - this.txtPatientFirst.Size = new System.Drawing.Size(148, 26); + this.txtPatientFirst.Size = new System.Drawing.Size(100, 20); this.txtPatientFirst.TabIndex = 1; // // btnPatientSearch // this.btnPatientSearch.BackColor = System.Drawing.Color.Transparent; - this.btnPatientSearch.Location = new System.Drawing.Point(34, 231); - this.btnPatientSearch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnPatientSearch.Location = new System.Drawing.Point(23, 150); this.btnPatientSearch.Name = "btnPatientSearch"; - this.btnPatientSearch.Size = new System.Drawing.Size(112, 35); + this.btnPatientSearch.Size = new System.Drawing.Size(75, 23); this.btnPatientSearch.TabIndex = 4; this.btnPatientSearch.Text = "Search"; this.btnPatientSearch.UseVisualStyleBackColor = false; @@ -281,13 +268,12 @@ namespace Louis__Pharmacy_CNSA212_FP this.dgvPatient.ContextMenuStrip = this.cmuPatient; this.dgvPatient.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgvPatient.Location = new System.Drawing.Point(0, 0); - this.dgvPatient.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.dgvPatient.MultiSelect = false; this.dgvPatient.Name = "dgvPatient"; this.dgvPatient.ReadOnly = true; this.dgvPatient.RowHeadersWidth = 51; this.dgvPatient.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgvPatient.Size = new System.Drawing.Size(1099, 411); + this.dgvPatient.Size = new System.Drawing.Size(733, 267); this.dgvPatient.TabIndex = 0; this.dgvPatient.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvPatient_CellContentClick); // @@ -434,36 +420,35 @@ namespace Louis__Pharmacy_CNSA212_FP this.cmuPatient.ImageScalingSize = new System.Drawing.Size(20, 20); this.cmuPatient.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuPatientNew, this.cmuPatientEdit, this.cmuPatientDelete }); this.cmuPatient.Name = "contextMenuStrip1"; - this.cmuPatient.Size = new System.Drawing.Size(135, 94); + this.cmuPatient.Size = new System.Drawing.Size(108, 70); // // cmuPatientNew // this.cmuPatientNew.Name = "cmuPatientNew"; - this.cmuPatientNew.Size = new System.Drawing.Size(134, 30); + this.cmuPatientNew.Size = new System.Drawing.Size(107, 22); this.cmuPatientNew.Text = "New"; this.cmuPatientNew.Click += new System.EventHandler(this.cmuPatientNew_Click); // // cmuPatientEdit // this.cmuPatientEdit.Name = "cmuPatientEdit"; - this.cmuPatientEdit.Size = new System.Drawing.Size(134, 30); + this.cmuPatientEdit.Size = new System.Drawing.Size(107, 22); this.cmuPatientEdit.Text = "Edit"; this.cmuPatientEdit.Click += new System.EventHandler(this.cmuPatientEdit_Click); // // cmuPatientDelete // this.cmuPatientDelete.Name = "cmuPatientDelete"; - this.cmuPatientDelete.Size = new System.Drawing.Size(134, 30); + this.cmuPatientDelete.Size = new System.Drawing.Size(107, 22); this.cmuPatientDelete.Text = "Delete"; this.cmuPatientDelete.Click += new System.EventHandler(this.cmuPatientDelete_Click); // // tbpMedication // this.tbpMedication.Controls.Add(this.splcPrescription); - this.tbpMedication.Location = new System.Drawing.Point(4, 29); - this.tbpMedication.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.tbpMedication.Location = new System.Drawing.Point(4, 22); this.tbpMedication.Name = "tbpMedication"; - this.tbpMedication.Size = new System.Drawing.Size(1103, 752); + this.tbpMedication.Size = new System.Drawing.Size(733, 484); this.tbpMedication.TabIndex = 4; this.tbpMedication.Text = "Medications"; this.tbpMedication.UseVisualStyleBackColor = true; @@ -472,7 +457,6 @@ namespace Louis__Pharmacy_CNSA212_FP // this.splcPrescription.Dock = System.Windows.Forms.DockStyle.Fill; this.splcPrescription.Location = new System.Drawing.Point(0, 0); - this.splcPrescription.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splcPrescription.Name = "splcPrescription"; this.splcPrescription.Orientation = System.Windows.Forms.Orientation.Horizontal; // @@ -487,17 +471,15 @@ namespace Louis__Pharmacy_CNSA212_FP // splcPrescription.Panel2 // this.splcPrescription.Panel2.Controls.Add(this.dgvPrescription); - this.splcPrescription.Size = new System.Drawing.Size(1103, 752); - this.splcPrescription.SplitterDistance = 376; - this.splcPrescription.SplitterWidth = 6; + this.splcPrescription.Size = new System.Drawing.Size(733, 484); + this.splcPrescription.SplitterDistance = 242; this.splcPrescription.TabIndex = 0; // // btnMedicationSearch // - this.btnMedicationSearch.Location = new System.Drawing.Point(96, 180); - this.btnMedicationSearch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnMedicationSearch.Location = new System.Drawing.Point(64, 117); this.btnMedicationSearch.Name = "btnMedicationSearch"; - this.btnMedicationSearch.Size = new System.Drawing.Size(112, 35); + this.btnMedicationSearch.Size = new System.Drawing.Size(75, 23); this.btnMedicationSearch.TabIndex = 4; this.btnMedicationSearch.Text = "Search"; this.btnMedicationSearch.UseVisualStyleBackColor = true; @@ -505,146 +487,137 @@ namespace Louis__Pharmacy_CNSA212_FP // // txtPrescriptionPatID // - this.txtPrescriptionPatID.Location = new System.Drawing.Point(276, 114); - this.txtPrescriptionPatID.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPrescriptionPatID.Location = new System.Drawing.Point(184, 74); this.txtPrescriptionPatID.Name = "txtPrescriptionPatID"; - this.txtPrescriptionPatID.Size = new System.Drawing.Size(148, 26); + this.txtPrescriptionPatID.Size = new System.Drawing.Size(100, 20); this.txtPrescriptionPatID.TabIndex = 3; // // txtRxNumber // - this.txtRxNumber.Location = new System.Drawing.Point(276, 78); - this.txtRxNumber.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtRxNumber.Location = new System.Drawing.Point(184, 51); this.txtRxNumber.Name = "txtRxNumber"; - this.txtRxNumber.Size = new System.Drawing.Size(148, 26); + this.txtRxNumber.Size = new System.Drawing.Size(100, 20); this.txtRxNumber.TabIndex = 2; // // lblPrescriptionPatID // this.lblPrescriptionPatID.AutoSize = true; - this.lblPrescriptionPatID.Location = new System.Drawing.Point(92, 114); - this.lblPrescriptionPatID.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblPrescriptionPatID.Location = new System.Drawing.Point(61, 74); this.lblPrescriptionPatID.Name = "lblPrescriptionPatID"; - this.lblPrescriptionPatID.Size = new System.Drawing.Size(84, 20); + this.lblPrescriptionPatID.Size = new System.Drawing.Size(93, 13); this.lblPrescriptionPatID.TabIndex = 1; - this.lblPrescriptionPatID.Text = "Patient ID:"; + this.lblPrescriptionPatID.Text = "Medication Name:"; // // lblDisMedicationNum // this.lblDisMedicationNum.AutoSize = true; - this.lblDisMedicationNum.Location = new System.Drawing.Point(92, 78); + this.lblDisMedicationNum.Location = new System.Drawing.Point(61, 51); + this.lblDisMedicationNum.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.lblDisMedicationNum.Name = "lblDisMedicationNum"; - this.lblDisMedicationNum.Size = new System.Drawing.Size(150, 20); + this.lblDisMedicationNum.Size = new System.Drawing.Size(76, 13); this.lblDisMedicationNum.TabIndex = 0; - this.lblDisMedicationNum.Text = "Medication Number:"; + this.lblDisMedicationNum.Text = "Medication ID:"; + this.lblDisMedicationNum.Click += new System.EventHandler(this.lblDisMedicationNum_Click); // // dgvPrescription // this.dgvPrescription.AllowUserToAddRows = false; this.dgvPrescription.AllowUserToDeleteRows = false; this.dgvPrescription.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.RxNum_id, this.numRefills, this.pastNumRefills, this.PrescribedBy, this.Physician_id, this.Medication_id, this.Patient_id }); + this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Medication_id, this.MedicationName, this.IntakeMethod, this.Frequency, this.Dosage, this.Purpose, this.RxNum }); this.dgvPrescription.ContextMenuStrip = this.cmuRx; - this.dgvPrescription.Location = new System.Drawing.Point(4, 5); - this.dgvPrescription.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.dgvPrescription.Location = new System.Drawing.Point(3, 3); this.dgvPrescription.Name = "dgvPrescription"; + this.dgvPrescription.ReadOnly = true; this.dgvPrescription.RowHeadersWidth = 51; this.dgvPrescription.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgvPrescription.Size = new System.Drawing.Size(1095, 365); + this.dgvPrescription.Size = new System.Drawing.Size(730, 237); this.dgvPrescription.TabIndex = 0; // - // RxNum_id - // - this.RxNum_id.DataPropertyName = "RxNum_id"; - this.RxNum_id.HeaderText = "Rx Number"; - this.RxNum_id.MinimumWidth = 6; - this.RxNum_id.Name = "RxNum_id"; - this.RxNum_id.Width = 125; - // - // numRefills - // - this.numRefills.DataPropertyName = "numRefills"; - this.numRefills.HeaderText = "Number of Refills"; - this.numRefills.MinimumWidth = 6; - this.numRefills.Name = "numRefills"; - this.numRefills.Width = 125; - // - // pastNumRefills - // - this.pastNumRefills.DataPropertyName = "pastNumRefills"; - this.pastNumRefills.HeaderText = "Past Number of Refills"; - this.pastNumRefills.MinimumWidth = 6; - this.pastNumRefills.Name = "pastNumRefills"; - this.pastNumRefills.Width = 125; - // - // PrescribedBy - // - this.PrescribedBy.DataPropertyName = "PrescribedBy"; - this.PrescribedBy.HeaderText = "Prescribed By"; - this.PrescribedBy.MinimumWidth = 6; - this.PrescribedBy.Name = "PrescribedBy"; - this.PrescribedBy.Width = 125; - // - // Physician_id - // - this.Physician_id.DataPropertyName = "Physician_id"; - this.Physician_id.HeaderText = "Physician ID"; - this.Physician_id.MinimumWidth = 6; - this.Physician_id.Name = "Physician_id"; - this.Physician_id.Width = 125; - // // Medication_id // this.Medication_id.DataPropertyName = "Medication_id"; this.Medication_id.HeaderText = "Medication ID"; - this.Medication_id.MinimumWidth = 6; this.Medication_id.Name = "Medication_id"; - this.Medication_id.Width = 125; + this.Medication_id.ReadOnly = true; // - // Patient_id + // MedicationName // - this.Patient_id.DataPropertyName = "Patient_id"; - this.Patient_id.HeaderText = "Patient ID"; - this.Patient_id.MinimumWidth = 6; - this.Patient_id.Name = "Patient_id"; - this.Patient_id.Width = 125; + this.MedicationName.DataPropertyName = "MedicationName"; + this.MedicationName.HeaderText = "Name"; + this.MedicationName.Name = "MedicationName"; + this.MedicationName.ReadOnly = true; + // + // IntakeMethod + // + this.IntakeMethod.DataPropertyName = "IntakeMethod"; + this.IntakeMethod.HeaderText = "Intake Method"; + this.IntakeMethod.Name = "IntakeMethod"; + this.IntakeMethod.ReadOnly = true; + // + // Frequency + // + this.Frequency.DataPropertyName = "Frequency"; + this.Frequency.HeaderText = "Frequency"; + this.Frequency.Name = "Frequency"; + this.Frequency.ReadOnly = true; + // + // Dosage + // + this.Dosage.DataPropertyName = "Dosage"; + this.Dosage.HeaderText = "Dosage"; + this.Dosage.Name = "Dosage"; + this.Dosage.ReadOnly = true; + // + // Purpose + // + this.Purpose.DataPropertyName = "Purpose"; + this.Purpose.HeaderText = "Purpose"; + this.Purpose.Name = "Purpose"; + this.Purpose.ReadOnly = true; + // + // RxNum + // + this.RxNum.DataPropertyName = "RxNum"; + this.RxNum.HeaderText = "Rx Number"; + this.RxNum.Name = "RxNum"; + this.RxNum.ReadOnly = true; // // cmuRx // this.cmuRx.ImageScalingSize = new System.Drawing.Size(20, 20); this.cmuRx.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuRxNew, this.cmuRxEdit, this.cmuRxDelete }); this.cmuRx.Name = "cmuRx"; - this.cmuRx.Size = new System.Drawing.Size(135, 94); + this.cmuRx.Size = new System.Drawing.Size(153, 92); // // cmuRxNew // this.cmuRxNew.Name = "cmuRxNew"; - this.cmuRxNew.Size = new System.Drawing.Size(134, 30); + this.cmuRxNew.Size = new System.Drawing.Size(152, 22); this.cmuRxNew.Text = "New"; this.cmuRxNew.Click += new System.EventHandler(this.cmuRxNew_Click); // // cmuRxEdit // this.cmuRxEdit.Name = "cmuRxEdit"; - this.cmuRxEdit.Size = new System.Drawing.Size(134, 30); + this.cmuRxEdit.Size = new System.Drawing.Size(152, 22); this.cmuRxEdit.Text = "Edit"; this.cmuRxEdit.Click += new System.EventHandler(this.cmuRxEdit_Click); // // cmuRxDelete // this.cmuRxDelete.Name = "cmuRxDelete"; - this.cmuRxDelete.Size = new System.Drawing.Size(134, 30); + this.cmuRxDelete.Size = new System.Drawing.Size(152, 22); this.cmuRxDelete.Text = "Delete"; this.cmuRxDelete.Click += new System.EventHandler(this.cmuRxDelete_Click); // // tbpPhysician // this.tbpPhysician.Controls.Add(this.splcPhysician); - this.tbpPhysician.Location = new System.Drawing.Point(4, 29); - this.tbpPhysician.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.tbpPhysician.Location = new System.Drawing.Point(4, 22); this.tbpPhysician.Name = "tbpPhysician"; - this.tbpPhysician.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbpPhysician.Size = new System.Drawing.Size(1103, 752); + this.tbpPhysician.Padding = new System.Windows.Forms.Padding(3); + this.tbpPhysician.Size = new System.Drawing.Size(733, 484); this.tbpPhysician.TabIndex = 2; this.tbpPhysician.Text = "Physicians"; this.tbpPhysician.UseVisualStyleBackColor = true; @@ -652,8 +625,7 @@ namespace Louis__Pharmacy_CNSA212_FP // splcPhysician // this.splcPhysician.Dock = System.Windows.Forms.DockStyle.Fill; - this.splcPhysician.Location = new System.Drawing.Point(4, 5); - this.splcPhysician.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.splcPhysician.Location = new System.Drawing.Point(3, 3); this.splcPhysician.Name = "splcPhysician"; this.splcPhysician.Orientation = System.Windows.Forms.Orientation.Horizontal; // @@ -673,51 +645,45 @@ namespace Louis__Pharmacy_CNSA212_FP // this.splcPhysician.Panel2.AutoScroll = true; this.splcPhysician.Panel2.Controls.Add(this.dgvPhysician); - this.splcPhysician.Size = new System.Drawing.Size(1095, 742); - this.splcPhysician.SplitterDistance = 327; - this.splcPhysician.SplitterWidth = 6; + this.splcPhysician.Size = new System.Drawing.Size(727, 478); + this.splcPhysician.SplitterDistance = 210; this.splcPhysician.TabIndex = 0; // // txtPhysicianID // - this.txtPhysicianID.Location = new System.Drawing.Point(148, 171); - this.txtPhysicianID.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPhysicianID.Location = new System.Drawing.Point(99, 111); this.txtPhysicianID.Name = "txtPhysicianID"; - this.txtPhysicianID.Size = new System.Drawing.Size(148, 26); + this.txtPhysicianID.Size = new System.Drawing.Size(100, 20); this.txtPhysicianID.TabIndex = 3; // // lblPhysicianID // this.lblPhysicianID.AutoSize = true; - this.lblPhysicianID.Location = new System.Drawing.Point(36, 171); - this.lblPhysicianID.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblPhysicianID.Location = new System.Drawing.Point(24, 111); this.lblPhysicianID.Name = "lblPhysicianID"; - this.lblPhysicianID.Size = new System.Drawing.Size(100, 20); + this.lblPhysicianID.Size = new System.Drawing.Size(69, 13); this.lblPhysicianID.TabIndex = 7; this.lblPhysicianID.Text = "Physician ID:"; // // txtPhysicianLast // - this.txtPhysicianLast.Location = new System.Drawing.Point(148, 103); - this.txtPhysicianLast.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPhysicianLast.Location = new System.Drawing.Point(99, 67); this.txtPhysicianLast.Name = "txtPhysicianLast"; - this.txtPhysicianLast.Size = new System.Drawing.Size(148, 26); + this.txtPhysicianLast.Size = new System.Drawing.Size(100, 20); this.txtPhysicianLast.TabIndex = 2; // // txtPhysicianFirst // - this.txtPhysicianFirst.Location = new System.Drawing.Point(148, 35); - this.txtPhysicianFirst.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtPhysicianFirst.Location = new System.Drawing.Point(99, 23); this.txtPhysicianFirst.Name = "txtPhysicianFirst"; - this.txtPhysicianFirst.Size = new System.Drawing.Size(148, 26); + this.txtPhysicianFirst.Size = new System.Drawing.Size(100, 20); this.txtPhysicianFirst.TabIndex = 1; // // btnPhysicianSearch // - this.btnPhysicianSearch.Location = new System.Drawing.Point(68, 225); - this.btnPhysicianSearch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnPhysicianSearch.Location = new System.Drawing.Point(45, 146); this.btnPhysicianSearch.Name = "btnPhysicianSearch"; - this.btnPhysicianSearch.Size = new System.Drawing.Size(112, 35); + this.btnPhysicianSearch.Size = new System.Drawing.Size(75, 23); this.btnPhysicianSearch.TabIndex = 4; this.btnPhysicianSearch.Text = "Search"; this.btnPhysicianSearch.UseVisualStyleBackColor = true; @@ -731,12 +697,11 @@ namespace Louis__Pharmacy_CNSA212_FP this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Phys_id, this.namefirst, this.namelast, this.initialsmiddle, this.cit, this.state, this.zipp, this.dobb, this.numberphone, this.gennder, this.Specialty }); this.dgvPhysician.ContextMenuStrip = this.cmuPhysician; this.dgvPhysician.Location = new System.Drawing.Point(0, 0); - this.dgvPhysician.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.dgvPhysician.Name = "dgvPhysician"; this.dgvPhysician.ReadOnly = true; this.dgvPhysician.RowHeadersWidth = 51; this.dgvPhysician.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgvPhysician.Size = new System.Drawing.Size(1091, 404); + this.dgvPhysician.Size = new System.Drawing.Size(727, 263); this.dgvPhysician.TabIndex = 0; this.dgvPhysician.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvPhysician_CellContentClick_1); // @@ -847,36 +812,37 @@ namespace Louis__Pharmacy_CNSA212_FP this.cmuPhysician.ImageScalingSize = new System.Drawing.Size(20, 20); this.cmuPhysician.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuPhysicianNew, this.cmuPhysicianEdit, this.cmuPhysicianDelete }); this.cmuPhysician.Name = "cmuPhysician"; - this.cmuPhysician.Size = new System.Drawing.Size(135, 94); + this.cmuPhysician.Size = new System.Drawing.Size(108, 70); // // cmuPhysicianNew // this.cmuPhysicianNew.Name = "cmuPhysicianNew"; - this.cmuPhysicianNew.Size = new System.Drawing.Size(134, 30); + this.cmuPhysicianNew.Size = new System.Drawing.Size(107, 22); this.cmuPhysicianNew.Text = "New"; this.cmuPhysicianNew.Click += new System.EventHandler(this.cmuPhysicianNew_Click); // // cmuPhysicianEdit // this.cmuPhysicianEdit.Name = "cmuPhysicianEdit"; - this.cmuPhysicianEdit.Size = new System.Drawing.Size(134, 30); + this.cmuPhysicianEdit.Size = new System.Drawing.Size(107, 22); this.cmuPhysicianEdit.Text = "Edit"; this.cmuPhysicianEdit.Click += new System.EventHandler(this.cmuPhysicianEdit_Click); // // cmuPhysicianDelete // this.cmuPhysicianDelete.Name = "cmuPhysicianDelete"; - this.cmuPhysicianDelete.Size = new System.Drawing.Size(134, 30); + this.cmuPhysicianDelete.Size = new System.Drawing.Size(107, 22); this.cmuPhysicianDelete.Text = "Delete"; this.cmuPhysicianDelete.Click += new System.EventHandler(this.cmuPhysicianDelete_Click); // // frmInfo // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1166, 885); + this.ClientSize = new System.Drawing.Size(777, 575); this.Controls.Add(this.tbcInfo); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "frmInfo"; this.Text = "Louis\' Pharmacy - View Patient / Prescription Info"; this.Load += new System.EventHandler(this.frmInfo_Load); @@ -908,6 +874,13 @@ namespace Louis__Pharmacy_CNSA212_FP this.ResumeLayout(false); } + private System.Windows.Forms.DataGridViewTextBoxColumn MedicationName; + private System.Windows.Forms.DataGridViewTextBoxColumn IntakeMethod; + private System.Windows.Forms.DataGridViewTextBoxColumn Frequency; + private System.Windows.Forms.DataGridViewTextBoxColumn Dosage; + private System.Windows.Forms.DataGridViewTextBoxColumn Purpose; + private System.Windows.Forms.DataGridViewTextBoxColumn RxNum; + private System.Windows.Forms.ContextMenuStrip cmuPatient; private System.Windows.Forms.ContextMenuStrip cmuRx; private System.Windows.Forms.ToolStripMenuItem cmuRxNew; @@ -931,7 +904,7 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.SplitContainer splcPatient; private System.Windows.Forms.SplitContainer splcPrescription; private System.Windows.Forms.Button btnPatientSearch; - private System.Windows.Forms.TextBox txtRxNumber; + public System.Windows.Forms.TextBox txtRxNumber; private System.Windows.Forms.Label lblPrescriptionPatID; private System.Windows.Forms.Label lblDisMedicationNum; private System.Windows.Forms.TextBox txtPrescriptionPatID; @@ -959,13 +932,7 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.DataGridViewTextBoxColumn PhoneNumber; private System.Windows.Forms.DataGridViewTextBoxColumn Gender; private System.Windows.Forms.DataGridViewTextBoxColumn Medications; - private System.Windows.Forms.DataGridViewTextBoxColumn RxNum_id; - private System.Windows.Forms.DataGridViewTextBoxColumn numRefills; - private System.Windows.Forms.DataGridViewTextBoxColumn pastNumRefills; - private System.Windows.Forms.DataGridViewTextBoxColumn PrescribedBy; - private System.Windows.Forms.DataGridViewTextBoxColumn Physician_id; private System.Windows.Forms.DataGridViewTextBoxColumn Medication_id; - private System.Windows.Forms.DataGridViewTextBoxColumn Patient_id; private System.Windows.Forms.DataGridViewTextBoxColumn Phys_id; private System.Windows.Forms.DataGridViewTextBoxColumn namefirst; private System.Windows.Forms.DataGridViewTextBoxColumn namelast; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index f2a6619..61eba14 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -38,6 +38,10 @@ namespace Louis__Pharmacy_CNSA212_FP cmuPatientEdit.Enabled = false; cmuPatientDelete.Enabled = false; + cmuPhysicianEdit.Enabled = false; + cmuPhysicianDelete.Enabled = false; + cmuRxEdit.Enabled = false; + cmuRxDelete.Enabled = false; txtPatientFirst.Focus(); @@ -224,10 +228,10 @@ namespace Louis__Pharmacy_CNSA212_FP } - private void btnPrescriptionSearch_Click(object sender, EventArgs e) + public void btnPrescriptionSearch_Click(object sender, EventArgs e) { - string rxID = ""; - string patientID = ""; + string medID = ""; + string medicationName = ""; if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0) @@ -237,18 +241,18 @@ namespace Louis__Pharmacy_CNSA212_FP try { - patientID = txtPrescriptionPatID.Text; + medicationName = txtPrescriptionPatID.Text; try { - rxID = txtRxNumber.Text; + medID = txtRxNumber.Text; try { - ds = PharmacyDataTier.PrescriptionInfoSearch(rxID, patientID); + ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName); if (ds.Tables[0].Rows.Count > 0) // There is a record. @@ -294,6 +298,13 @@ namespace Louis__Pharmacy_CNSA212_FP } } + + + cmuRxEdit.Enabled = dgvPrescription.Rows.Count > 0; + cmuRxDelete.Enabled = dgvPrescription.Rows.Count > 0; + + dgvPrescription.Focus(); + } public void btnPhysicianSearch_Click(object sender, EventArgs e) @@ -380,6 +391,10 @@ namespace Louis__Pharmacy_CNSA212_FP } + + cmuPhysicianEdit.Enabled = dgvPhysician.Rows.Count > 0; + cmuPhysicianDelete.Enabled = dgvPhysician.Rows.Count > 0; + dgvPhysician.Focus(); } @@ -489,10 +504,18 @@ namespace Louis__Pharmacy_CNSA212_FP string phyID = ""; phyID = (row.Cells[0].Value).ToString(); PharmacyDataTier.DeletePhysician(phyID); - btnPhysicianSearch_Click(sender, e); + PhysicianReset(sender, e); } } + private void PhysicianReset(object sender, EventArgs e) + { + txtPhysicianFirst.Text = ""; + txtPhysicianLast.Text = ""; + txtPhysicianID.Text = ""; + dgvPhysician.Visible = false; + } + private void dgvPhysician_CellContentClick(object sender, DataGridViewCellEventArgs e) { } @@ -512,7 +535,7 @@ namespace Louis__Pharmacy_CNSA212_FP private void cmuRxEdit_Click(object sender, EventArgs e) { - if (dgvPhysician.Rows.Count > 0) + if (dgvPrescription.Rows.Count > 0) { dgvPrescription.DataSource = ds.Tables[0]; @@ -530,6 +553,23 @@ namespace Louis__Pharmacy_CNSA212_FP } private void cmuRxDelete_Click(object sender, EventArgs e) + { + + if (dgvPrescription.Rows.Count > 0) + { + + dgvPrescription.DataSource = ds.Tables[0]; + DataGridViewRow row = new DataGridViewRow(); + row = dgvPrescription.SelectedRows[0]; + string medID = ""; + medID = (row.Cells[0].Value).ToString(); + PharmacyDataTier.DeleteMedication(medID); + btnPrescriptionSearch_Click(sender, e); + } + + } + + private void lblDisMedicationNum_Click(object sender, EventArgs e) { } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.resx b/Louis'-Pharmacy_CNSA212-FP/frmInfo.resx index 2ed6270..fb69f30 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.resx +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.resx @@ -177,25 +177,25 @@ 17, 17 - - True - - - True - - - True - - - True - - - True - True - + + True + + + True + + + True + + + True + + + True + + True diff --git a/Louis'-Pharmacy_CNSA212-FP/frmMedication.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmMedication.Designer.cs index bf306ce..3296b45 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmMedication.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmMedication.Designer.cs @@ -40,7 +40,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.label7 = new System.Windows.Forms.Label(); this.btnGO = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); - this.label8 = new System.Windows.Forms.Label(); + this.lblDisPurpose = new System.Windows.Forms.Label(); this.txtMedID = new System.Windows.Forms.TextBox(); this.txtName = new System.Windows.Forms.TextBox(); this.txtIntake = new System.Windows.Forms.TextBox(); @@ -52,148 +52,174 @@ namespace Louis__Pharmacy_CNSA212_FP // // label1 // - this.label1.Location = new System.Drawing.Point(333, 157); + this.label1.Location = new System.Drawing.Point(222, 102); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(163, 43); + this.label1.Size = new System.Drawing.Size(109, 28); this.label1.TabIndex = 0; this.label1.Text = "Medication ID:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label2 // - this.label2.Location = new System.Drawing.Point(333, 200); + this.label2.Location = new System.Drawing.Point(222, 130); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(163, 43); + this.label2.Size = new System.Drawing.Size(109, 28); this.label2.TabIndex = 1; this.label2.Text = "Name:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label3 // - this.label3.Location = new System.Drawing.Point(333, 243); + this.label3.Location = new System.Drawing.Point(222, 158); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(163, 43); + this.label3.Size = new System.Drawing.Size(109, 28); this.label3.TabIndex = 2; this.label3.Text = "Intake Method:"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label4 // - this.label4.Location = new System.Drawing.Point(333, 286); + this.label4.Location = new System.Drawing.Point(222, 186); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(163, 43); + this.label4.Size = new System.Drawing.Size(109, 28); this.label4.TabIndex = 3; this.label4.Text = "Frequency:"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label5 // - this.label5.Location = new System.Drawing.Point(333, 329); + this.label5.Location = new System.Drawing.Point(222, 214); + this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(163, 43); + this.label5.Size = new System.Drawing.Size(109, 28); this.label5.TabIndex = 4; this.label5.Text = "Dosage:"; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label6 // - this.label6.Location = new System.Drawing.Point(333, 372); + this.label6.Location = new System.Drawing.Point(222, 242); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(163, 43); + this.label6.Size = new System.Drawing.Size(109, 28); this.label6.TabIndex = 5; this.label6.Text = "Purpose:"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label7 // - this.label7.Location = new System.Drawing.Point(333, 415); + this.label7.Location = new System.Drawing.Point(222, 270); + this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(163, 43); + this.label7.Size = new System.Drawing.Size(109, 28); this.label7.TabIndex = 6; this.label7.Text = "Rx Number:"; this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // btnGO // - this.btnGO.Location = new System.Drawing.Point(767, 567); + this.btnGO.Location = new System.Drawing.Point(511, 369); + this.btnGO.Margin = new System.Windows.Forms.Padding(2); this.btnGO.Name = "btnGO"; - this.btnGO.Size = new System.Drawing.Size(101, 36); + this.btnGO.Size = new System.Drawing.Size(67, 23); this.btnGO.TabIndex = 7; this.btnGO.UseVisualStyleBackColor = true; + this.btnGO.Click += new System.EventHandler(this.btnGO_Click); // // btnCancel // - this.btnCancel.Location = new System.Drawing.Point(896, 567); + this.btnCancel.Location = new System.Drawing.Point(597, 369); + this.btnCancel.Margin = new System.Windows.Forms.Padding(2); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(101, 36); + this.btnCancel.Size = new System.Drawing.Size(67, 23); this.btnCancel.TabIndex = 8; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // - // label8 + // lblDisPurpose // - this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label8.Location = new System.Drawing.Point(176, 30); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(691, 72); - this.label8.TabIndex = 9; - this.label8.Text = "Medication"; - this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblDisPurpose.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblDisPurpose.Location = new System.Drawing.Point(117, 19); + this.lblDisPurpose.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblDisPurpose.Name = "lblDisPurpose"; + this.lblDisPurpose.Size = new System.Drawing.Size(461, 47); + this.lblDisPurpose.TabIndex = 9; + this.lblDisPurpose.Text = "Medication"; + this.lblDisPurpose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // txtMedID // - this.txtMedID.Location = new System.Drawing.Point(502, 165); + this.txtMedID.Location = new System.Drawing.Point(335, 107); + this.txtMedID.Margin = new System.Windows.Forms.Padding(2); this.txtMedID.Name = "txtMedID"; - this.txtMedID.Size = new System.Drawing.Size(182, 26); + this.txtMedID.Size = new System.Drawing.Size(123, 20); this.txtMedID.TabIndex = 10; + this.txtMedID.TextChanged += new System.EventHandler(this.txtMedID_TextChanged); // // txtName // - this.txtName.Location = new System.Drawing.Point(502, 208); + this.txtName.Location = new System.Drawing.Point(335, 135); + this.txtName.Margin = new System.Windows.Forms.Padding(2); this.txtName.Name = "txtName"; - this.txtName.Size = new System.Drawing.Size(182, 26); + this.txtName.Size = new System.Drawing.Size(123, 20); this.txtName.TabIndex = 11; + this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); // // txtIntake // - this.txtIntake.Location = new System.Drawing.Point(502, 251); + this.txtIntake.Location = new System.Drawing.Point(335, 163); + this.txtIntake.Margin = new System.Windows.Forms.Padding(2); this.txtIntake.Name = "txtIntake"; - this.txtIntake.Size = new System.Drawing.Size(182, 26); + this.txtIntake.Size = new System.Drawing.Size(123, 20); this.txtIntake.TabIndex = 12; + this.txtIntake.TextChanged += new System.EventHandler(this.txtIntake_TextChanged); // // txtFrequency // - this.txtFrequency.Location = new System.Drawing.Point(502, 294); + this.txtFrequency.Location = new System.Drawing.Point(335, 191); + this.txtFrequency.Margin = new System.Windows.Forms.Padding(2); this.txtFrequency.Name = "txtFrequency"; - this.txtFrequency.Size = new System.Drawing.Size(182, 26); + this.txtFrequency.Size = new System.Drawing.Size(123, 20); this.txtFrequency.TabIndex = 13; + this.txtFrequency.TextChanged += new System.EventHandler(this.txtFrequency_TextChanged); // // txtDosage // - this.txtDosage.Location = new System.Drawing.Point(502, 337); + this.txtDosage.Location = new System.Drawing.Point(335, 219); + this.txtDosage.Margin = new System.Windows.Forms.Padding(2); this.txtDosage.Name = "txtDosage"; - this.txtDosage.Size = new System.Drawing.Size(182, 26); + this.txtDosage.Size = new System.Drawing.Size(123, 20); this.txtDosage.TabIndex = 14; + this.txtDosage.TextChanged += new System.EventHandler(this.txtDosage_TextChanged); // // txtPurpose // - this.txtPurpose.Location = new System.Drawing.Point(502, 380); + this.txtPurpose.Location = new System.Drawing.Point(335, 247); + this.txtPurpose.Margin = new System.Windows.Forms.Padding(2); this.txtPurpose.Name = "txtPurpose"; - this.txtPurpose.Size = new System.Drawing.Size(182, 26); + this.txtPurpose.Size = new System.Drawing.Size(123, 20); this.txtPurpose.TabIndex = 15; + this.txtPurpose.TextChanged += new System.EventHandler(this.txtPurpose_TextChanged); // // txtRxNum // - this.txtRxNum.Location = new System.Drawing.Point(502, 423); + this.txtRxNum.Location = new System.Drawing.Point(335, 275); + this.txtRxNum.Margin = new System.Windows.Forms.Padding(2); this.txtRxNum.Name = "txtRxNum"; - this.txtRxNum.Size = new System.Drawing.Size(182, 26); + this.txtRxNum.Size = new System.Drawing.Size(123, 20); this.txtRxNum.TabIndex = 16; + this.txtRxNum.TextChanged += new System.EventHandler(this.txtRxNum_TextChanged); // // frmMedication // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1041, 649); + this.ClientSize = new System.Drawing.Size(694, 422); this.Controls.Add(this.txtRxNum); this.Controls.Add(this.txtPurpose); this.Controls.Add(this.txtDosage); @@ -201,7 +227,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.Controls.Add(this.txtIntake); this.Controls.Add(this.txtName); this.Controls.Add(this.txtMedID); - this.Controls.Add(this.label8); + this.Controls.Add(this.lblDisPurpose); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnGO); this.Controls.Add(this.label7); @@ -211,8 +237,10 @@ namespace Louis__Pharmacy_CNSA212_FP this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "frmMedication"; this.Text = "frmMedication"; + this.Load += new System.EventHandler(this.frmMedication_Load); this.ResumeLayout(false); this.PerformLayout(); } @@ -234,7 +262,7 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.Label label7; private System.Windows.Forms.Button btnGO; private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label lblDisPurpose; #endregion } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs b/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs index c317bc2..f611939 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs @@ -1,13 +1,47 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; using System.Data; +using System.Drawing.Imaging; +using System.Net.NetworkInformation; namespace Louis__Pharmacy_CNSA212_FP { public partial class frmMedication : Form { + private readonly bool isAdd; + private frmInfo SourceForm; + ErrorProvider epLocal = new ErrorProvider(); public frmMedication(frmInfo sourceForm, bool isNew) { + + + SourceForm = sourceForm; + + isAdd = isNew; InitializeComponent(); + + + + if (isNew) + { + lblDisPurpose.Text = "Add Medication"; + btnGO.Text = "Create"; + } + else + { + lblDisPurpose.Text = "Edit Medication"; + btnGO.Text = "Update"; + } + KeyPreview = true; + KeyDown += frmMedication_KeyDown; + } + + private void frmMedication_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + Close(); + + if (e.KeyCode == Keys.Enter) btnGO_Click(sender, e); } public void FillMedication(string rxID) @@ -24,5 +58,216 @@ namespace Louis__Pharmacy_CNSA212_FP txtPurpose.Text = ds.Tables[0].Rows[0]["Purpose"].ToString(); txtRxNum.Text = ds.Tables[0].Rows[0]["RxNum"].ToString(); } + + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void btnGO_Click(object sender, EventArgs e) + { + + var hasFailed = false; + + var Medication_id = ""; + var MedicationName = ""; + var IntakeMethod = ""; + var Frequency = ""; + var Dosage = ""; + var Purpose = ""; + var RxNum = ""; + + + if (txtMedID.Text.Length + txtName.Text.Length + txtIntake.Text.Length + txtFrequency.Text.Length + txtDosage.Text.Length + txtPurpose.Text.Length + txtRxNum.Text.Length > 0) + { + + + + try + { + RxNum = txtRxNum.Text; + + if (RxNum.Length > 30) + { + throw new Exception(); + } + + } + catch (Exception exception) + { + epLocal.SetError(txtRxNum, "Invalid Value"); + hasFailed = true; + } + try + { + Purpose = txtPurpose.Text; + + if (Purpose.Length > 100) + { + throw new Exception(); + } + } + catch (Exception exception) + { + epLocal.SetError(txtPurpose, "Invalid Value"); + hasFailed = true; + } + try + { + Dosage = txtDosage.Text; + + if (Dosage.Length > 30) + { + throw new Exception(); + } + } + catch (Exception exception) + { + epLocal.SetError(txtDosage, "Invalid Value"); + hasFailed = true; + } + try + { + + Frequency = txtFrequency.Text; + + if (Frequency.Length > 30) + { + throw new Exception(); + } + + } + catch (Exception exception) + { + epLocal.SetError(txtFrequency, "Invalid Value"); + hasFailed = true; + } + try + { + IntakeMethod = txtIntake.Text; + if (IntakeMethod.Length>30) + { + throw new Exception(); + } + } + catch (Exception exception) + { + epLocal.SetError(txtIntake, "Invalid Value"); + hasFailed = true; + } + try + { + MedicationName = txtName.Text; + if (MedicationName.Length>60) + { + throw new Exception(); + } + } + catch (Exception exception) + { + epLocal.SetError(txtName, "Invalid Value"); + hasFailed = true; + } + + try + { + Medication_id = txtMedID.Text; + if (Medication_id.Length>7) + { + throw new Exception(); + } + + while (Medication_id.Length < 7) + { + Medication_id = "0" + Medication_id; + } + } + catch (Exception exception) + { + epLocal.SetError(txtMedID, "Invalid Value"); + hasFailed = true; + } + + if (!hasFailed) + { + if (isAdd) + { + PharmacyDataTier.CreateMedication( + Medication_id, + MedicationName, + IntakeMethod, + Frequency, + Dosage, + Purpose, + RxNum); + } + else + { + PharmacyDataTier.UpdateMedication( + Medication_id, + MedicationName, + IntakeMethod, + Frequency, + Dosage, + Purpose, + RxNum); + } + + SourceForm.txtRxNumber.Text = Medication_id; + SourceForm.btnPrescriptionSearch_Click(sender, e); + Close(); + + + } + } + + } + + private void frmMedication_Load(object sender, EventArgs e) + { + txtMedID.Enabled = false; + + if (isAdd) + { + var nextID = PharmacyDataTier.GetNextMedicationID(); + txtMedID.Text = nextID.ToString(); + } + } + + + private void txtMedID_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtMedID,""); + } + + private void txtName_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtName,""); + } + + private void txtIntake_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtIntake,""); + } + + private void txtFrequency_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtFrequency,""); + } + + private void txtDosage_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtDosage,""); + } + + private void txtPurpose_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtPurpose,""); + } + + private void txtRxNum_TextChanged(object sender, EventArgs e) + { + epLocal.SetError(txtRxNum,""); + } } } \ No newline at end of file