Example #1
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mfacility_code, mproduct_category, mstart_date, mend_date) == null)
         {
             var x = new LMIS_ExpectedReport
             {
                 facility_code    = mfacility_code,
                 start_date       = mstart_date,
                 end_date         = mend_date,
                 product_category = mproduct_category
             };
             context.LMIS_ExpectedReport.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mConditionCode) == null)
         {
             var x = new Treatment_Fluconazole
             {
                 OrderNumber = mOrderNumber,
                 //FacilityCode = mFacilityCode,
                 //StartDate = mStartDate,
                 //EndDate = mEndDate,
                 ConditionCode = mConditionCode,
                 Adults        = mAdults,
                 Children      = mChildren
             };
             context.Treatment_Fluconazole.Add(x);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mProductCode) == null)
         {
             var x = new Order_Lab_Custom
             {
                 OrderNumber        = mOrderNumber.Trim(),
                 ProductCode        = mProductCode,
                 Notes              = mNotes,
                 Quantity_Required  = Quantity_Required,
                 Quantity_Allocated = mQuantity_Allocated,
                 RFSONotes          = mRFSONotes
             };
             context.Order_Lab_Custom.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mID) == null)
         {
             var x = new Order_SMC_SLM_Summary
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 ID           = mID,
                 Quantity     = mQuantity
             };
             context.Order_SMC_SLM_Summary.Add(x);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new Order_MAULT_Header
             {
                 OrderNumber              = mOrderNumber,
                 FacilityCode             = mFacilityCode,
                 DatePrepared             = mDatePrepared,
                 EditedBy                 = new UserManagement().getCurrentuser(),
                 EditedDate               = DateTime.Now,
                 FinalSubmission          = mFinalSubmission,
                 DateExpected             = mDateExpected,
                 ProductCategoryId        = mProductCategoryId,
                 OrderStatusId            = mOrderStatusId,
                 OrderStatusIdChangedBy   = mOrderStatusIdChangedBy,
                 OrderStatusIdDateChanged = mOrderStatusIdDateChanged,
                 RFSO_SentBackTofacility  = mRFSO_SentBackTofacility
             };
             context.Order_MAULT_Header.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mitem_code) == null)
         {
             var x = new order_hiv_rapid_test_kit_summary
             {
                 OrderNumber = mOrderNumber,
                 //Facility_Code = mFacilityCode,
                 //Start_Date = mStartDate,
                 //End_Date = mEndDate,
                 item_code          = mitem_code,
                 HCT                = mHCT,
                 PMTCT              = mPMTCT,
                 Clinical_Diagnosis = mClinical_Diagnosis,
                 SMC                = mSMC,
                 Quality_Control    = mQuality_Control,
                 Total              = mTotal,
             };
             context.order_hiv_rapid_test_kit_summary.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         var x = new order_hiv_rapid_test_kit
         {
             OrderNumber = mOrderNumber,
             //Facility_Code = mFacilityCode,
             //Start_Date = mStartDate,
             //End_Date = mEndDate,
             item_code             = mitem_code,
             No_Test_Start_2Months = mNo_Test_Start_2Months,
             Test_Recieved_2Months = mTest_Recieved_2Months,
             Test_Used_2Months     = mTest_Used_2Months,
             Test_Remaining        = mTest_Remaining,
             Loss_Adjustment       = mLoss_Adjustment,
             Maximum_Stock         = mMaximum_Stock,
             Qunatity_On_Order     = mQunatity_On_Order,
             Quantity_Required     = mQuantity_Required,
             Quantity_To_Ship      = mQuantity_To_Ship,
             Quantity_Allocated    = mQuantity_Allocated,
             RFSONotes             = mRFSONotes,
             Notes = mNotes,
             DaysOutOfStockDuring2Months = mDaysOutOfStockDuring2Months,
             AdjustedAMC = mAdjustedAMC
         };
         context.order_hiv_rapid_test_kit.Add(x);
         context.SaveChanges();
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["FacilityList"] != null && Request["FacilityList"] != string.Empty)
                {
                    string facility = Request["FacilityList"].ToString();
                    model.FacilityId = System.Convert.ToInt32(facility);
                }
                if (Request["UserTypeList"] != null && Request["UserTypeList"] != string.Empty)
                {
                    string user_type = Request["UserTypeList"].ToString();
                    model.UserTypeId = System.Convert.ToInt32(user_type);
                }
                var hased = MD5Hash(model.Password);
                var user  = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber, Name = model.Name, UserTypeId = System.Convert.ToInt32(model.UserTypeId), FacilityId = model.FacilityId, MD5Hash = hased, LockoutEnabled = false
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    if (Request["RolesList"] != null && Request["RolesList"] != string.Empty)
                    {
                        string user_role = Request["RolesList"].ToString();
                        model.UserRole = user_role;
                    }
                    await this.UserManager.AddToRoleAsync(user.Id, model.UserRole);

                    var contact = db.fo_contact_person.FirstOrDefault(o => o.cp_name.Trim() == model.Name.Trim());
                    if (contact != null)
                    {
                        contact.User_ID         = user.Id;
                        db.Entry(contact).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Register", "Account"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #9
0
        public ActionResult BatchUpdate(string key, List <LMIS_ExpectedReport> changed, List <LMIS_ExpectedReport> added, List <LMIS_ExpectedReport> deleted)
        {
            mascisEntities  dbCase = new mascisEntities();
            ExpectedReports obj    = new ExpectedReports();

            //Performing insert operation
            if (added != null && added.Count() > 0)
            {
                foreach (var temp in added)
                {
                    //dbCase.A_Facilities.Add(temp);
                    obj.facility_code    = temp.facility_code;
                    obj.start_date       = temp.start_date;
                    obj.end_date         = temp.end_date;
                    obj.product_category = temp.product_category;
                    context.SaveChanges();
                }
            }
            obj.Update();

            if (changed != null && changed.Count() > 0)
            {
                foreach (var temp in changed)
                {
                    obj.facility_code    = temp.facility_code;
                    obj.start_date       = temp.start_date;
                    obj.end_date         = temp.end_date;
                    obj.product_category = temp.product_category;
                    var check = context.LMIS_ExpectedReport.FirstOrDefault(e => e.facility_code == temp.facility_code && e.start_date == temp.start_date && e.end_date == temp.end_date && e.product_category == temp.product_category);
                    context.Entry(check).CurrentValues.SetValues(check);
                    context.Entry(check).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            //dbCase.SaveChanges();
            obj.Update();
            //Performing delete operation
            if (deleted != null && deleted.Count() > 0)
            {
                foreach (var temp in deleted)
                {
                    dbCase.LMIS_ExpectedReport.Remove(dbCase.LMIS_ExpectedReport.FirstOrDefault(e => e.facility_code == temp.facility_code && e.start_date == temp.start_date && e.end_date == temp.end_date && e.product_category == temp.product_category));
                }
            }

            //dbCase.SaveChanges();
            obj.Update();
            return(RedirectToAction("DataSourceRFSO"));
        }
Example #10
0
 private Boolean Save()
 {
     try
     {
         var x = new order_hiv_rapid_test_kit_PhysicalCount
         {
             FacilityCode        = mFacilityCode,
             DateOfPhysicalCount = mDateOfPhysicalCount,
             // string Expiry_Date = temp.ExpiryDate.ToString();
             //DateTime ExpiryTime = DateTime.Parse(Expiry_Date);
             //obj.ExpiryDate = ExpiryTime;
             product_code        = mproduct_code,
             BatchNo             = mBatchNo,
             Quantity_Dispensary = mQuantity_Dispensary,
             Quantity_Store      = mQuantity_Store,
             ExpiryDate          = mExpiryDate,
             Total         = (mQuantity_Dispensary + mQuantity_Store),
             Comment       = mComment,
             AddedBy       = new UserManagement().getCurrentuser(),
             DateAdded     = DateTime.Now,
             record_status = true
         };
         context.order_hiv_rapid_test_kit_PhysicalCount.Add(x);
         context.SaveChanges();
         return(true);
     }
     //catch (Exception x)
     //{
     //    throw (x);
     //}
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }
        public ActionResult DialogInsertHSIP(Order_TB_Header value)
        {
            EmailJob email = new EmailJob();

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities db_hv = new mascisEntities();
            // OrderOISTIHeaderModels obj = new OrderOISTIHeaderModels();
            string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "13", "02");

            db_hv.Order_TB_Header.Add(value);
            value.OrderNumber       = OrderNumber;
            TempData["OrderNumber"] = OrderNumber;
            //value.OrderNumber = OrderNumber;
            //TempData["OrderNumber"] = OrderNumber;
            TempData["FacilityCode"] = value.FacilityCode;
            TempData["StartDate"]    = value.StartDate;
            TempData["EndDate"]      = value.EndDate;
            value.OrderTypeId        = 2;
            value.OrderStatusId      = 1;
            value.EditedDate         = DateTime.Now;
            value.EditedBy           = new UserManagement().getCurrentuser();
            db_hv.SaveChanges();
            // //obj.SaveLog(value);
            if (value.FinalSubmission == true)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "TB");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DialogUpdateHSIP(Order_TB_Header value)
        {
            EmailJob email = new EmailJob();

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities  db_master = new mascisEntities();
            Order_TB_Header table     = db_master.Order_TB_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber);

            TempData["OrderNumber"]  = value.OrderNumber;
            TempData["FacilityCode"] = value.FacilityCode;
            TempData["StartDate"]    = value.StartDate;
            TempData["EndDate"]      = value.EndDate;
            value.OrderTypeId        = 2;
            value.OrderStatusId      = 1;
            value.EditedDate         = DateTime.Now;
            value.EditedBy           = new UserManagement().getCurrentuser();
            db_master.Entry(table).CurrentValues.SetValues(value);
            db_master.Entry(table).State = EntityState.Modified;
            db_master.SaveChanges();
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "TB");
            }
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == true)
            {
                email.OrderReSentToScto(value.FacilityCode, value.OrderNumber, "TB");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        //public ActionResult DialogInsertHSIP(Order_ViralLoadReagents_Header value)
        //{
        //    string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "11", "02");
        //    OrderViralLoadReagentsHeaderModels obj = new OrderViralLoadReagentsHeaderModels();
        //    obj.OrderNumber = OrderNumber;
        //    TempData["OrderNumber"] = OrderNumber;
        //    obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.FacilityCode = value.FacilityCode;
        //    obj.StartDate = value.StartDate;
        //    obj.EndDate = value.EndDate;
        //    obj.OrderTypeId = 2;
        //    obj.OrderStatusId = 1;
        //    obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission);
        //    obj.EditedBy = new UserManagement().getCurrentuser();
        //    obj.EditedDate = DateTime.Now;
        //    obj.Save();
        //    return Json(value, JsonRequestBehavior.AllowGet);
        //}
        public ActionResult DialogInsertHSIPCustom(Order_ViralLoadReagents_Header value)
        {
            // EmailJob obx = new EmailJob();
            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities db_hv = new mascisEntities();
            OrderViralLoadReagentsHeaderModels obj = new OrderViralLoadReagentsHeaderModels();
            string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "11", "02");

            db_hv.Order_ViralLoadReagents_Header.Add(value);
            value.OrderNumber       = OrderNumber;
            TempData["OrderNumber"] = OrderNumber;
            value.OrderTypeId       = 1;
            value.OrderStatusId     = 1;
            value.StartDate         = DateTime.Now;
            value.EndDate           = DateTime.Now;
            value.EditedDate        = DateTime.Now;
            value.EditedBy          = new UserManagement().getCurrentuser();
            db_hv.SaveChanges();
            //obj.SaveLog(value);
            //EmailJob obx = new EmailJob();
            //if (value.FinalSubmission == true)
            //{
            //    obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //}
            //obx.SendEmail(value.FacilityCode, value.OrderNumber);
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Example #14
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mFacilityCode) == null)
         {
             var x = new A_Facilities
             {
                 FacilityCode            = mFacilityCode,
                 DeliveryZoneCode        = mDeliveryZoneCode,
                 ImplimentingPartnerCode = mImplimentingPartnerCode,
                 DistrrictCode           = mDistrrictCode,
                 Facility         = mFacility,
                 SAP_Code         = mSAP_Code,
                 SupportedByMAUL  = mSupportedByMAUL,
                 IsAccredited     = mIsAccredited,
                 level_of_care    = mlevel_of_care,
                 client_type_code = mclient_type_code,
                 region_code      = mregion_code,
                 RFSO_UserName    = mRFSO_UserName,
                 OwnershipId      = mOwnershipId,
                 CDCRegionId      = mCDCRegionId,
                 FacilityTypeId   = mFacilityTypeId,
                 Longtitude       = mLongtitude,
                 Latititude       = mLatititude,
                 Village_Id       = mVillage_Id,
                 ComprehensiveImplimentingPartnerCode = mComprehensiveImplimentingPartnerCode,
                 PatientLoadCode            = mPatientLoadCode,
                 IsActive                   = mIsActive,
                 Nearest_Public_HF_Distance = mNearest_Public_HF_Distance,
                 DSDM = mDSDM
             };
             context.A_Facilities.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Example #15
0
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mDrugCode) == null)
         {
             var x = new Order_DrugDetails
             {
                 OrderNumber = mOrderNumber.Trim(),
                 //FacilityCode = mFacilityCode,
                 //StartDate = mStartDate,
                 //EndDate = mEndDate,
                 DrugCode            = mDrugCode,
                 OpeningBalance      = mOpeningBalance,
                 QuantityRecieved    = mQuantityRecieved,
                 PMTCT_Consumption   = mPMTCT_Consumption,
                 ART_Consumption     = mART_Consumption,
                 Losses_Adjustments  = mLosses_Adjustments,
                 ClosingBalance      = mClosingBalance,
                 Months_Stock_atHand = mMonths_Stock_atHand,
                 Quantity_Required_Current_Patients = mQuantity_Required_Current_Patients,
                 EstimatedNew_ART_Patients          = mEstimatedNew_ART_Patients,
                 EstimatedNew_HIV_Pregnant          = mEstimatedNew_HIV_Pregnant,
                 DrugsRequired_NewPatients          = mDrugsRequired_NewPatients,
                 TotalDrugs_Required = mTotalDrugs_Required,
                 Notes = mNotes,
                 Quantity_Allocated          = mQuantity_Allocated,
                 RFSONotes                   = mRFSONotes,
                 ART_eMTCT_Consumption       = mART_eMTCT_Consumption,
                 DaysOutOfStockDuring2Months = mDaysOutOfStockDuring2Months,
                 AdjustedAMC                 = mAdjustedAMC
             };
             context.Order_DrugDetails.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mProductCode) == null)
         {
             var x = new Order_OI_STI_Detail
             {
                 OrderNumber = mOrderNumber,
                 ProductCode = mProductCode,
                 PhysicalCountAtBeginningOfReviewPeriod  = mPhysicalCountAtBeginningOfReviewPeriod,
                 QuantityReceivedDuringTheTwoMonthsCycle = mQuantityReceivedDuringTheTwoMonthsCycle,
                 QuantityUsedDuringTwoMonths             = mQuantityUsedDuringTwoMonths,
                 LossesAndAdjustments   = mLossesAndAdjustments,
                 NumberOfDaysOutOfStock = mNumberOfDaysOutOfStock,
                 ThisMonthPhysicalCount = mThisMonthPhysicalCount,
                 AMC                  = mAMC,
                 MonthsOfStock        = mMonthsOfStock,
                 MaximumStockQuantity = mMaximumStockQuantity,
                 QuantityRequired     = mQuantityRequired,
                 Notes                = mNotes,
                 Quantity_Allocated   = mQuantity_Allocated,
                 RFSONotes            = mRFSONotes
             };
             context.Order_OI_STI_Detail.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Example #17
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new Order_ViralLoadReagents_Header
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 DatePrepared = mDatePrepared,
                 //AddedBy = mAddedBy,
                 //AddedDate = mAddedDate,
                 EditedBy   = new UserManagement().getCurrentuser(),
                 EditedDate = DateTime.Now,
                 //RecordStatus = mRecordStatus,
                 // EmergencyOrder = mEmergencyOrder,
                 FinalSubmission = mFinalSubmission,
                 //ExportedToSAP = mExportedToSAP,
                 OrderTypeId             = mOrderTypeId,
                 OrderStatusId           = mOrderStatusId,
                 RFSO_SentBackTofacility = mRFSO_SentBackTofacility
                                           //OrderApproved = mOrderApproved,
                                           //OrderApprovedBy = mOrderApprovedBy,
                                           //OrderDateOfApproval = mOrderDateOfApproval
             };
             context.Order_ViralLoadReagents_Header.Add(x);
             context.SaveChanges();
             ////SaveLog(x);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Example #18
0
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mProductCode) == null)
         {
             var x = new Order_TB
             {
                 OrderNumber            = mOrderNumber,
                 ProductCode            = mProductCode,
                 OpeningBalance         = mOpeningBalance,
                 QtyRecieved            = mQtyRecieved,
                 Dispensed2MonthsReview = mDispensed2MonthsReview,
                 LossesAndAdjustments   = mLossesAndAdjustments,
                 DaysOutofStock         = mDaysOutofStock,
                 ClosingBalance         = mClosingBalance,
                 AdjustedAMC            = mAdjustedAMC,
                 MonthsOfStock          = mMonthsOfStock,
                 // MaximumStockQuantity = mMaximumStockQuantity,
                 QuantityRequired   = mQuantityRequired,
                 Comments           = mComments,
                 Quantity_Allocated = mQuantity_Allocated,
                 RFSONotes          = mRFSONotes
             };
             context.Order_TB.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mitem_code) == null)
         {
             var x = new Order_Lab
             {
                 OrderNumber = mOrderNumber,
                 //FacilityCode = mFacilityCode,
                 //start_date = mStartDate,
                 //end_date = mEndDate,
                 item_code          = mitem_code,
                 opening_balance    = mopening_balance,
                 quantity_recieved  = mquantity_recieved,
                 consumption        = mconsumption,
                 losses_adjustment  = mlosses_adjustment,
                 closing_balance    = mclosing_balance,
                 quantity_to_order  = mquantity_to_order,
                 quantity_allocated = mquantity_allocated,
                 total_cost         = mtotal_cost,
                 comments           = mcomments,
                 RFSONotes          = mRFSONotes
             };
             context.Order_Lab.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Example #20
0
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mProductCode) == null)
         {
             var x = new Order_SMC_SLM
             {
                 OrderNumber = mOrderNumber,
                 //FacilityCode = mFacilityCode,
                 //StartDate = mStartDate,
                 //EndDate = mEndDate,
                 ProductCode          = mProductCode,
                 OpeningBalance       = mOpeningBalance,
                 QtyRecieved          = mQtyRecieved,
                 Consumption          = mConsumption,
                 LossesAndAdjustments = mLossesAndAdjustments,
                 TotalClosingBalance  = mTotalClosingBalance,
                 QuantityToOrder      = mQuantityToOrder,
                 QuantityAllocated    = mQuantityAllocated,
                 Comments             = mComments,
                 RFSONotes            = mRFSONotes
             };
             context.Order_SMC_SLM.Add(x);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
        public ActionResult DialogInsert(A_Product value /*, string testdata, string testdata2, string testdata3*/)
        {
            try
            {
                var _feedback = db.A_Product.FirstOrDefault(f => f.product_code == value.product_code);
                db.Configuration.ProxyCreationEnabled = false;

                if (_feedback == null)
                {
                    db.A_Product.Add(value);
                }
                else
                {
                    db.Entry(_feedback).CurrentValues.SetValues(value);
                    db.Entry(_feedback).State = EntityState.Modified;
                }
                if (value.Basic_Unit == 0)
                {
                    value.Basic_Unit = null;
                }
                var recsaved = db.SaveChanges();
                // msg = value.product_description + " Saved Successfully";
                return(Json(new
                {
                    msg = "Successfully added " + value.product_description,
                    JsonRequestBehavior.AllowGet
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }


            // return Json(msg, JsonRequestBehavior.AllowGet);
        }
 private Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber, mRegimenCode) == null)
         {
             var x = new Treatment_PatientSummary
             {
                 OrderNumber = mOrderNumber,
                 //FacilityCode = mFacilityCode,
                 //StartDate = mStartDate,
                 //EndDate = mEndDate,
                 RegimenCode                   = mRegimenCode,
                 Patients_Existing             = mPatients_Existing,
                 Patients_New                  = mPatients_New,
                 Pregnant_Existing             = mPregnant_Existing,
                 Pregnant_New                  = mPregnant_New,
                 Existing_0_3Yrs               = mExisting_0_3Yrs,
                 New_0_3Yrs                    = mNew_0_3Yrs,
                 Existing_3_10Yrs              = mExisting_3_10Yrs,
                 New_3_10Yrs                   = mNew_3_10Yrs,
                 Existing_10_15Yrs_Less35Kg    = mExisting_10_15Yrs_Less35Kg,
                 New_10_15Yrs_Less35Kg         = mNew_10_15Yrs_Less35Kg,
                 Existing_10_15Yrs_Greater35Kg = mExisting_10_15Yrs_Greater35Kg,
                 New_10_15Yrs_Greater35Kg      = mNew_10_15Yrs_Greater35Kg
             };
             context.Treatment_PatientSummary.Add(x);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Example #23
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new Order_Header
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 DatePrepared = mDatePrepared,
                 EditedBy     = new UserManagement().getCurrentuser(),
                 EditedDate   = mEditedDate,
                 //EmergencyOrder = mEmergencyOrder,
                 FinalSubmission          = mFinalSubmission,
                 OrderTypeId              = mOrderTypeId,
                 OrderStatusId            = mOrderStatusId,
                 OrderStatusIdChangedBy   = mOrderStatusIdChangedBy,
                 OrderStatusIdDateChanged = mOrderStatusIdDateChanged,
                 DateExpected             = mDateExpected,
                 RFSO_SentBackTofacility  = mRFSO_SentBackTofacility
             };
             context.Order_Header.Add(x);
             //////SaveLog(x);
             context.SaveChanges();
             ////SaveLog(x);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
        public ActionResult DialogUpdateMAULT(Order_MAULT_Header value)
        {
            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities     db_master = new mascisEntities();
            Order_MAULT_Header table     = db_master.Order_MAULT_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber);

            TempData["OrderNumber"] = value.OrderNumber;
            value.OrderStatusId     = 1;
            value.ProductCategoryId = 13;
            value.EditedDate        = DateTime.Now;
            value.EditedBy          = new UserManagement().getCurrentuser();
            db_master.Entry(table).CurrentValues.SetValues(value);
            db_master.Entry(table).State = EntityState.Modified;
            db_master.SaveChanges();
            //if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            //{
            //    obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //}
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        //public ActionResult DialogInsertHSIP(Order_SMC_SLM_Header value)
        //{
        //    string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "02");
        //    OrderSMCHeaderModels obj = new OrderSMCHeaderModels();
        //    obj.OrderNumber = OrderNumber;
        //    TempData["OrderNumber"] = OrderNumber;
        //    obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared);
        //    obj.FacilityCode = value.FacilityCode;
        //    obj.StartDate = value.StartDate;
        //    obj.EndDate = value.EndDate;
        //    obj.OrderTypeId = 2;
        //    obj.OrderStatusId = 1;
        //    obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission);
        //    obj.EditedBy = new UserManagement().getCurrentuser();
        //    obj.EditedDate = DateTime.Now;
        //    obj.Save();
        //    return Json(value, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult DialogInsertMAULT(Order_MAULT_Header value)
        {
            //EmailJob obx = new EmailJob();
            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities db_hv       = new mascisEntities();
            string         OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "01");

            db_hv.Order_MAULT_Header.Add(value);
            value.OrderNumber       = OrderNumber;
            TempData["OrderNumber"] = OrderNumber;
            value.ProductCategoryId = 10;
            value.OrderStatusId     = 1;
            value.EditedDate        = DateTime.Now;
            value.EditedBy          = new UserManagement().getCurrentuser();
            db_hv.SaveChanges();
            //obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //if (value.FinalSubmission == true)
            //{
            //    obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //}
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Example #26
0
        public void Save(ScheduleEvent value)
        {
            db.Configuration.ProxyCreationEnabled = false;
            //int intMax = db.ScheduleEvents.ToList().Count > 0 ? db.ScheduleEvents.ToList().Max(p => p.Id) : 1;
            DateTime      startTime       = Convert.ToDateTime(value.StartTime);
            DateTime      endTime         = Convert.ToDateTime(value.EndTime);
            var           currentTimeZone = TimeZone.CurrentTimeZone;
            ScheduleEvent appoint         = new ScheduleEvent()
            {
                SheduleID = value.SheduleID,
                //Id = intMax + 1,
                StartTime         = startTime.ToUniversalTime(),
                EndTime           = endTime.ToUniversalTime(),
                Subject           = value.Subject,
                Location          = value.Location,
                Description       = value.Description,
                Owner             = value.Owner,
                Priority          = value.Priority,
                Recurrence        = value.Recurrence,
                RecurrenceType    = value.RecurrenceType,
                Reminder          = value.Reminder,
                Categorize        = value.Categorize,
                AllDay            = value.AllDay,
                RecurrenceEndDate = value.RecurrenceEndDate != null?Convert.ToDateTime(value.RecurrenceEndDate).ToUniversalTime() : endTime.ToUniversalTime(),
                                        RecurrenceStartDate = value.RecurrenceStartDate != null?Convert.ToDateTime(value.RecurrenceStartDate).ToUniversalTime() : startTime.ToUniversalTime(),
                                                                  RecurrenceRule        = value.RecurrenceRule,
                                                                  RecurrenceTypeCount   = value.RecurrenceTypeCount,
                                                                  CustomStyle           = value.CustomStyle,
                                                                  RemiderType           = value.RemiderType,
                                                                  RemiderTypeCount      = value.RemiderTypeCount,
                                                                  RemiderStartDate      = value.RemiderStartDate,
                                                                  RemiderEndDate        = value.RemiderEndDate,
                                                                  RemiderRule           = value.RemiderRule,
                                                                  VenueCode             = value.VenueCode,
                                                                  ParticipationInvitee  = value.ParticipationInvitee,
                                                                  ParticipationAttendee = value.ParticipationAttendee,
                                                                  EventCategory         = value.EventCategory,
                                                                  Organizer             = value.Organizer,
                                                                  MeetingType           = value.MeetingType,
                                                                  PublicHoliday         = value.PublicHoliday,
                                                                  Added_By              = new UserManagement().getCurrentuser(), //value.Added_By,
                                                                  Date_Added            = DateTime.Now,                          //value.Date_Added,
                                                                  EventOccured          = value.EventOccured,
                                                                  NoEventOccuredComment = value.NoEventOccuredComment,
                                                                  IsBlockAppointment    = value.IsBlockAppointment,
                                                                  VenueList             = value.VenueList,
                                                                  BlockForAll           = value.BlockForAll,
            };

            db.Configuration.ProxyCreationEnabled = false;
            db.ScheduleEvents.Add(appoint);
            //db.SaveChanges();
            try
            {
                db.SaveChanges();
            }

            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        //public ActionResult BatchDataKount(DataManager dataManager)
        //{
        //    IEnumerable DataSource = context.WebTemplate_ARV_PhysicalCount.ToList();
        //    DataResult result = new DataResult();
        //    result.result = DataSource;
        //    result.count = context.WebTemplate_ARV_PhysicalCount.Count();

        //    return Json(result.count, JsonRequestBehavior.AllowGet);
        //}
        public int SavePC(int FacilityCode, DateTime DateOfPhysicalCount, int product_code, string BatchNo,
                          string Quantity_Dispensary, string Quantity_Store, DateTime?ExpiryDate, string Total, string Comment)
        {
            order_hiv_rapid_test_kit_PhysicalCount obj = new order_hiv_rapid_test_kit_PhysicalCount();
            int recstat = 0;

            obj.FacilityCode        = FacilityCode;
            obj.DateOfPhysicalCount = DateOfPhysicalCount;
            obj.product_code        = System.Convert.ToInt32(product_code);
            obj.BatchNo             = BatchNo;
            if (Quantity_Dispensary != null && !string.IsNullOrEmpty(Quantity_Dispensary))
            {
                obj.Quantity_Dispensary = System.Convert.ToDouble(Quantity_Dispensary);
            }
            if (Quantity_Store != null && !string.IsNullOrEmpty(Quantity_Store))
            {
                obj.Quantity_Store = System.Convert.ToDouble(Quantity_Store);
            }
            obj.ExpiryDate = ExpiryDate;
            if (Total != null && !string.IsNullOrEmpty(Total))
            {
                obj.Total = System.Convert.ToDouble(Total);
            }
            obj.Comment = Comment;

            try
            {
                //Check for the existance of the record
                var ca = context.order_hiv_rapid_test_kit_PhysicalCount.FirstOrDefault(c => c.FacilityCode == FacilityCode && c.DateOfPhysicalCount == DateOfPhysicalCount && c.product_code == product_code && c.BatchNo == BatchNo);

                if (ca == null)
                {
                    context.order_hiv_rapid_test_kit_PhysicalCount.Add(obj);
                    obj.DateAdded = DateTime.Now;
                    obj.AddedBy   = new UserManagement().getCurrentuser();
                    recstat       = context.SaveChanges();
                    // recstat = obj.household_number;
                }
                else
                {
                    order_hiv_rapid_test_kit_PhysicalCount table = context.order_hiv_rapid_test_kit_PhysicalCount.FirstOrDefault(c => c.FacilityCode == FacilityCode && c.DateOfPhysicalCount == DateOfPhysicalCount && c.product_code == product_code && c.BatchNo == BatchNo);
                    // obj.household_number = ca.household_number ;
                    context.Entry(table).CurrentValues.SetValues(obj);
                    obj.DateAdded = DateTime.Now;
                    obj.AddedBy   = new UserManagement().getCurrentuser();
                    context.Entry(table).State = EntityState.Modified;
                    recstat = context.SaveChanges();
                    //recstat = ca.household_number;
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }

            return(recstat);
        }
        public ActionResult BatchUpdateSMC(string key, List <Order_SMC_SLM_Physical_Count> changed, List <Order_SMC_SLM_Physical_Count> added, List <Order_SMC_SLM_Physical_Count> deleted)
        {
            mascisEntities dbCase = new mascisEntities();

            //Performing insert operation
            if (added != null && added.Count() > 0)
            {
                foreach (var temp in added)
                {
                    string   iDate = temp.DateOfPhysicalCount.ToString();
                    DateTime oDate = DateTime.Parse(iDate);
                    temp.DateOfPhysicalCount = oDate;

                    dbCase.Order_SMC_SLM_Physical_Count.Add(temp);
                    temp.Total         = temp.Quantity_Dispensary;
                    temp.DateAdded     = DateTime.Now;
                    temp.AddedBy       = new UserManagement().getCurrentuser();
                    temp.record_status = true;
                }
            }
            dbCase.SaveChanges();

            if (changed != null && changed.Count() > 0)
            {
                foreach (var temp in changed)
                {
                    string   iDate = temp.DateOfPhysicalCount.ToString();
                    DateTime oDate = DateTime.Parse(iDate);
                    temp.DateOfPhysicalCount = oDate;

                    Order_SMC_SLM_Physical_Count old = dbCase.Order_SMC_SLM_Physical_Count.
                                                       FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo);
                    if (old != null)
                    {
                        dbCase.Entry(old).CurrentValues.SetValues(temp);
                        temp.Total         = temp.Quantity_Dispensary;
                        temp.DateAdded     = DateTime.Now;
                        temp.AddedBy       = new UserManagement().getCurrentuser();
                        temp.record_status = true;
                    }
                    else
                    {
                        dbCase.Order_SMC_SLM_Physical_Count.Add(temp);
                        temp.Total         = temp.Quantity_Dispensary;
                        temp.DateAdded     = DateTime.Now;
                        temp.AddedBy       = new UserManagement().getCurrentuser();
                        temp.record_status = true;
                    }
                }
            }
            dbCase.SaveChanges();
            //Performing delete operation
            if (deleted != null && deleted.Count() > 0)
            {
                foreach (var temp in deleted)
                {
                    dbCase.Order_SMC_SLM_Physical_Count.Remove(dbCase.Order_SMC_SLM_Physical_Count.FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo));
                }
            }

            dbCase.SaveChanges();
            //return RedirectToAction("BatchDataSMC");
            var data = 0;

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SaveScto(string scto, string Telephone, string Tel, string email, string userid, int _type)
        {
            var result = string.Empty;

            if (_type == 1)
            {
                if (string.IsNullOrEmpty(scto))
                {
                    result = "Please type in the scto";
                }
                else
                {
                    var userexits = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.SCTO == scto);
                    if (userexits == null)
                    {
                        var _userid = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.UserId == userid);
                        if (_userid == null)
                        {
                            fo_SCTO_ContactPerson person = new fo_SCTO_ContactPerson();
                            person.SCTO        = scto;
                            person.SCTO_Email  = email;
                            person.SCTO_TelNo1 = Telephone;
                            person.SCTO_TelNo2 = Tel;
                            person.UserId      = userid;
                            db.fo_SCTO_ContactPerson.Add(person);
                            try
                            {
                                db.SaveChanges();
                                result = scto + " Was saved successfully";
                            }
                            catch (Exception ex)
                            {
                                result = ex.Message.ToString();
                            }
                        }
                        else
                        {
                            result = "This user was already saved as " + _userid.SCTO;
                        }
                    }
                    else
                    {
                        result = "This SCTO name already exists";
                    }
                }
            }
            else if (_type == 2)
            {
                var userexits = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.SCTO == scto);
                if (userexits != null)
                {
                    fo_SCTO_ContactPerson person = new fo_SCTO_ContactPerson();
                    person.SCTO        = scto;
                    person.SCTO_Email  = email;
                    person.SCTO_TelNo1 = Telephone;
                    person.SCTO_TelNo2 = Tel;
                    person.UserId      = userid;
                    try
                    {
                        db.Entry(userexits).CurrentValues.SetValues(person);
                        db.Entry(userexits).State = EntityState.Modified;
                        db.SaveChanges();
                        result = scto + " was updated successfully";
                    }
                    catch (Exception ex)
                    {
                        result = ex.Message.ToString();
                    }
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public Boolean SaveART(string order_no)
        {
            try
            {
                if (GetRecordByKey(order_no).Count > 0)
                {
                    List <Order_DrugDetails> m = new List <Order_DrugDetails>();
                    m = GetRecordByKey(order_no);
                    //DateTime eDate = m.;
                    DateTime date = System.Convert.ToDateTime(context.Order_Header.FirstOrDefault(a => a.OrderNumber == order_no).DatePrepared);

                    foreach (var n in m)
                    {
                        if (n.Quantity_Allocated > 0)
                        {
                            DateTime pDate       = date;//System.Convert.ToDateTime(n.Order_Header.DatePrepared);
                            int?     facility    = n.FacilityCode;
                            int      productcode = n.DrugCode;
                            var      sapcode     = context.A_Product.FirstOrDefault(a => a.product_code == n.DrugCode);
                            if (sapcode != null)
                            {
                                productcode = Convert.ToInt32(sapcode.SAP_code);
                            }
                            var x = new SAP_ExportDocumentLines
                            {
                                OrderNumber        = n.OrderNumber,
                                ItemCode           = productcode,
                                CurrentRecord      = true,
                                RecordReadBySAP    = false,
                                DocNum             = System.Convert.ToString(System.Convert.ToDateTime(pDate).Day + "" + System.Convert.ToDateTime(pDate).Month + "" + System.Convert.ToDateTime(pDate).Year + "" + facility),
                                QuantityAllocated  = Convert.ToInt32(n.Quantity_Allocated),
                                QuantityOrdered    = Convert.ToInt32(n.TotalDrugs_Required),
                                CurrentRecordOnSAP = true,
                                AddedDate          = System.DateTime.Now,
                                AddedBy            = new UserManagement().getCurrentuser(),
                            };

                            if (GetRecord(order_no, x.ItemCode).Count > 0)
                            {
                            }
                            else
                            {
                                context.SAP_ExportDocumentLines.Add(x);
                                context.SaveChanges();
                            }
                        }
                    }

                    return(true);
                }
                else
                {
                    // existing_records = true;
                    return(false);
                }
            }
            catch (Exception x)
            {
                throw (x);
            }
        }