Example #1
0
        static public Item SearchItem(string itemID)
        {
            HLFEntities ctx = new HLFEntities();

            try
            {
                return(ctx.Item.ToList().Find(x => x.ItemID == itemID));
            }
            catch (Exception) { throw; }
        }
Example #2
0
        /*
         * This class defines the service methods available for the Item class
         *
         * Changelog:
         * 2018-04-24 0845 | Sam Teong | Initial Release
         *
         */

        static public List <Item> GetItemList()
        {
            HLFEntities ctx = new HLFEntities();

            try
            {
                return(ctx.Item.ToList());
            }
            catch (Exception) { throw; }
        }
Example #3
0
        static public string AddItem(Item item)
        {
            HLFEntities ctx = new HLFEntities();

            try
            {
                ctx.Item.Add(item);
                ctx.SaveChanges();
                return(HLFMsg.AddItemOKMsg);
            }
            catch (Exception) { return(HLFMsg.AddItemNGMsg); throw; }
        }
Example #4
0
        static public string RemoveItem(string itemID)
        {
            HLFEntities ctx = new HLFEntities();

            try
            {
                Item original = SearchItem(itemID);
                if (original == null)
                {
                    return(HLFMsg.FindItemNGMsg);
                }
                ctx.Item.Remove(original);
                ctx.SaveChanges();
                return(HLFMsg.RemoveItemOKMsg);
            }
            catch (Exception) { return(HLFMsg.RemoveItemNGMsg); throw; }
        }
Example #5
0
        static public string UpdateItem(Item item)
        {
            HLFEntities ctx = new HLFEntities();

            try
            {
                Item original = SearchItem(item.ItemID);
                if (original == null)
                {
                    return(HLFMsg.FindItemNGMsg);
                }
                original = item;
                ctx.SaveChanges();
                return(HLFMsg.UpdateItemOKMsg);
            }
            catch (Exception) { return(HLFMsg.UpdateItemNGMsg);  throw; }
        }
        private void btn_RefreshDGV_Click(object sender, EventArgs e)
        {
            HLFEntities ctx = new HLFEntities();

            switch (cbx_TableSelector.Text)
            {
            case "Appointment":
                dgv_DisplayRecord.DataSource = ctx.Appointment.ToList();
                dgv_DisplayRecord.Columns["Customer"].Visible = false;
                break;

            case "Case":
                dgv_DisplayRecord.DataSource = ctx.Case.ToList();
                dgv_DisplayRecord.Columns["Customer"].Visible = false;
                dgv_DisplayRecord.Columns["Employee"].Visible = false;
                break;

            case "Customer":
                dgv_DisplayRecord.DataSource = ctx.Customer.ToList();
                dgv_DisplayRecord.Columns["Appointment"].Visible = false;
                dgv_DisplayRecord.Columns["Case"].Visible        = false;
                break;

            case "Employee":
                dgv_DisplayRecord.DataSource = ctx.Employee.ToList();
                dgv_DisplayRecord.Columns["Leave"].Visible = false;
                break;

            case "Inventory":
                dgv_DisplayRecord.DataSource = ctx.Inventory.ToList();
                dgv_DisplayRecord.Columns["Item"].Visible = false;
                break;

            case "Item":
                dgv_DisplayRecord.DataSource = ctx.Item.ToList();
                dgv_DisplayRecord.Columns["Inventory"].Visible = false;
                dgv_DisplayRecord.Columns["Supplier"].Visible  = false;
                dgv_DisplayRecord.Columns["Order"].Visible     = false;
                dgv_DisplayRecord.Columns["Sourcing"].Visible  = false;
                break;

            case "Leave":
                dgv_DisplayRecord.DataSource = ctx.Leave.ToList();
                dgv_DisplayRecord.Columns["Employee"].Visible = false;
                break;

            case "Order":
                dgv_DisplayRecord.DataSource = ctx.Order.ToList();
                dgv_DisplayRecord.Columns["Item"].Visible     = false;
                dgv_DisplayRecord.Columns["Supplier"].Visible = false;
                break;

            case "Prescription":
                dgv_DisplayRecord.DataSource = ctx.Prescription.ToList();
                break;

            case "PrescriptionSet":
                dgv_DisplayRecord.DataSource = ctx.PrescriptionSet.ToList();
                break;

            case "Sourcing":
                dgv_DisplayRecord.DataSource = ctx.Sourcing.ToList();
                dgv_DisplayRecord.Columns["Item"].Visible     = false;
                dgv_DisplayRecord.Columns["Supplier"].Visible = false;
                break;

            case "Supplier":
                dgv_DisplayRecord.DataSource = ctx.Supplier.ToList();
                dgv_DisplayRecord.Columns["Country"].Visible  = false;
                dgv_DisplayRecord.Columns["Item"].Visible     = false;
                dgv_DisplayRecord.Columns["Order"].Visible    = false;
                dgv_DisplayRecord.Columns["Sourcing"].Visible = false;
                break;
            }
        }