Пример #1
0
        public void Delete(object id)
        {
            T find = _aTable.Find(id);

            _aTable.Remove(find);
            _db.SaveChanges();
        }
Пример #2
0
        public ResponseModel SaveJournalTransaction(List <ManualJournal> a_objList)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    var vouchers = a_objList.Select(x => x.VoucharNumber).ToList().Distinct();
                    foreach (Int32 v in vouchers)
                    {
                        var d = (from e in a_objList
                                 where e.VoucharNumber == v
                                 select
                                 new
                        {
                            e.TransactionDate,
                            e.Particulars
                        }).FirstOrDefault();
                        A_GlTransaction aGlTransaction = new A_GlTransaction()
                        {
                            TransactionDate = d.TransactionDate,
                            EntryMethod     = 1,
                            VoucharNumber   = v,
                            Description     = d.Particulars
                        };
                        _db.A_GlTransaction.Add(aGlTransaction);
                        _db.SaveChanges();
                        List <ManualJournal> manualJournals = (from o in a_objList
                                                               where o.VoucharNumber == v
                                                               select o).ToList();

                        foreach (var o in manualJournals)
                        {
                            A_GlTransactionDetails aGlTransactionDetails = new A_GlTransactionDetails()
                            {
                                A_GlAccountId     = o.A_GlAccountId,
                                A_GlTransactionId = aGlTransaction.A_GlTransactionId,
                                DebitAmount       = o.DebitAmount,
                                CreditAmount      = o.CreditAmount,
                                TransactionDate   = o.TransactionDate,
                                ChequeNumber      = o.ChequeNumber
                            };
                            _db.A_GlTransactionDetails.Add(aGlTransactionDetails);
                            _db.SaveChanges();
                        }
                    }
                    transaction.Commit();
                    return(_aModel.Respons(true, "Journal Saved"));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(false, "Journal not saved"));
                }
            }
        }
Пример #3
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();
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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));
     }
 }
Пример #8
0
        public bool addTreatmentList(IEnumerable <TreatmentPresntViewModel> treatmentList, int AppointmentID, int DoctorID, int PatientID, int clinecID)
        {
            // enhance
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                foreach (var item in treatmentList)
                {
                    Treatment treatment = ctx.Treatments.Create();
                    treatment.PatientID       = PatientID;
                    treatment.DoctorID        = DoctorID;
                    treatment.ClinicID        = clinecID;
                    treatment.AppointmentID   = AppointmentID;
                    treatment.OpperationID    = item.OpperationID;
                    treatment.TeratmentCost   = item.TeratmentCost;
                    treatment.ToothNumber     = item.toothNumber;
                    treatment.ToothSideNumber = item.toothSideNumber;
                    treatment.Description     = item.Description;
                    treatment.OpperationCost  = ctx.opperations.Find(item.OpperationID).Price;
                    ctx.Treatments.Add(treatment);
                    count += ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
Пример #9
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);
        }
Пример #10
0
        public void SaveLogWS(log_ws dbItem)
        {
            if (dbItem.id == Guid.Empty)
            {
                dbItem.id = Guid.NewGuid();
                context.log_ws.Add(dbItem);
            }

            context.SaveChanges();
        }
 public void Save()
 {
     try
     {
         _db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #12
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);
        }
Пример #13
0
        public bool AddNewWarehouse(Warehouse warehouse)
        {
            int result = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                ctx.Warehouses.Add(warehouse);
                result = ctx.SaveChanges();
            }
            return(result > 0 ? true : false);
        }
Пример #14
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);
        }
Пример #15
0
        public bool addTreatment(Treatment treatment)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                ctx.Treatments.Add(treatment);
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Пример #16
0
 public void Save(car_model dbItem)
 {
     if (dbItem.id == Guid.Empty) //create
     {
         dbItem.id = Guid.NewGuid();
         car_model checkUnique = context.car_model.Where(x => x.id == dbItem.id).FirstOrDefault();
         while (checkUnique != null)
         {
             dbItem.id   = Guid.NewGuid();
             checkUnique = context.car_model.Where(x => x.id == dbItem.id).FirstOrDefault();
         }
         context.car_model.Add(dbItem);
     }
     else //edit
     {
         var entry = context.Entry(dbItem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Пример #17
0
        public bool updateSecertaryUserID(Entities.Secretary secretary)
        {
            int count;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                var sec = ctx.Secretaries.FirstOrDefault(d => d.SecretaryID == secretary.SecretaryID);
                sec.UserID = secretary.UserID;
                count      = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Пример #18
0
        public bool updateDoctorUserID(Entities.Doctor doctor)
        {
            int count;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                var doc = ctx.Doctors.FirstOrDefault(d => d.DoctorID == doctor.DoctorID);
                doc.UserID = doctor.UserID;
                count      = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Пример #19
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);
        }
Пример #20
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();
 }
Пример #21
0
 public ResponseModel CreateFiscalYear(A_FiscalYear obj)
 {
     try
     {
         _db.A_FiscalYear.Attach(obj);
         _db.A_FiscalYear.Add(obj);
         _db.SaveChanges();
         return(_aModel.Respons("Data saved successfuly."));
     }
     catch (Exception ex)
     {
         return(_aModel.Respons(ex.Message));
     }
 }
Пример #22
0
        public bool AddSessionProbertyValue(int sessionID, string probertyName, string probertyValue)
        {
            int check = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                SessionValue sv = new SessionValue {
                    SessionID = sessionID, PrortyName = probertyName, SessionValue1 = probertyValue
                };
                ctx.SessionValues.Add(sv);
                check = ctx.SaveChanges();
            }
            return(check > 0 ? true : false);
        }
Пример #23
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);
        }
Пример #24
0
        public bool deleteAppointment(int appointmentID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Appointment appointment = ctx.Appointments.Find(appointmentID);
                if (appointment != null)
                {
                    ctx.Appointments.Remove(appointment);
                    count = ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
Пример #25
0
        public int addSessionAndGetID(string SessionName, string userID)
        {
            int sessionID;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                SessionsStat sessionState = new SessionsStat {
                    SessionName = SessionName, UserID = userID
                };
                ctx.SessionsStats.Add(sessionState);
                ctx.SaveChanges();
                sessionID = sessionState.SessionID;
            }
            return(sessionID);
        }
Пример #26
0
        public bool deletepatientBasicInfo(int patientID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Patient patient = ctx.Patients.Find(patientID);
                if (patient != null)
                {
                    ctx.Patients.Remove(patient);
                    count = ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
Пример #27
0
        public bool deletePatientImages(int patinetImagestID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Image image = ctx.Images.Find(patinetImagestID);
                if (image != null)
                {
                    ctx.Images.Remove(image);
                    count = ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
Пример #28
0
        public bool deletePatientHistory(int patientHistorytID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                PatientHistory patientHistory = ctx.PatientHistories.Find(patientHistorytID);
                if (patientHistory != null)
                {
                    ctx.PatientHistories.Remove(patientHistory);
                    count = ctx.SaveChanges();
                }
            }
            return(count > 0 ? true : false);
        }
        public bool deletePatientReceipt(int ReceiptID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                PaymentReceipt recipt = ctx.PaymentReceipts.Find(ReceiptID);
                if (recipt == null)
                {
                    return(false);
                }
                ctx.PaymentReceipts.Remove(recipt);
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
Пример #30
0
        public bool addNewPatinetHistory(PatientHistoryViewModel patientHistory)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                PatientHistory patientHistoryEntity = ctx.PatientHistories.Create();
                patientHistoryEntity.PatientID    = patientHistory.PatientID;
                patientHistoryEntity.Name         = patientHistory.Name;
                patientHistoryEntity.Descripation = patientHistory.Descripation;

                ctx.PatientHistories.Add(patientHistoryEntity);
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }