Example #1
0
        /***************************************** Item Master *****************************************/

        public ActionResult Item()
        {
            ItemMaster obj = new Models.ItemMaster();

            obj.getMultipleUnit();
            return(View(obj));
        }
Example #2
0
        public ViewResult ItemUpdate(int itemid)
        {
            ItemMaster obj = new Models.ItemMaster();

            if (itemid > 0)
            {
                obj.CMD = "Update";
                obj     = obj.GetSingleItem(itemid);
                obj.getMultipleUnit();
            }
            return(View("Item", obj));
        }
Example #3
0
        public ActionResult ViewItem()
        {
            ItemMaster   obj = new Models.ItemMaster();
            DBConnection cn  = new DBConnection();

            obj.CMD = "View";
            obj.hid = Convert.ToInt32(Session["hospital"].ToString());
            string  xml     = Common.ToXML(obj);
            DataSet dataset = cn.ExecuteProcedure("SP_Item", xml);

            return(View(dataset));
        }
Example #4
0
        public ActionResult ApproveSpecificInvoice(int id)
        {
            var loggedInUser = db2.Users.Find(Session["UserId"]);
            var UserName     = loggedInUser.Username;


            var invoice = db.Invoice.Where(p => p.Id == id).FirstOrDefault();

            invoice.ApprovedBy    = UserName;
            invoice.FinalApproval = true;

            db.Entry(invoice).State = EntityState.Modified;
            db.SaveChanges();

            List <Models.Invoice> invoices = new List <Models.Invoice>();

            var todaysDate = DateTime.Now.Date;

            Models.ItemMaster itemMaster;

            List <Models.ItemMaster> lstItemsToBeAdded = new List <Models.ItemMaster>();
            var approvedItems = db.InvoiceDetail.Where(p => p.InvoiceNo == id).ToList();

            //Add items in invoice to item master table
            foreach (var item in approvedItems)
            {
                var drug = db.Drug.Where(p => p.Id == item.DrugId).FirstOrDefault();

                itemMaster = new Models.ItemMaster();

                itemMaster.ItemName        = drug.Name;
                itemMaster.BatchNo         = item.BatchNo;
                itemMaster.GenericDrugName = drug.genericDrugName?.Name ?? "";
                itemMaster.MfgCoName       = item.MfgCoNm;
                itemMaster.Supplier        = invoice.SupplierName;
                itemMaster.CurrentStock    = item.Units;
                itemMaster.MfgDate         = item.MfgDate.ToString();
                itemMaster.ReorderLevel    = drug.ReorderLevel;
                itemMaster.UnitsPack       = drug.UnitsPack;
                itemMaster.CostPriceUnit   = item.CostPrice;
                itemMaster.ExpiryStatus    = item.ExpiryStatus;
                itemMaster.PurchaseDate    = item.ReceviedDate.ToString();
                itemMaster.barCode         = "";
                itemMaster.CasePackRate    = item.CasePackRate;
                itemMaster.StoreName       = item.StoreFlag;

                lstItemsToBeAdded.Add(itemMaster);
            }

            db.ItemMaster.AddRange(lstItemsToBeAdded);
            db.SaveChanges();

            if (Session["StartDate"] != null && Session["ToDate"] != null)
            {
                DateTime fromDate = (DateTime)Session["StartDate"];
                DateTime toDate   = (DateTime)Session["ToDate"];

                invoices = db.Invoice.Where(x => x.InvoiceDate >= fromDate && x.InvoiceDate <= toDate)
                           .OrderByDescending(p => p.Id)
                           .ToList();
                ViewBag.SearchDates = true;
            }
            else if (Session["SupplierName"] != null)
            {
                var supplierName = Session["SupplierName"].ToString();

                invoices = db.Invoice.Where(x => x.SupplierName.Contains(supplierName))
                           .OrderByDescending(p => p.Id)
                           .ToList();
            }
            else
            {
                invoices = db.Invoice.Where(x => x.InvoiceDate == todaysDate)
                           .OrderByDescending(p => p.Id)
                           .ToList();
            }

            int?page      = 1;
            int pageSize  = 10;
            int pageIndex = 1;

            pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;


            return(PartialView("~/Areas/Procurement/Views/ProcurementPurchase/_ApproveInvoice.cshtml", invoices.ToPagedList(pageIndex, pageSize)));
        }