Example #1
0
        public bool Create(OPDHistoryUpdateModel model)
        {
            try
            {
                bool isSaved = false;
                using (var db = new HMSEntities())
                {
                    OPDHistoryUpdate entity = new OPDHistoryUpdate();

                    entity.OPDHistoryId  = model.OPDHistoryId;
                    entity.UpdatedBy     = UserDetailSession.Id;
                    entity.UpdatedField  = model.UpdatedField;
                    entity.UpdatedValue  = model.UpdatedValue;
                    entity.PreviousValue = model.PreviousValue;
                    entity.CreatedOn     = DateTime.Now;


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

                    isSaved = true;
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public static List <OPDHistoryUpdateModel> GetPayingPatient(Guid?opdHistoryId)
        {
            try
            {
                List <OPDHistoryUpdateModel> list = new List <OPDHistoryUpdateModel>();

                using (var db = new HMSEntities())
                {
                    var data = db.OPDHistoryUpdates
                               .Where(t => t.OPDHistoryId == opdHistoryId && t.UpdatedField == "PayingAmount")
                               .OrderBy(c => c.CreatedOn).ToList();
                    foreach (OPDHistoryUpdate t in data)
                    {
                        OPDHistoryUpdateModel model = new OPDHistoryUpdateModel();
                        model.Id            = t.Id;
                        model.OPDHistoryId  = t.OPDHistoryId;
                        model.UpdatedBy     = t.UpdatedBy;
                        model.UpdatedName   = t.UpdatedBy.HasValue ? UserDetail.GetNameById(t.UpdatedBy.Value) : string.Empty;
                        model.UpdatedField  = t.UpdatedField;
                        model.UpdatedValue  = t.UpdatedValue;
                        model.PreviousValue = t.PreviousValue;
                        model.CreatedOn     = t.CreatedOn;
                        list.Add(model);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        private List <OPDHistoryUpdateModel> OPDHistoryModifications(object entityEntry, object modelEntry)
        {
            string[] arrayColumns = new string[] { "ECGAmount", "XRAYAmount", "ThirdPartyLabAmoumt", "Amount", "PaidAmount", "IsCharity", "StatusId", "IsECG", "IsXRAY", "IsLabCharity", "LabTestingAmount" };

            //Getting Type of Generic Class Model
            var entityType = entityEntry.GetType();
            var modelType  = modelEntry.GetType();

            PropertyInfo[] entityProperty     = entityType.GetProperties();
            PropertyInfo[] modelProperties    = modelType.GetProperties();
            List <OPDHistoryUpdateModel> list = new List <OPDHistoryUpdateModel>();

            foreach (PropertyInfo property in entityProperty)
            {
                if (modelType.GetProperty(property.Name) != null)
                {
                    if (arrayColumns.Contains(property.Name))
                    {
                        var newValue = modelType.GetProperty(property.Name).GetValue(modelEntry, null);
                        var oldValue = entityType.GetProperty(property.Name).GetValue(entityEntry, null);
                        if (newValue.ToString() != oldValue.ToString())
                        {
                            if (property.Name == "PaidAmount")
                            {
                                OPDHistoryUpdateModel objPaying = new OPDHistoryUpdateModel();

                                decimal?payingAmount = Convert.ToDecimal(modelType.GetProperty("PayingAmount").GetValue(modelEntry, null).ToString());
                                objPaying.OPDHistoryId = new Guid(modelType.GetProperty("Id").GetValue(modelEntry, null).ToString());
                                // objPaying.PreviousValue = Convert.ToString("");
                                objPaying.UpdatedBy    = UserDetailSession.Id;
                                objPaying.UpdatedValue = Convert.ToString(payingAmount);
                                objPaying.UpdatedField = "PayingAmount";
                                objPaying.CreatedOn    = DateTime.Now.Date;
                                list.Add(objPaying);
                            }
                            else
                            {
                                OPDHistoryUpdateModel obj = new OPDHistoryUpdateModel();
                                obj.OPDHistoryId  = new Guid(modelType.GetProperty("Id").GetValue(modelEntry, null).ToString());
                                obj.PreviousValue = Convert.ToString(oldValue);
                                obj.UpdatedBy     = UserDetailSession.Id;
                                obj.UpdatedValue  = Convert.ToString(newValue);
                                obj.UpdatedField  = Convert.ToString(property.Name);
                                obj.CreatedOn     = DateTime.Now.Date;
                                list.Add(obj);
                            }
                        }
                    }
                }
            }

            return(list);
        }
Example #4
0
        private List <OPDHistoryUpdateModel> OPDHistoryModifications(object modelEntry)
        {
            string[] arrayColumns = new string[] { "XRAYAmount", "PaidAmount", "IsCharity", "IsECG", "IsXRAY" };

            //Getting Type of Generic Class Model

            var modelType = modelEntry.GetType();


            PropertyInfo[] modelProperties    = modelType.GetProperties();
            List <OPDHistoryUpdateModel> list = new List <OPDHistoryUpdateModel>();

            foreach (PropertyInfo property in modelProperties)
            {
                if (arrayColumns.Contains(property.Name))
                {
                    if (property.Name == "PaidAmount")
                    {
                        OPDHistoryUpdateModel objPaying = new OPDHistoryUpdateModel();

                        decimal?payingAmount = Convert.ToDecimal(modelType.GetProperty("PayingAmount").GetValue(modelEntry, null).ToString());
                        objPaying.OPDHistoryId = new Guid(modelType.GetProperty("Id").GetValue(modelEntry, null).ToString());
                        // objPaying.PreviousValue = Convert.ToString("");
                        objPaying.UpdatedBy    = UserDetailSession.Id;
                        objPaying.UpdatedValue = Convert.ToString(payingAmount);
                        objPaying.UpdatedField = "PayingAmount";
                        objPaying.CreatedOn    = DateTime.Now.Date;
                        list.Add(objPaying);
                    }
                    else
                    {
                        OPDHistoryUpdateModel obj = new OPDHistoryUpdateModel();
                        obj.OPDHistoryId  = new Guid(modelType.GetProperty("Id").GetValue(modelEntry, null).ToString());
                        obj.PreviousValue = null;
                        obj.UpdatedBy     = UserDetailSession.Id;
                        obj.UpdatedValue  = Convert.ToString(modelType.GetProperty(property.Name).GetValue(modelEntry, null));
                        obj.UpdatedField  = Convert.ToString(property.Name);
                        obj.CreatedOn     = DateTime.Now.Date;
                        list.Add(obj);
                    }

                    //}
                }
                //}
            }

            return(list);
        }