Ejemplo n.º 1
0
        public bool Update(Guid?id)
        {
            try
            {
                bool isSaved = false;


                using (var db = new HMSEntities())
                {
                    BillHistory entity = db.BillHistories.FirstOrDefault(t => t.OPDHistoryId == id);

                    entity.PrintCopys    = entity.PrintCopys + 1;
                    entity.LastPrintedOn = DateTime.Now;
                    entity.LastPrintedBy = UserDetailSession.Id;

                    db.SaveChanges();

                    isSaved = true;
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public BillHistoryModel GetByOPDId(Guid id)
        {
            try
            {
                BillHistoryModel model = new BillHistoryModel();
                using (var db = new HMSEntities())
                {
                    BillHistory entity = db.BillHistories.Find(id);
                    if (entity != null)
                    {
                        model.Id            = entity.Id;
                        model.PatientId     = entity.PatientId;
                        model.OPDHistoryId  = entity.OPDHistoryId;
                        model.ReceiptNumber = entity.ReceiptNumber;
                        model.PrintCopys    = entity.PrintCopys;
                        model.CreatedOn     = entity.CreatedOn;
                        model.CreatedBy     = entity.CreatedBy;
                        model.LastPrintedOn = entity.LastPrintedOn;
                        model.LastPrintedBy = entity.LastPrintedBy;
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public bool Create(BillHistoryModel model)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model))
                {
                    using (var db = new HMSEntities())
                    {
                        BillHistory entity = new BillHistory();

                        entity.PatientId    = model.PatientId;
                        entity.OPDHistoryId = model.OPDHistoryId;
                        entity.PrintCopys   = 1;
                        int?recpNumber = db.BillHistories.Select(t => t.ReceiptNumber).DefaultIfEmpty(0).Max();
                        entity.ReceiptNumber = recpNumber == null ? 1 : recpNumber.Value + 1;
                        entity.CreatedOn     = DateTime.Now;
                        entity.CreatedBy     = UserDetailSession.Id;

                        db.BillHistories.Add(entity);
                        db.SaveChanges();

                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }