示例#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 AllHerb GetAllHerb(string allHerbID)
 {
     try
     {
         using (DispenseryEntities db = new DispenseryEntities())
         {
             AllHerb ah = db.AllHerbs.Find(allHerbID);
             return(ah);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public AllHerb GetHerbByName(string HerbName)
 {
     try
     {
         using (DispenseryEntities db = new DispenseryEntities())
         {
             AllHerb ah = db.AllHerbs.SingleOrDefault(AllHerb => AllHerb.HerbName == HerbName);
             return(ah);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#4
0
        public string InsertHerb(AllHerb allHerbs)
        {
            try
            {
                DispenseryEntities db = new DispenseryEntities();
                db.AllHerbs.Add(allHerbs);
                db.SaveChanges();

                return(allHerbs.HerbName + " was succesfully inserted.");
            }

            catch (Exception ex)
            {
                return("Error: " + ex);
            }
        }
示例#5
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);
        }
示例#6
0
        public string DeleteHerb(string refNum)
        {
            try
            {
                DispenseryEntities db = new DispenseryEntities();
                AllHerb            aH = db.AllHerbs.Find(refNum);
                db.AllHerbs.Attach(aH);
                db.AllHerbs.Remove(aH);
                db.SaveChanges();



                return(aH.HerbName + " was succesfully removed.");
            }

            catch (Exception ex)
            {
                return("Error: " + ex);
            }
        }
示例#7
0
        public string UpdateHerb(string refNum, AllHerb allHerb)
        {
            try
            {
                DispenseryEntities db = new DispenseryEntities();
                //fetch object from db
                AllHerb aH = db.AllHerbs.Find(refNum);
                aH.Active          = allHerb.Active;
                aH.Description     = allHerb.Description;
                aH.EnglishName     = allHerb.EnglishName;
                aH.HerbName        = allHerb.HerbName;
                aH.HerbNameChinese = allHerb.HerbNameChinese;
                aH.PharmaName      = allHerb.PharmaName;
                aH.Temperature     = allHerb.Temperature;
                db.SaveChanges();

                return(allHerb.HerbName + " was succesfully updated.");
            }

            catch (Exception ex)
            {
                return("Error: " + ex);
            }
        }