protected static FR_L6PD_GOPaAAP_1154 Execute(DbConnection Connection, DbTransaction Transaction, P_L6PD_GOPaAAP_1154 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6PD_GOPaAAP_1154(); returnValue.Result = new L6PD_GOPaAAP_1154(); var param = new P_L6PD_GPaCOSfT_1120(); param.TreatmentID = Parameter.TreatmentID; returnValue.Result.ProductsForTreatment = cls_Get_Products_and_CustomerOrderStatuses_for_TreatmentID.Invoke(Connection, Transaction, param, securityTicket).Result.ToArray(); List <L5PR_GHPfT_1018> filteredArticles = new List <L5PR_GHPfT_1018>(); var allArticles = cls_Get_HEC_Products_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result.ToList(); foreach (var item in allArticles) { //Ovo ce se brisati################################# var cmn_pro_product_2_productGroupQuery = new ORM_CMN_PRO_Product_2_ProductGroup.Query(); cmn_pro_product_2_productGroupQuery.Tenant_RefID = securityTicket.TenantID; cmn_pro_product_2_productGroupQuery.CMN_PRO_Product_RefID = item.CMN_PRO_ProductID; cmn_pro_product_2_productGroupQuery.IsDeleted = false; var cmn_pro_product_2_productGroup = ORM_CMN_PRO_Product_2_ProductGroup.Query.Search(Connection, Transaction, cmn_pro_product_2_productGroupQuery).FirstOrDefault(); //################################# if (cmn_pro_product_2_productGroup == null) { filteredArticles.Add(item); } else { continue; } } returnValue.Result.AllProducts = filteredArticles.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_SOHaS1434 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //* Array TreatmentID and ArticleID are the sam lenght; Treatment with position i has article with the position i var count = 0; List <Orders> orderList = new List <Orders>(); int ordinalNumber = 0; Guid headerID = Guid.Empty; for (int g = 0; g < Parameter.HEC_Patient_TreatmentID.Length; g++) { #region Save Order var status_query = new ORM_ORD_CUO_CustomerOrder_Status.Query(); status_query.IsDeleted = false; status_query.Tenant_RefID = securityTicket.TenantID; status_query.GlobalPropertyMatchingID = STLD_ORD_CUO_CustomerOrder_Status.Ordered.ToString(); var notOrderedstatus = ORM_ORD_CUO_CustomerOrder_Status.Query.Search(Connection, Transaction, status_query).First(); // za ispraviti sto pre #region var prod_param = new P_L6PD_GPaCOSfT_1120(); prod_param.TreatmentID = Parameter.HEC_Patient_TreatmentID[g]; var products = cls_Get_Products_and_CustomerOrderStatuses_for_TreatmentID.Invoke(Connection, Transaction, prod_param, securityTicket).Result; var notOrdered_Products = products.Where(i => i.CMN_PRO_ProductID == Guid.Empty); #endregion if (notOrdered_Products.Count() == 0) { return(returnValue); } #region Save Header and Status var header_query = new ORM_ORD_CUO_CustomerOrder_Header.Query(); header_query.IsDeleted = false; header_query.Tenant_RefID = securityTicket.TenantID; var headers = ORM_ORD_CUO_CustomerOrder_Header.Query.Search(Connection, Transaction, header_query); if (headers != null) { count = headers.Count(); } String ordernumber = String.Empty; var orderFound = orderList.Where(c => c.TreatmentID == Parameter.HEC_Patient_TreatmentID[g]).FirstOrDefault(); if (orderFound == null) { ordernumber = "000000000000" + (count + 1).ToString(); ordernumber = ordernumber.Substring(ordernumber.Length - 12); var header = new ORM_ORD_CUO_CustomerOrder_Header(); headerID = Guid.NewGuid(); header.ORD_CUO_CustomerOrder_HeaderID = headerID; header.Current_CustomerOrderStatus_RefID = notOrderedstatus.ORD_CUO_CustomerOrder_StatusID; header.CustomerOrder_Number = ordernumber; header.CustomerOrder_Date = DateTime.Now; header.Creation_Timestamp = DateTime.Now; header.Tenant_RefID = securityTicket.TenantID; header.Save(Connection, Transaction); var history = new ORM_ORD_CUO_CustomerOrder_StatusHistory(); history.ORD_CUO_CustomerOrder_StatusHistoryID = Guid.NewGuid(); history.CustomerOrder_Header_RefID = header.ORD_CUO_CustomerOrder_HeaderID; history.CustomerOrder_Status_RefID = notOrderedstatus.ORD_CUO_CustomerOrder_StatusID; history.StatusHistoryComment = ""; history.Creation_Timestamp = DateTime.Now; history.Tenant_RefID = securityTicket.TenantID; history.Save(Connection, Transaction); Orders ord = new Orders(); ord.TreatmentID = Parameter.HEC_Patient_TreatmentID[g]; ord.Ordernumber = ordernumber; ord.OrdinalNumber = 0; ord.headerID = headerID; orderList.Add(ord); ordinalNumber = 0; } else { ordernumber = orderFound.Ordernumber; ordinalNumber = orderFound.OrdinalNumber + 1; headerID = orderFound.headerID; } #endregion var product = notOrdered_Products.Where(t => t.CMN_PRO_ProductID == Parameter.AtricleID[g]).FirstOrDefault(); var position = new ORM_ORD_CUO_CustomerOrder_Position(); position.ORD_CUO_CustomerOrder_PositionID = Guid.NewGuid(); position.CustomerOrder_Header_RefID = headerID; position.Position_OrdinalNumber = ordinalNumber; position.Position_Quantity = product.Quantity; position.Position_ValuePerUnit = 1; position.Position_ValueTotal = (decimal)product.Quantity; position.CMN_PRO_Product_Variant_RefID = Guid.Empty; position.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; position.CMN_PRO_Product_Release_RefID = Guid.Empty; position.Position_RequestedDateOfDelivery = product.ExpectedDateOfDelivery; position.Creation_Timestamp = DateTime.Now; position.Tenant_RefID = securityTicket.TenantID; position.Save(Connection, Transaction); var item = new ORM_HEC_Patient_Treatment_RequiredProduct(); item.Load(Connection, Transaction, product.HEC_Patient_Treatment_RequiredProductID); item.BoundTo_CustomerOrderPosition_RefID = position.ORD_CUO_CustomerOrder_PositionID; item.Save(Connection, Transaction); #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_SPTaO_1014 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Save Treatment var param = new P_L6TR_SPT_1533(); param.Aticles = Parameter.Aticles; param.Diagnosis = Parameter.Diagnosis; param.Treatment = Parameter.Treatment; param.Followups = Parameter.Followups; var TreatmentID = cls_Save_Patient_Treatment.Invoke(Connection, Transaction, param, securityTicket).Result; returnValue.Result = TreatmentID; #endregion #region Save Order var status_query = new ORM_ORD_CUO_CustomerOrder_Status.Query(); status_query.IsDeleted = false; status_query.Tenant_RefID = securityTicket.TenantID; status_query.GlobalPropertyMatchingID = STLD_ORD_CUO_CustomerOrder_Status.Ordered.ToString(); var notOrderedstatus = ORM_ORD_CUO_CustomerOrder_Status.Query.Search(Connection, Transaction, status_query).First(); var prod_param = new P_L6PD_GPaCOSfT_1120(); prod_param.TreatmentID = TreatmentID; var products = cls_Get_Products_and_CustomerOrderStatuses_for_TreatmentID.Invoke(Connection, Transaction, prod_param, securityTicket).Result; var notOrdered_Products = products.Where(i => i.ORD_CUO_CustomerOrder_PositionID == Guid.Empty); if (notOrdered_Products.Count() == 0) { return(returnValue); } #region Save Header and Status var header_query = new ORM_ORD_CUO_CustomerOrder_Header.Query(); header_query.IsDeleted = false; header_query.Tenant_RefID = securityTicket.TenantID; var headers = ORM_ORD_CUO_CustomerOrder_Header.Query.Search(Connection, Transaction, header_query); var count = 0; if (headers != null) { count = headers.Count(); } String ordernumber = "000000000000" + (count + 1).ToString(); ordernumber = ordernumber.Substring(ordernumber.Length - 12); var header = new ORM_ORD_CUO_CustomerOrder_Header(); header.ORD_CUO_CustomerOrder_HeaderID = Guid.NewGuid(); header.Current_CustomerOrderStatus_RefID = notOrderedstatus.ORD_CUO_CustomerOrder_StatusID; header.CustomerOrder_Number = ordernumber; header.CustomerOrder_Date = DateTime.Now; header.Creation_Timestamp = DateTime.Now; header.Tenant_RefID = securityTicket.TenantID; header.Save(Connection, Transaction); var history = new ORM_ORD_CUO_CustomerOrder_StatusHistory(); history.ORD_CUO_CustomerOrder_StatusHistoryID = Guid.NewGuid(); history.CustomerOrder_Header_RefID = header.ORD_CUO_CustomerOrder_HeaderID; history.CustomerOrder_Status_RefID = notOrderedstatus.ORD_CUO_CustomerOrder_StatusID; history.StatusHistoryComment = ""; history.Creation_Timestamp = DateTime.Now; history.Tenant_RefID = securityTicket.TenantID; history.Save(Connection, Transaction); #endregion int cnt = 0; foreach (var product in notOrdered_Products) { cnt++; var position = new ORM_ORD_CUO_CustomerOrder_Position(); position.ORD_CUO_CustomerOrder_PositionID = Guid.NewGuid(); position.CustomerOrder_Header_RefID = header.ORD_CUO_CustomerOrder_HeaderID; position.Position_OrdinalNumber = cnt; position.Position_Quantity = product.Quantity; position.Position_ValuePerUnit = 1; position.Position_ValueTotal = (decimal)product.Quantity; position.CMN_PRO_Product_Variant_RefID = Guid.Empty; position.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; position.CMN_PRO_Product_Release_RefID = Guid.Empty; position.Position_RequestedDateOfDelivery = product.ExpectedDateOfDelivery; position.Creation_Timestamp = DateTime.Now; position.Tenant_RefID = securityTicket.TenantID; position.Save(Connection, Transaction); var item = new ORM_HEC_Patient_Treatment_RequiredProduct(); item.Load(Connection, Transaction, product.HEC_Patient_Treatment_RequiredProductID); item.BoundTo_CustomerOrderPosition_RefID = position.ORD_CUO_CustomerOrder_PositionID; item.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }