Exemple #1
0
 public Boolean SaveART(string OrderNo)
 {
     try
     {
         var allocated = context.Order_DrugDetails.Where(o => o.OrderNumber == OrderNo && o.Quantity_Allocated > 0).ToList().Count;
         if (allocated > 0)
         {
             if (GetRecordByKey(OrderNo) != null)
             {
                 Order_Header t = new Order_Header();
                 t = GetRecordByKey(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        = sapcode,// t.A_Facilities.SAP_Code,
                     DocEntry        = mDocEntry,
                     ProductCategory = 2,
                 };
                 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.SaveART(OrderNo);
                 //var update = t;
                 //update.OrderStatusId = 4;
                 //context.Entry(t).CurrentValues.SetValues(update);
                 //context.Entry(t).State = EntityState.Modified;
                 //context.SaveChanges();
                 return(true);
             }
             else
             {
                 // existing_records = true;
                 return(false);
             }
         }
         else
         {
             // existing_records = true;
             return(false);
         }
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Exemple #2
0
        public Boolean SaveLab(string OrderNo)
        {
            try
            {
                var allocated = context.Order_Lab.Where(o => o.OrderNumber == OrderNo && o.quantity_allocated > 0).ToList().Count;
                if (allocated > 0)
                {
                    if (GetRecordByKey_Lab(OrderNo) != null)
                    {
                        View_Order_Lab_SAP_Export_Final t = new View_Order_Lab_SAP_Export_Final();
                        t = GetRecordByKey_Lab(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.SAP_Code,
                            DocEntry        = mDocEntry,
                            ProductCategory = 1,
                        };
                        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.SaveLab(OrderNo);
                        //var lab = context.Order_Lab_Header.FirstOrDefault(o => o.OrderNumber == OrderNo);
                        //var update = lab;
                        //update.OrderStatusId = 4;
                        //context.Entry(lab).CurrentValues.SetValues(update);
                        //context.Entry(lab).State = EntityState.Modified;
                        //context.SaveChanges();

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

                        //// to update the order status of the record in lab custom
                        //OrderLaboratoryCustomHeaderModels sapCustom = new OrderLaboratoryCustomHeaderModels();
                        //sapCustom.UpdateSAP(OrderNo);

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