private void butClose_Click(object sender, EventArgs e) { //Regular Expressions to validate the format of the entered value in the textAnesthDose and textQtyWasted Regex regexDose = new Regex("^\\d{1,4}(\\.\\d{1,2})?$"); Regex regexQtyWasted = new Regex("^\\d{1,4}(\\.\\d{1,2})?$"); if (!(regexDose.IsMatch(textDose.Text)) && textDose.Text != "") { MessageBox.Show(Lan.g(this, "Dose should be xxx.xx format")); textQtyWasted.Focus(); } else if (!(regexQtyWasted.IsMatch(textQtyWasted.Text)) && textQtyWasted.Text != "") { MessageBox.Show(Lan.g(this, "Amount wasted should be xxx.xx format")); textQtyWasted.Focus(); } else { double dose = Convert.ToDouble(textDose.Text); double amtWasted = Convert.ToDouble(textQtyWasted.Text); AnesthMeds.UpdateAMedDose(textAnesthMedName.Text, Convert.ToDouble(textDose.Text), Convert.ToDouble(amtWasted), textDoseTimeStamp.Text, anestheticMedNum, anestheticRecordNum); Close(); } }
private void FillGrid() { listAnestheticMeds = AnesthMeds.CreateObjects(); gridAnesthMedsInventory.BeginUpdate(); gridAnesthMedsInventory.Columns.Clear(); textAlign = HorizontalAlignment.Center; ODGridColumn col = new ODGridColumn(Lan.g(this, "Anesthetic Medication"), 200, textAlign); gridAnesthMedsInventory.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "How Supplied"), 200, textAlign); gridAnesthMedsInventory.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Quantity on Hand (mL)"), 180, textAlign); gridAnesthMedsInventory.Columns.Add(col); gridAnesthMedsInventory.Rows.Clear(); ODGridRow row; for (int i = 0; i < listAnestheticMeds.Count; i++) { row = new ODGridRow(); row.Cells.Add(listAnestheticMeds[i].AnesthMedName); row.Cells.Add(listAnestheticMeds[i].AnesthHowSupplied); row.Cells.Add(listAnestheticMeds[i].QtyOnHand); gridAnesthMedsInventory.Rows.Add(row); } gridAnesthMedsInventory.EndUpdate(); }
private void textQtyAdj_TextChanged(object sender, EventArgs e) { //prevents user from using this form to enter initial quantities. This should be done on FormAnestheticMedsIntake if (AnesthMeds.GetQtyOnHand(textAnesthMedName.Text) == 0) { MessageBox.Show(this, "Please use the 'Intake new meds' button on the previous form \rto add initial inventory quantities"); butOK.Enabled = false; } }
private void butDelete_Click(object sender, EventArgs e) { if (Med.IsNew) { DialogResult = DialogResult.Cancel; } if (!MsgBox.Show(this, true, "Delete?")) { return; } AnesthMeds.DeleteObject(Med); DialogResult = DialogResult.OK; }
private void butClose_Click(object sender, EventArgs e) { if (comboAnesthMedName.SelectedIndex == -1 || textQty.Text == "" || comboSupplierName.SelectedIndex == -1 || textInvoiceNum.Text == "") { MessageBox.Show(Lan.g(this, "All fields are mandatory.")); return; } else { Regex regex = new Regex("^\\d{1,6}?$"); if (!(regex.IsMatch(textQty.Text)) && textQty.Text != "") { MessageBox.Show(Lan.g(this, "The Quantity field should be a 1-6 digit integer.")); textQty.Focus(); return; } else { if (comboAnesthMedName.SelectedIndex != 0 && comboSupplierName.SelectedIndex != 0) { if (textInvoiceNum.Text.Trim() == "") { MessageBox.Show(Lan.g(this, "Invoice # does not accept spaces.")); textInvoiceNum.Focus(); } } } //the current QtyOnHand of a scheduled anesthetic medication double qtyOnHand = Convert.ToDouble(AnesthMeds.GetQtyOnHand(comboAnesthMedName.SelectedItem.ToString())); //records transaction into tableanesthmedsintake which tracks intake of scheduled anesthetic medications into inventory int supplierIDNum = AnesthMedSuppliers.GetSupplierIDNum(comboSupplierName.SelectedIndex); AnesthMeds.InsertMed_Intake(comboAnesthMedName.SelectedItem.ToString(), Convert.ToInt32(textQty.Text), supplierIDNum.ToString(), textInvoiceNum.Text); //updates QtyOnHand in tableanesthmedsinventory when a new order of scheduled anesthetic medications is received into inventory AnesthMeds.UpdateAMedInvAdj(comboAnesthMedName.SelectedItem.ToString(), Convert.ToDouble(textQty.Text), qtyOnHand); DialogResult = DialogResult.OK; Close(); } }
private void butOK_Click(object sender, EventArgs e) { AdjustNumCur = new AnesthMedsInventoryAdj(); if (textAnesthMedName.Text == "") { MsgBox.Show(this, "Please enter a name."); return; } //write inventory data to anesthetic meds inventory db Med.AnesthMedName = textAnesthMedName.Text; Med.AnesthHowSupplied = textAnesthHowSupplied.Text; Med.DEASchedule = comboDEASchedule.Text; if (Med.IsNew != true) { Med.QtyOnHand = textQtyOnHand.Text; } if (Med.QtyOnHand == null) { Med.QtyOnHand = "0"; } if (Med.DEASchedule == null) { Med.DEASchedule = ""; } //write adjustment data to anesthetic meds inventory adjustment db Userod curUser = Security.CurUser; AdjustNumCur.AnestheticMedNum = Convert.ToInt32(Med.AnestheticMedNum); if (textQtyAdj.Text != "") { Regex regex = new Regex("^-\\d{1,6}?$|^\\d{1,6}?$"); if (!(regex.IsMatch(textQtyAdj.Text)) && textQtyAdj.Text != "") { MessageBox.Show("The Quantity field should be a 1-6 digit integer."); textQtyAdj.Focus(); return; } else { AdjustNumCur.QtyAdj = Convert.ToDouble(textQtyAdj.Text); } } AdjustNumCur.UserNum = Convert.ToInt32(curUser.UserNum); if (textNotes.Text != "") { AdjustNumCur.Notes = textNotes.Text; } AdjustNumCur.TimeStamp = DateTime.Now; AnesthMedInvAdjs.Insert(AdjustNumCur); //write inventory adjustment back to table anesthmedsinventory double newQty = Convert.ToDouble(Med.QtyOnHand) + Convert.ToDouble(AdjustNumCur.QtyAdj); Med.QtyOnHand = newQty.ToString(); AnesthMeds.WriteObject(Med); DialogResult = DialogResult.OK; }