public static bool Add(Session pSession, ProcessArticleStockMode pMode, FIN_DocumentFinanceDetail pDocumentDetail, ERP_Customer pCustomer, int pOrd, DateTime pDocumentDate, string pDocumentNumber, FIN_Article pArticle, decimal pQuantity, string pNotes) { //Log4Net log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); bool result = false; decimal quantity = 0.0m; try { switch (pMode) { case ProcessArticleStockMode.Out: quantity = -(pQuantity); break; case ProcessArticleStockMode.In: quantity = pQuantity; break; } //Get Objects in same Session ERP_Customer customer = (ERP_Customer)pSession.GetObjectByKey(typeof(ERP_Customer), pCustomer.Oid); FIN_Article article = (FIN_Article)pSession.GetObjectByKey(typeof(FIN_Article), pArticle.Oid); POS_ConfigurationPlaceTerminal terminal = (POS_ConfigurationPlaceTerminal)pSession.GetObjectByKey(typeof(POS_ConfigurationPlaceTerminal), GlobalFramework.LoggedTerminal.Oid); SYS_UserDetail userDetail = (SYS_UserDetail)pSession.GetObjectByKey(typeof(SYS_UserDetail), GlobalFramework.LoggedUser.Oid); FIN_ArticleStock articleStock = new FIN_ArticleStock(pSession) { Customer = customer, Date = pDocumentDate, Article = article, Quantity = quantity, Notes = pNotes, CreatedWhere = terminal, CreatedBy = userDetail }; if (pDocumentNumber != string.Empty) { articleStock.DocumentNumber = pDocumentNumber; } if (pDocumentDetail != null) { articleStock.DocumentNumber = pDocumentDetail.DocumentMaster.DocumentNumber; articleStock.DocumentMaster = pDocumentDetail.DocumentMaster; articleStock.DocumentDetail = pDocumentDetail; } //Only saves if not Working on a Unit Of Work Transaction if (pSession.GetType() != typeof(UnitOfWork)) { articleStock.Save(); } //Audit switch (pMode) { case ProcessArticleStockMode.Out: FrameworkUtils.Audit("STOCK_MOVEMENT_OUT", string.Format(Resx.audit_message_stock_movement_out, article.Designation, FrameworkUtils.DecimalToString(quantity, SettingsApp.DecimalFormatStockQuantity))); break; case ProcessArticleStockMode.In: FrameworkUtils.Audit("STOCK_MOVEMENT_IN", string.Format(Resx.audit_message_stock_movement_in, article.Designation, FrameworkUtils.DecimalToString(quantity, SettingsApp.DecimalFormatStockQuantity))); break; } result = true; } catch (Exception ex) { log.Error(ex.Message, ex); } return(result); }
//XpoMode public TreeViewArticleStock(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default) { //Init Vars Type xpoGuidObjectType = typeof(FIN_ArticleStock); //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView FIN_ArticleStock defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_ArticleStock : null; //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView Type typeDialogClass = (pDialogType != null) ? pDialogType : null; //Config int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]); //Configure columnProperties List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>(); columnProperties.Add(new GenericTreeViewColumnProperty("Quantity") { Title = Resx.global_stock_movement, MinWidth = 100, FormatProvider = new FormatterStockMovement(), }); columnProperties.Add(new GenericTreeViewColumnProperty("Date") { Title = Resx.global_date, MinWidth = 100, FormatProvider = new FormatterDate(), }); columnProperties.Add(new GenericTreeViewColumnProperty("Customer") { Title = Resx.global_entity, ChildName = "Name", MinWidth = 125 }); columnProperties.Add(new GenericTreeViewColumnProperty("DocumentNumber") { Title = Resx.global_document_number, MinWidth = 125 }); columnProperties.Add(new GenericTreeViewColumnProperty("Article") { Title = Resx.global_article, ChildName = "Designation", MinWidth = 125 }); columnProperties.Add(new GenericTreeViewColumnProperty("Quantity") { Title = Resx.global_quantity, MinWidth = 100, //Alignment = 1.0F, FormatProvider = new FormatterDecimal(), //CellRenderer = new CellRendererText() //{ // FontDesc = new Pango.FontDescription() { Size = fontGenericTreeViewColumn }, // Alignment = Pango.Alignment.Right, // Xalign = 1.0F //} }); columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt") { Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150 }); //Configure Criteria/XPCollection/Model //CriteriaOperator.Parse("Code >= 100 and Code <= 9999"); CriteriaOperator criteria = pXpoCriteria; SortProperty[] sortProperty = new SortProperty[2]; sortProperty[0] = new SortProperty("CreatedAt", SortingDirection.Ascending); sortProperty[1] = new SortProperty("Ord", SortingDirection.Ascending); XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty); //Call Base Initializer base.InitObject( pSourceWindow, //Pass parameter defaultValue, //Pass parameter pGenericTreeViewMode, //Pass parameter pGenericTreeViewNavigatorMode, //Pass parameter columnProperties, //Created Here xpoCollection, //Created Here typeDialogClass //Created Here ); }