From 54528b2a5b78d3a5d36e7e8d8a0e43b497153e9d Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Fri, 16 Feb 2024 12:41:14 -0500 Subject: [PATCH] Created the search functionality for the refill form. Created the refill add form. --- .../Louis'-Pharmacy_CNSA212-FP.csproj | 6 +++ .../PharmacyDataTier.cs | 39 ++++++++++++++- .../frmRefill.Designer.cs | 47 ++++++++++--------- Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 40 +++++++++++++++- Louis'-Pharmacy_CNSA212-FP/frmRefill.resx | 2 +- .../frmRefillAdd.Designer.cs | 39 +++++++++++++++ Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 20 ++++++++ 7 files changed, 168 insertions(+), 25 deletions(-) create mode 100644 Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs create mode 100644 Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs diff --git a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj index dbfad5e..48fa102 100644 --- a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj +++ b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj @@ -89,6 +89,12 @@ frmRefill.cs + + Form + + + frmRefillAdd.cs + Form diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 8555b67..31cb88a 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -208,6 +208,43 @@ namespace Louis__Pharmacy_CNSA212_FP myConn.Close(); } } - + + public static DataSet RefillSearch(DateTime date, string id) + { + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "SearchRefills"; + // Define input parameter + cmdString.Parameters.Add("@date", SqlDbType.Date).Value = date; + cmdString.Parameters.Add("@ID", SqlDbType.VarChar, 8).Value = id; + // 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(); + } + } + } } \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index 1d1b000..7977919 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -44,13 +44,13 @@ namespace Louis__Pharmacy_CNSA212_FP this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.rEFILLSBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton(); - this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.dgvRefills = new System.Windows.Forms.DataGridView(); this.refillid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.refilldate = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cmuRefill = new System.Windows.Forms.ContextMenuStrip(this.components); this.cmuAdd = new System.Windows.Forms.ToolStripMenuItem(); this.cmuUpdate = new System.Windows.Forms.ToolStripMenuItem(); this.cmuDelete = new System.Windows.Forms.ToolStripMenuItem(); @@ -60,8 +60,8 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnSearch = new System.Windows.Forms.Button(); this.lblPatientID = new System.Windows.Forms.Label(); this.lblDate = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); - this.contextMenuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit(); + this.cmuRefill.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -129,21 +129,23 @@ namespace Louis__Pharmacy_CNSA212_FP this.rEFILLSBindingNavigatorSaveItem.Name = "rEFILLSBindingNavigatorSaveItem"; this.rEFILLSBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 23); // - // dataGridView1 + // dgvRefills // - this.dataGridView1.AllowUserToAddRows = false; - this.dataGridView1.AllowUserToDeleteRows = false; - this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.dgvRefills.AllowUserToAddRows = false; + this.dgvRefills.AllowUserToDeleteRows = false; + this.dgvRefills.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvRefills.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.refillid, this.refilldate, this.patientid, this.medicationid, this.rxnumber}); - this.dataGridView1.Location = new System.Drawing.Point(3, 3); - this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.Size = new System.Drawing.Size(625, 239); - this.dataGridView1.TabIndex = 0; + this.dgvRefills.ContextMenuStrip = this.cmuRefill; + this.dgvRefills.Location = new System.Drawing.Point(3, 3); + this.dgvRefills.Name = "dgvRefills"; + this.dgvRefills.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvRefills.Size = new System.Drawing.Size(625, 239); + this.dgvRefills.TabIndex = 0; // // refillid // @@ -178,14 +180,14 @@ namespace Louis__Pharmacy_CNSA212_FP this.rxnumber.HeaderText = "Rx Number"; this.rxnumber.Name = "rxnumber"; // - // contextMenuStrip1 + // cmuRefill // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cmuRefill.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuAdd, this.cmuUpdate, this.cmuDelete}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(113, 70); + this.cmuRefill.Name = "contextMenuStrip1"; + this.cmuRefill.Size = new System.Drawing.Size(113, 70); // // cmuAdd // @@ -221,7 +223,7 @@ namespace Louis__Pharmacy_CNSA212_FP // // splitContainer1.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.dataGridView1); + this.splitContainer1.Panel2.Controls.Add(this.dgvRefills); this.splitContainer1.Size = new System.Drawing.Size(631, 498); this.splitContainer1.SplitterDistance = 249; this.splitContainer1.TabIndex = 1; @@ -248,6 +250,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnSearch.TabIndex = 2; this.btnSearch.Text = "Search"; this.btnSearch.UseVisualStyleBackColor = true; + this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); // // lblPatientID // @@ -278,8 +281,8 @@ namespace Louis__Pharmacy_CNSA212_FP this.Name = "frmRefill"; this.Text = "Louis\' Pharmacy - Prescription Refill"; this.Load += new System.EventHandler(this.frmRefill_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); - this.contextMenuStrip1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).EndInit(); + this.cmuRefill.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.PerformLayout(); this.splitContainer1.Panel2.ResumeLayout(false); @@ -317,13 +320,13 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn13; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn14; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn15; - private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.DataGridView dgvRefills; private System.Windows.Forms.DataGridViewTextBoxColumn refillid; private System.Windows.Forms.DataGridViewTextBoxColumn refilldate; private System.Windows.Forms.DataGridViewTextBoxColumn patientid; private System.Windows.Forms.DataGridViewTextBoxColumn medicationid; private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ContextMenuStrip cmuRefill; private System.Windows.Forms.ToolStripMenuItem cmuAdd; private System.Windows.Forms.ToolStripMenuItem cmuUpdate; private System.Windows.Forms.ToolStripMenuItem cmuDelete; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index 16a900c..8e8813c 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -29,7 +29,45 @@ namespace Louis__Pharmacy_CNSA212_FP private void frmRefill_Load(object sender, EventArgs e) { - + dgvRefills.Visible = false; + } + + private void btnSearch_Click(object sender, EventArgs e) + { + string patientID = ""; + DateTime date = new DateTime(); + + try + { + DataSet ds = new DataSet(); + //PharmacyDataTier phaDT = new PharmacyDataTier(); + + patientID = txtPatientID.Text.Trim(); + if (txtDate.Text.Trim().Length > 0) + { + date = DateTime.Parse(txtDate.Text.Trim()); + } + + ds = PharmacyDataTier.RefillSearch(date, patientID); + + if (ds.Tables[0].Rows.Count > 0 ) + { + dgvRefills.Visible = true; + + dgvRefills.DataSource = ds.Tables[0]; + dgvRefills.AlternatingRowsDefaultCellStyle.BackColor = Color.Black; + dgvRefills.AlternatingRowsDefaultCellStyle.ForeColor = Color.White; + } + else + { + dgvRefills.Visible = false; + MessageBox.Show("No records found"); + } + } + catch (Exception ex) + { + + } } } } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx index e194b91..0a6275b 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx @@ -132,7 +132,7 @@ True - + 17, 17 diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs new file mode 100644 index 0000000..2f7396e --- /dev/null +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs @@ -0,0 +1,39 @@ +namespace Louis__Pharmacy_CNSA212_FP +{ + partial class frmRefillAdd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "frmRefillAdd"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs new file mode 100644 index 0000000..265080f --- /dev/null +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Louis__Pharmacy_CNSA212_FP +{ + public partial class frmRefillAdd : Form + { + public frmRefillAdd() + { + InitializeComponent(); + } + } +}