Exemplo n.º 1
0
        public void Save(expense dbItem)
        {
            if (dbItem.id == Guid.Empty) //create
            {
                dbItem.id = Guid.NewGuid();

                context.expenses.Add(dbItem);
            }
            else //edit
            {
                var entry = context.Entry(dbItem);
                entry.State = EntityState.Modified;
            }
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public bool updatePatinetBasicInfo(Entities.Patient patient)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Patient patientEntity = ctx.Patients.Find(patient.PatientID);
                if (patientEntity == null)
                {
                    return(false);
                }

                patientEntity.Name      = patient.Name;
                patientEntity.Mobile    = patient.Mobile;
                patientEntity.Notice    = patient.Notice;
                patientEntity.Phone     = patient.Phone;
                patientEntity.Address   = patient.Address;
                patientEntity.BrithDate = patient.BrithDate;
                patientEntity.E_mail    = patient.E_mail;
                patientEntity.gender    = patient.gender;

                ctx.Entry(patientEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 3
0
        public bool alterAppointment(AppointmentViewModelFull appointment)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Appointment appointmentEntity = ctx.Appointments.Find(appointment.id);

                if (appointmentEntity == null)
                {
                    return(false);
                }

                appointmentEntity.ClinicID   = appointment.ClinicID;
                appointmentEntity.DoctorID   = appointment.DoctorID;
                appointmentEntity.PatientID  = appointment.PatientID;
                appointmentEntity.Reason     = appointment.Reason;
                appointmentEntity.Status     = appointment.Status;
                appointmentEntity.Start_date = appointment.start_date;
                appointmentEntity.End_date   = appointment.end_date;
                appointmentEntity.Text       = appointment.text;

                ctx.Entry(appointmentEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 4
0
 public ResponseModel CreateNode(A_GlAccount aObj)
 {
     if (aObj != null)
     {
         A_GlAccount nameEsist = _db.A_GlAccount.FirstOrDefault(x => x.Name == aObj.Name);
         if (nameEsist != null)
         {
             return(_aModel.Respons(false, "Given Name Exists In The Chart Of Account"));
         }
     }
     try
     {
         A_GlAccount aParent = _db.A_GlAccount.FirstOrDefault(x => x.A_GlAccountId == aObj.ParentId);
         if (aParent != null)
         {
             aParent.TransactionAllowed = false;
             _db.A_GlAccount.Attach(aParent);
             _db.Entry(aParent).State = EntityState.Modified;
             aObj.TransactionAllowed  = true;
             aObj.CreatedDate         = DateTime.Now;
             aObj.AccountType         = aParent.AccountType;
             aObj.BalanceType         = aParent.BalanceType;
         }
         aObj.IsActive  = true;
         aObj.IsDeleted = false;
         _db.A_GlAccount.Add(aObj);
         _db.SaveChanges();
         return(_aModel.Respons(true, " Congratulation : A new node created successfully"));
     }
     catch (Exception ex)
     {
         return(_aModel.Respons(false, ex.Message));
     }
 }
Exemplo n.º 5
0
        public bool SaveTreatmentMatrail(IEnumerable <MatrailToSaveViewModel> matrailList, int treatmentID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                foreach (var item in matrailList)
                {
                    MaterialTreatment materialTreatment = ctx.MaterialTreatments.Where(x => x.TeratmentID == treatmentID && x.MaterialID == item.MatrailID).FirstOrDefault();
                    if (materialTreatment == null)
                    {
                        materialTreatment              = ctx.MaterialTreatments.Create();
                        materialTreatment.TeratmentID  = treatmentID;
                        materialTreatment.MaterialID   = item.MatrailID;
                        materialTreatment.MaterialCost = ctx.Materials.Find(item.MatrailID).MaterialCost;
                        materialTreatment.Quantity     = item.Quantity;
                        ctx.MaterialTreatments.Add(materialTreatment);
                    }
                    else
                    {
                        materialTreatment.Quantity         = item.Quantity;
                        ctx.Entry(materialTreatment).State = System.Data.Entity.EntityState.Modified;
                    }

                    count += ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 6
0
        public bool UpdateWarehouse(Warehouse warehouse)
        {
            int result = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                ctx.Entry(warehouse).State = System.Data.Entity.EntityState.Modified;
                result = ctx.SaveChanges();
            }
            return(false);
        }
Exemplo n.º 7
0
        public bool updateTreatment(Treatment treatment)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                ctx.Entry(treatment).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 8
0
 public void Save(owner dbItem)
 {
     if (dbItem.id == Guid.Empty) //create
     {
         dbItem.id = Guid.NewGuid();
         owner checkUnique = context.owners.Where(x => x.id == dbItem.id).FirstOrDefault();
         while (checkUnique != null)
         {
             dbItem.id   = Guid.NewGuid();
             checkUnique = context.owners.Where(x => x.id == dbItem.id).FirstOrDefault();
         }
         context.owners.Add(dbItem);
     }
     else //edit
     {
         var entry = context.Entry(dbItem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Exemplo n.º 9
0
        public bool alterSerssionProbertyValue(SessionValue sessionValue, string probertyValue)
        {
            int check = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                sessionValue.SessionValue1    = probertyValue;
                ctx.Entry(sessionValue).State = System.Data.Entity.EntityState.Modified;
                check = ctx.SaveChanges();
            }
            return(check > 0 ? true : false);
        }
Exemplo n.º 10
0
        public Guid Save(rent dbItem)
        {
            if (dbItem.id == Guid.Empty) //create
            {
                dbItem.id = Guid.NewGuid();

                context.rents.Add(dbItem);
            }
            else //edit
            {
                context.rents.Attach(dbItem);

                var entry = context.Entry(dbItem);
                entry.State = EntityState.Modified;

                //field yang tidak ditentukan oleh user
                //entry.Property(e => e.is_delete).IsModified = false;
            }

            context.SaveChanges();

            return(dbItem.id);
        }
Exemplo n.º 11
0
        public Guid Save(api_rent dbItem)
        {
            //kamus
            api_rent     checkUnique;
            log_api_rent log;

            //algoritma
            if (dbItem.id == Guid.Empty) //create
            {
                dbItem.id   = Guid.NewGuid();
                checkUnique = FindByPk(dbItem.id);

                while (checkUnique != null)
                {
                    dbItem.id   = Guid.NewGuid();
                    checkUnique = FindByPk(dbItem.id);
                }

                context.api_rent.Add(dbItem);
            }
            else //edit
            {
                var entry = context.Entry(dbItem);
                entry.State = EntityState.Modified;
            }

            //save log_api_rent
            log = new log_api_rent
            {
                id           = Guid.NewGuid(),
                id_api_rent  = dbItem.id,
                created_time = DateTimeOffset.Now
            };
            if (dbItem.cancellation_status != null)
            {
                log.status = dbItem.cancellation_status;
            }
            else
            {
                log.status = dbItem.status;
            }

            context.log_api_rent.Add(log);

            context.SaveChanges();

            return(dbItem.id);
        }
Exemplo n.º 12
0
        public bool withdrawMatrailFromWarehouse(int matrailID, int?storgeID, int quantity)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Warehouse warehouse = ctx.Warehouses.Where(x => x.StorageID == storgeID && x.ItemID == matrailID).FirstOrDefault();
                if (warehouse == null)
                {
                    return(false);
                }
                warehouse.Available       -= quantity;
                ctx.Entry(warehouse).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 13
0
        public bool updateCustomMaterial(CustomMaterialViewModel customMaterialViewModel)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                CustomMaterial customMatrailEntity = ctx.CustomMaterials.Find(customMaterialViewModel.CustomMaterialID);

                customMatrailEntity.ReciveDate       = customMaterialViewModel.ReciveDate;
                customMatrailEntity.Name             = customMaterialViewModel.Name;
                customMatrailEntity.Description      = customMaterialViewModel.Description;
                customMatrailEntity.Cost             = customMaterialViewModel.Cost;
                customMatrailEntity.Payed            = customMaterialViewModel.payed == 1 ? true : false;
                ctx.Entry(customMatrailEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 14
0
        public bool updatePatientStatus(AppointmentStatusViewModel appointmentStatusViewModel)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Appointment appointmentEntity = ctx.Appointments.Find(appointmentStatusViewModel.id);

                if (appointmentEntity == null)
                {
                    return(false);
                }

                appointmentEntity.Status = appointmentStatusViewModel.Status;

                ctx.Entry(appointmentEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 15
0
        public bool updatePrescription(PrescriptionViewModel prescription)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Prescription prescriptionEntity = ctx.Prescriptions.Find(prescription.PrescriptionID);
                if (prescriptionEntity == null)
                {
                    return(false);
                }

                prescriptionEntity.Notice = prescription.Notice;
                prescriptionEntity.Dose   = prescription.Dose;

                ctx.Entry(prescriptionEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 16
0
        public bool updatePatinetHistory(PatientHistoryViewModel patientHistory)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                PatientHistory patientHistoryEntity = ctx.PatientHistories.Find(patientHistory.HistoryID);
                if (patientHistoryEntity == null)
                {
                    return(false);
                }

                patientHistoryEntity.Name         = patientHistory.Name;
                patientHistoryEntity.Descripation = patientHistory.Descripation;

                ctx.Entry(patientHistoryEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 17
0
        public long Save(log dbItem)
        {
            if (dbItem.id == 0) //create
            {
                context.logs.Add(dbItem);
            }
            else //edit
            {
                context.logs.Attach(dbItem);

                var entry = context.Entry(dbItem);
                entry.State = EntityState.Modified;

                //field yang tidak ditentukan oleh user
                //entry.Property(e => e.is_delete).IsModified = false;
            }
            context.SaveChanges();

            return(dbItem.id);
        }
Exemplo n.º 18
0
        public bool updatePatinetImage(ImagesViewModel patientImagesViewModel)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Image patientImageEntity = ctx.Images.Find(patientImagesViewModel.ImageID);
                if (patientImageEntity == null)
                {
                    return(false);
                }

                patientImageEntity.Name            = patientImagesViewModel.Name;
                patientImageEntity.Notice          = patientImagesViewModel.Notice;
                patientImageEntity.ImageCategoryID = patientImagesViewModel.ImageCategoryID;

                ctx.Entry(patientImageEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Exemplo n.º 19
0
 public void Save(d_notification dbItem)
 {
     if (dbItem.id == 0) //create
     {
         //penanggulangan data null
         if (context.d_notification.Count() > 0)
         {
             dbItem.id = context.d_notification.Max(n => n.id) + 1;
         }
         else
         {
             dbItem.id = 1;
         }
         context.d_notification.Add(dbItem);
     }
     else //edit
     {
         var entry = context.Entry(dbItem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Exemplo n.º 20
0
 public void Update(T obj)
 {
     _aTable.Attach(obj);
     _db.Entry(obj).State = EntityState.Modified;
 }
Exemplo n.º 21
0
        public ResponseModel ProcessUnprocessedData(List <UnprocessedData> unprocessedData, int costCenterId)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    string debtAccountCode   = null;
                    string creditAccountCode = null;
                    if (costCenterId == 1)
                    {
                        foreach (var data in unprocessedData)
                        {
                            debtAccountCode   = _db.A_CostCenter.SingleOrDefault(x => x.A_CostCenterId == costCenterId && x.Particular == data.Particular).DebitAccount.ToString();
                            creditAccountCode = _db.A_CostCenter.SingleOrDefault(x => x.A_CostCenterId == costCenterId && x.Particular == data.Particular).CreditAccount.ToString();
                            if (String.IsNullOrWhiteSpace(debtAccountCode) || String.IsNullOrWhiteSpace(creditAccountCode))
                            {
                                return(_aModel.Respons(false, "Debit or credit account in Cost Center Not Found"));
                            }
                            else
                            {
                                if (data.A_GLTransactionId > 0)
                                {
                                    Int32 A_GlAccountId = 0;
                                    A_GlAccountId = _db.A_GlAccount.SingleOrDefault(x => x.Code == debtAccountCode).A_GlAccountId;

                                    A_GlTransactionDetails aGlTransactionDetailsDebit = _db.A_GlTransactionDetails.SingleOrDefault(i => i.A_GlTransactionId == data.A_GLTransactionId && i.A_GlAccountId == A_GlAccountId);
                                    aGlTransactionDetailsDebit.DebitAmount = data.Amount;
                                    _db.A_GlTransactionDetails.Attach(aGlTransactionDetailsDebit);
                                    _db.Entry(aGlTransactionDetailsDebit).State = EntityState.Modified;
                                    _db.SaveChanges();

                                    A_GlAccountId = _db.A_GlAccount.SingleOrDefault(x => x.Code == creditAccountCode).A_GlAccountId;

                                    A_GlTransactionDetails aGlTransactionDetailsCredit = _db.A_GlTransactionDetails.SingleOrDefault(i => i.A_GlTransactionId == data.A_GLTransactionId && i.A_GlAccountId == A_GlAccountId);
                                    aGlTransactionDetailsCredit.CreditAmount = data.Amount;
                                    _db.A_GlTransactionDetails.Attach(aGlTransactionDetailsCredit);
                                    _db.Entry(aGlTransactionDetailsCredit).State = EntityState.Modified;
                                    _db.SaveChanges();
                                    SupplierInvestment aInvestment = _db.SupplierInvestments.SingleOrDefault(x => x.SupplierInvestmentId == data.Id);
                                    if (aInvestment != null)
                                    {
                                        aInvestment.ProcessStatus     = 2;
                                        aInvestment.A_GlTransactionId = data.A_GLTransactionId;
                                        _db.SupplierInvestments.Attach(aInvestment);
                                        _db.Entry(aInvestment).State = EntityState.Modified;
                                        _db.SaveChanges();
                                    }
                                }
                                else
                                {
                                    A_GlTransaction aGlTransaction = new A_GlTransaction()
                                    {
                                        TransactionDate = DateTime.Now,
                                        EntryMethod     = 2,
                                        Description     = data.Particular,
                                        A_CostCenterId  = costCenterId
                                    };
                                    _db.A_GlTransaction.Add(aGlTransaction);
                                    _db.SaveChanges();
                                    A_GlTransactionDetails aGlTransactionDetailsforDebt = new A_GlTransactionDetails()
                                    {
                                        A_GlAccountId     = _db.A_GlAccount.SingleOrDefault(x => x.Code == debtAccountCode).A_GlAccountId,
                                        A_GlTransactionId = aGlTransaction.A_GlTransactionId,
                                        DebitAmount       = data.Amount,
                                        CreditAmount      = 0,
                                        TransactionDate   = DateTime.Now,
                                        Particular        = data.Particular
                                    };
                                    _db.A_GlTransactionDetails.Add(aGlTransactionDetailsforDebt);
                                    _db.SaveChanges();
                                    A_GlTransactionDetails aGlTransactionDetailsforCredit = new A_GlTransactionDetails()
                                    {
                                        A_GlAccountId     = _db.A_GlAccount.SingleOrDefault(x => x.Code == creditAccountCode).A_GlAccountId,
                                        A_GlTransactionId = aGlTransaction.A_GlTransactionId,
                                        DebitAmount       = 0,
                                        CreditAmount      = data.Amount,
                                        TransactionDate   = DateTime.Now,
                                        Particular        = data.Particular
                                    };
                                    _db.A_GlTransactionDetails.Add(aGlTransactionDetailsforCredit);
                                    _db.SaveChanges();
                                    SupplierInvestment aInvestment = _db.SupplierInvestments.SingleOrDefault(x => x.SupplierInvestmentId == data.Id);
                                    if (aInvestment != null)
                                    {
                                        aInvestment.ProcessStatus     = 2;
                                        aInvestment.A_GlTransactionId = aGlTransaction.A_GlTransactionId;

                                        _db.SupplierInvestments.Attach(aInvestment);
                                        _db.Entry(aInvestment).State = EntityState.Modified;
                                        _db.SaveChanges();
                                    }
                                }
                            }
                        }
                    }

                    transaction.Commit();
                    return(_aModel.Respons(true, "Data processing done successfully"));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(false, "Sorry ! Some error occured"));
                }
            }
        }