Пример #1
0
 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 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();
            }
        }