예제 #1
0
        /**
         * This method is being invoked by Employee on the Medicine/Purchase Form. The Employee
         * has to select the required medicines and click to purchase button. The method loops
         * through the list of medicines and create a new fiscal account.
         */
        private void purchase(object sender, EventArgs e)
        {
            /* rand unique fiscal no */
            int randFiscalNo = rand.Next(1, 999999);

            if (dgv_AvaialbleMedicines.SelectedRows.Count != 0)
            {
                foreach (DataGridViewRow item in this.dgv_AvaialbleMedicines.SelectedRows)
                {
                    var MedicineId = (ObjectId)item.Cells[0].Value;     // get medicine id from selected item
                    medicineHelper.updateMedicines(MedicineId, false);  // update the value of selected medicines

                    /* create new fiscal account for purchase */
                    Fiscal newFiscal = new Fiscal
                    {
                        EmployeeId    = Employee.Instance.id,
                        MedicineId    = MedicineId,
                        fiscalNo      = randFiscalNo,
                        date          = String.Format("{0:d/M/yyyy HH:mm:ss}", DateTime.Now),
                        medicineName  = item.Cells[1].Value.ToString(),
                        medicinePrice = Convert.ToInt32(item.Cells[8].Value)
                    };

                    fiscalHelper.add(newFiscal);
                }


                /* refreshing datagridview */
                dgv_AvaialbleMedicines.DataSource = medicineHelper.getAvailableMedicines();
                lbl_response.Text = "Transakcija je uspešno završena. Račun je izdat.";
            }
            else
            {
                lbl_response.Text = "Nijedan od lekova nije odabran.";
            }
        }
예제 #2
0
 /**
  * This method is being invoked by the Employee on Purchase/Medicine's form. The method
  * uses forwarded object trying to save it into MongoDB Employees collection.
  *
  * @param obj
  */
 public void add(Fiscal obj)
 {
     ctx.Fiscals.Save(obj);
 }
예제 #3
0
 public FormFiscal()
 {
     InitializeComponent();
     fiscalHelper = new Fiscal();
 }
예제 #4
0
 public FormMedicine()
 {
     InitializeComponent();
     medicineHelper = new Medicine();
     fiscalHelper   = new Fiscal();
 }