Esempio n. 1
0
        private HerbStock CreateHerbStock()
        {
            HerbStock     hs  = new HerbStock();
            AllHerbsModel ahm = new AllHerbsModel();
            AllHerb       ah  = ahm.GetHerbByName(tbxHerb.Text);

            hs.HerbRefNum         = ah.RefNum.ToString();
            hs.BatchNum           = tbxBatchNumber.Text;
            hs.BuyPrice           = Convert.ToDecimal(tbxSupplierPrice.Text);
            hs.ExpiryDate         = Convert.ToDateTime(tbxExpiaryDate.Text);
            hs.Quantity           = Convert.ToDecimal(tbxQuantity.Text);
            hs.SupplierID         = Convert.ToInt32(ddlSupplier.SelectedValue);
            hs.HerbRawToGranRatio = Convert.ToDecimal(tbxRatio.Text);
            hs.DateReceived       = Convert.ToDateTime(tbxDateReceived.Text);
            if (tbxDateToDispensery.Text == "")
            {
                hs.DateToDispensery = null;
            }
            else
            {
                hs.DateToDispensery = Convert.ToDateTime(tbxDateToDispensery.Text);
            }
            hs.HerbForm = ddlHerbForm.SelectedItem.Text;
            return(hs);
        }
        public string UpdateHerbStock(int herbStockID, HerbStock herbStock)
        {
            try
            {
                DispenseryEntities db = new DispenseryEntities();
                //fetch object from db
                HerbStock hs = db.HerbStocks.Find(herbStockID);
                hs.HerbRefNum         = herbStock.HerbRefNum;
                hs.BatchNum           = herbStock.BatchNum;
                hs.BuyPrice           = herbStock.BuyPrice;
                hs.ExpiryDate         = herbStock.ExpiryDate;
                hs.Quantity           = herbStock.Quantity;
                hs.SupplierID         = herbStock.SupplierID;
                hs.HerbRawToGranRatio = herbStock.HerbRawToGranRatio;
                hs.DateReceived       = herbStock.DateReceived;
                hs.DateToDispensery   = herbStock.DateToDispensery;
                hs.HerbForm           = herbStock.HerbForm;
                hs.DateLastChanged    = herbStock.DateLastChanged;



                db.SaveChanges();

                return("Herb ref.: " + herbStock.HerbRefNum + ", batch : " + herbStock.BatchNum + " was succesfully inserted.");
            }

            catch (Exception ex)
            {
                return("Error: " + ex);
            }
        }
Esempio n. 3
0
        protected void btnUpdateHerbStock_Click(object sender, EventArgs e)
        {
            HerbStockModel hsModel = new HerbStockModel();
            HerbStock      hs      = CreateHerbStock();

            if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                int id       = Convert.ToInt32(Request.QueryString["id"]);
                int rowIndex = Convert.ToInt32(Request.QueryString["rowIndex"]);

                divAlertSuccess.Visible        = true;
                lblNoSelectionAlertHeader.Text = hsModel.UpdateHerbStock(id, hs);
                Response.Redirect("ViewInventory.aspx?rowIndex=" + rowIndex);
            }
        }
        //public string DeletePatient(int patientId)
        //{
        //    try
        //    {
        //        DispenseryEntities db = new DispenseryEntities();
        //        HerbStock hs = db.Patients.Find(patientId);
        //        db.Patients.Attach(hs);
        //        db.Patients.Remove(hs);
        //        db.SaveChanges();



        //        return hs.PatientName + " " + hs.PatientSurname + " was succesfully removed.";
        //    }

        //    catch (Exception ex)
        //    {

        //        return "Error: " + ex;
        //    }
        //}

        public HerbStock GetHerbStock(int herbStockID)
        {
            try
            {
                using (DispenseryEntities db = new DispenseryEntities())
                {
                    HerbStock hs = db.HerbStocks.Find(herbStockID);
                    return(hs);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public string InsertHerbToStock(HerbStock herbStock)
        {
            try
            {
                DispenseryEntities db = new DispenseryEntities();
                db.HerbStocks.Add(herbStock);
                db.SaveChanges();

                return("Herb ref.: " + herbStock.HerbRefNum + ", batch : " + herbStock.BatchNum + " was succesfully inserted.");
            }

            catch (Exception ex)
            {
                return("Error: " + ex);
            }
        }
Esempio n. 6
0
        private void FillPage(int id)
        {
            HerbStockModel herbStock = new HerbStockModel();
            HerbStock      hs        = herbStock.GetHerbStock(id);
            AllHerbsModel  ahm       = new AllHerbsModel();
            AllHerb        ah        = ahm.GetAllHerb(hs.HerbRefNum.ToString());

            tbxHerb.Text              = ah.HerbName;
            tbxQuantity.Text          = hs.Quantity.ToString();
            tbxBatchNumber.Text       = hs.BatchNum;
            tbxExpiaryDate.Text       = String.Format("{0:dd/MM/yyyy}", hs.ExpiryDate);
            ddlSupplier.SelectedValue = hs.SupplierID.ToString();
            tbxSupplierPrice.Text     = String.Format("{0:0.0000}", hs.BuyPrice);
            ddlHerbForm.SelectedValue = hs.HerbForm.ToString();
            tbxRatio.Text             = hs.HerbRawToGranRatio.ToString();
            tbxDateReceived.Text      = String.Format("{0:dd/MM/yyyy}", hs.DateReceived);

            tbxDateToDispensery.Text = String.Format("{0:dd/MM/yyyy}", hs.DateToDispensery);
        }