Esempio n. 1
0
 public Boolean SaveLog(order_hiv_rapid_test_kit_header record)
 {
     try
     {
         var log = new order_hiv_rapid_test_kit_header_Log
         {
             OrderNumber            = record.OrderNumber,
             FacilityCode           = record.FacilityCode,
             OrderStatusId          = System.Convert.ToInt32(record.OrderStatusId),
             OrderStatusChangedBy   = new UserManagement().getCurrentuser(),
             OrderStatusDateChanged = DateTime.Now,
             StartDate         = record.StartDate,
             EndDate           = record.EndDate,
             DatePrepared      = record.DatePrepared,
             OrderTypeId       = record.OrderTypeId,
             ProductCategoryId = 3
         };
         context.order_hiv_rapid_test_kit_header_Log.Add(log);
         context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw (e);
     }
 }
Esempio n. 2
0
 public Boolean Save()
 {
     try
     {
         if (GetRecordByKey(mOrderNumber) == null)
         {
             var x = new order_hiv_rapid_test_kit_header
             {
                 OrderNumber  = mOrderNumber,
                 FacilityCode = mFacilityCode,
                 StartDate    = mStartDate,
                 EndDate      = mEndDate,
                 DatePrepared = mDatePrepared,
                 EditedBy     = new UserManagement().getCurrentuser(),
                 EditedDate   = DateTime.Now,
                 // EmergencyOrder = mEmergencyOrder,
                 FinalSubmission          = mFinalSubmission,
                 OrderTypeId              = mOrderTypeId,
                 DateExpected             = mDateExpected,
                 OrderStatusId            = mOrderStatusId,
                 OrderStatusIdChangedBy   = mOrderStatusIdChangedBy,
                 OrderStatusIdDateChanged = mOrderStatusIdDateChanged,
                 RFSO_SentBackTofacility  = mRFSO_SentBackTofacility
             };
             context.order_hiv_rapid_test_kit_header.Add(x);
             context.SaveChanges();
             ////SaveLog(x);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Esempio n. 3
0
        public Boolean SaveHIV(string OrderNo)
        {
            try
            {
                var allocated = context.order_hiv_rapid_test_kit.Where(o => o.OrderNumber == OrderNo && o.Quantity_Allocated > 0).ToList().Count;
                if (allocated > 0)
                {
                    if (GetRecordByKey_HIV(OrderNo) != null)
                    {
                        order_hiv_rapid_test_kit_header t = new order_hiv_rapid_test_kit_header();
                        t = GetRecordByKey_HIV(OrderNo);
                        //DateTime eDate  = t.EndDate;
                        DateTime pDate    = System.Convert.ToDateTime(t.DatePrepared);
                        int      facility = t.FacilityCode;
                        var      sapcode  = context.A_Facilities.FirstOrDefault(a => a.FacilityCode == facility).SAP_Code;
                        var      x        = new SAP_ExportHeader
                        {
                            OrderNumber     = t.OrderNumber,
                            AddedDate       = System.DateTime.Now,
                            AddedBy         = new UserManagement().getCurrentuser(),
                            CurrentReccord  = true,
                            RecordReadBySAP = false,
                            DocNum          = System.Convert.ToString(System.Convert.ToDateTime(pDate).Day + "" + System.Convert.ToDateTime(pDate).Month + "" + System.Convert.ToDateTime(pDate).Year + "" + facility),
                            DocDate         = System.Convert.ToDateTime(pDate),
                            DocDueDate      = System.Convert.ToDateTime(pDate),
                            //CardCode = t.A_Facilities.SAP_Code,
                            CardCode        = sapcode,
                            DocEntry        = mDocEntry,
                            ProductCategory = 3,
                        };

                        var order = context.SAP_ExportHeader.FirstOrDefault(o => o.OrderNumber == OrderNo);
                        if (order == null)
                        {
                            context.SAP_ExportHeader.Add(x);
                            context.SaveChanges();
                        }
                        SAPExportDetails details = new SAPExportDetails();
                        details.SaveHIV(OrderNo);
                        //var update = t;
                        //update.OrderStatusId = 4;
                        //context.Entry(t).CurrentValues.SetValues(update);
                        //context.Entry(t).State = EntityState.Modified;
                        //context.SaveChanges();


                        //// to update the order status of the record
                        //OrderHIVTestKitHeaderModels sap = new OrderHIVTestKitHeaderModels();
                        //sap.UpdateSAP(OrderNo);

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