///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L6SO_IPCA_1039 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6SO_IPCA_1039 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L6SO_IPCA_1039 functionReturn = new FR_L6SO_IPCA_1039(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, Parameter, securityTicket); #region Cleanup Connection/Transaction //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } #endregion } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw new Exception("Exception occured in method cls_Is_PickingControlAllowed", ex); } return(functionReturn); }
protected static FR_L6SO_IPCA_1039 Execute(DbConnection Connection, DbTransaction Transaction, P_L6SO_IPCA_1039 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6SO_IPCA_1039(); returnValue.Result = new L6SO_IPCA_1039(); #region Check Header var shipmentHeader = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Header(); shipmentHeader.Load(Connection, Transaction, Parameter.LOG_SHP_Shipment_HeaderID); if (shipmentHeader.IsReadyForPicking == false) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = true; returnValue.Result.IfPickingControlNotAllowed_Reason = "IsReadyForPicking == false"; return(returnValue); } if (shipmentHeader.IsManuallyCleared_ForPicking == false) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = true; returnValue.Result.IfPickingControlNotAllowed_Reason = "IsManuallyCleared_ForPicking == false"; return(returnValue); } if (shipmentHeader.HasPickingStarted == false) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = true; returnValue.Result.IfPickingControlNotAllowed_Reason = "HasPickingStarted == false"; return(returnValue); } if (shipmentHeader.HasPickingFinished == true) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = false; returnValue.Result.IfPickingControlNotAllowed_Reason = "HasPickingFinished == true"; return(returnValue); } if (shipmentHeader.IsShipped == true) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = false; returnValue.Result.IfPickingControlNotAllowed_Reason = "IsShipped == true"; return(returnValue); } if (shipmentHeader.IsBilled == true) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = false; returnValue.Result.IfPickingControlNotAllowed_Reason = "IsBilled == true"; return(returnValue); } #endregion #region Check Positions var shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, new ORM_LOG_SHP_Shipment_Position.Query() { LOG_SHP_Shipment_Header_RefID = Parameter.LOG_SHP_Shipment_HeaderID, IsDeleted = false }); if (shipmentPositions.Count() == 0) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = false; returnValue.Result.IfPickingControlNotAllowed_Reason = "shipmentPositions.Count() == 0"; return(returnValue); } foreach (var shipmentPosition in shipmentPositions) { var quantityToShip = shipmentPosition.QuantityToShip; var reservations = ORM_LOG_RSV_Reservation.Query.Search(Connection, Transaction, new ORM_LOG_RSV_Reservation.Query() { LOG_SHP_Shipment_Position_RefID = shipmentPosition.LOG_SHP_Shipment_PositionID, IsReservationExecuted = false, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); var reservedQuantity = reservations.Sum(i => i.ReservedQuantity); if (quantityToShip != reservedQuantity || reservedQuantity == 0) { returnValue.Result.IsPickingControlAllowed = false; returnValue.Result.IfPickingControlNotAllowed_ResetShipmentFlags = true; returnValue.Result.IfPickingControlNotAllowed_Reason = String.Format("Shipment position {0} with quantity {1}, has {2} reserved quantity", shipmentPosition.LOG_SHP_Shipment_PositionID.ToString(), shipmentPosition.QuantityToShip, reservedQuantity); return(returnValue); } } #endregion returnValue.Result.IsPickingControlAllowed = true; return(returnValue); #endregion UserCode }