How do I close SalesQuotation Details Form in the background? - axapta

I have created some form in which it sended a few items to the sales lines in sales order detail form. What I need now is some logic to check if salesquotation detail form is open in the background then close it. Can anyone help.

It is not best practice to close forms by code, the user should be in control.
But if you insist:
void close()
{
if (formRun && !formRun.closed())
formRun.close();
super();
}
This closes a child form (if not already closed) when closing the current form.
Of course this requires you to open the child form by code as explained here.

Related

Return to previous page with refresh data Xamarin Forms [duplicate]

This question already has answers here:
How to pass data to the previous page using PopAsync?
(2 answers)
Closed 6 years ago.
in main page I have a button create post. When I click on it I receive editor. After input of some text I click button savePost. Then post saves to server and return to my main page, but without new post on my wall. I need to refresh that page to see my new post. How can I write code to receive my previous page with my new post on main page after clicking button savePost?
Button savePost = new Button {Text = "Save post"};
stackLayout.Children.Add(savePost);
savePost.Clicked += (sender, args) =>
{
var restService = new RestServiceImpl(UserService.User.AccessToken);
PostView post = new PostView
{
Text = textEditor.Text,
};
restService.CreatePost(post);
Navigation.PopAsync();
};
There are a few ways to go about it. The most simple one is to implement some mechanism on the OnAppearing event of the page and just reload there, or think of some way to detect a reload has to be done instead of just reloading. This can be done for instance by some bool you set to true after the 'restService.CreatePost(post);' line.
That kind of brings me to the other way. When you are using some kind of MVVM framework (have a look at FreshMvvm for example) you can execute some code when a PageModel is popped. So you have much more granular control over when to reload and detect if it is necessary at all.
A completely other way is to use the MessagingCenter. You can send out a message whenever (and from where ever) reloading is needed and let the pages which needs reloading subscribe to that and execute the reloading code whenever the right message was received.
It all depends on what your requirements and code structure is.

How navigate to next page using AJAX in MVC4?

I don't have so much experience using AJAX in a MVC application, in fact is my first facing. Please check the below image and note the rectangles.
The image is just an example that I took from internet.
The biggest rectangle is a partial view in my application and I have to render it when the user press Continue or Continuar button. The application should replace the current view for another without refresh the page.
This is the code which I'm testing, note first that I'm passing the first element of a list, but when the user press the button, render the view with the next element index = 2.
public ActionResult DoTest()
{
if (!Request.IsAjaxRequest())
{ }
List<Worksheet> worksheets = new List<Worksheet>()
{
new Worksheet("Hoja 1", ...),
new Worksheet("Hoja 2", ...)
};
return View(worksheets[0]);
}
Can orient me a little bit to know how to implement this feature? I just know that I need to use Ajax.
Have a look through the tutorials and examples here. There's plenty of other material around on the web with information on this subject.
There are many different ways you can achieve this. One way would be to write a custom paging Helper (HtmlHelper) that accepts new content upon the post event. You can view all about Helpers here : Custom HTML Helpers
Another way could be to use partial page rendering to achieve the partial page update upon post event.
If I was you I would combine a partial view with a jquery function to update the content. You can view some help on that here: Change dive content with Jquery

WebBrowser Control programming Tabs within Document pages query

I am trying to download information from a website and I have hit (yet another) brick wall in a long and tiresome journey to get something productive developed.
I have a program which uses WebBrowser to login to a site - with a valid username and password - therby allowing me to set up a legitimate connection to it and retrieve information (my own) from it.
From the initial page presented to me after login, I can use WebBrowser.Document.GetElementsByTagName("A") and WebBrowser.Document.GetElementById("Some Id") etc. to work my way around the website, and processing all the DocumentCompleted events returned until ... I arrive at a page which appears to have a TabControl embedded in it.
I need to be able to choose the middle Tab of this control, and retrieve the information it holds. When I access this information 'normally' (i.e. from IE and not from my WebBrowser program) I can click each of the three tabs and information duly appears - so its there, tantalisingly so ... but can I manupulate these Tabs from my program? I feel it should be possible, but I can't see how I can do it.
The problem manifests itself because when I am processing the page which has the Tab in it my code looks like this:
static void wb_TabPage(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb = (WebBrowser)sender;
HtmlElement element;
element = wb.Document.GetElementById("Bills"); // Find the "Bills" tab
element.InvokeMember("Click"); // Click the "Bills" tab
// Unhook THIS routine from DocumentCompleted delivery
wb.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(wb_TabPage);
// Hook up this routine - for the next 'Document Completed' delivery - which never arrives!
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_Bills);
return;
}
And that's the problem - no more Documents are ever 'Completed' for me to process, even after the InvokeMember("Click"). It seems for all the world that the Tabs are being updated inplace, and no amount of Refresh(ing) or Navigating or Event Handling will allow me to get to a place or in a position where I can get the data from them
Does anybody have any idea how I can do this? Does anybody know how to manipulate Tabs from WebBrowser? Thanks in advance if you do ...
Try using the findcontrol function on your page. You will likely need to drill into the tab control itself to find the tab page and the controls contained in it.

ASP.NET MVC cancel, not delete

I have two questions, both related to the same view: so there is view called ProductDetails which shows the details of a product.
Each product can have the status:
Available - in this case, two button are available "edit" and "remove"(which will change the status of the product to "Not available" but will not remove it from DB)
Not available - in this case, the page displays the product but no options to edit or remove are
visible.
The controller ProductsController has an action Details that shows that view.
The problem is that I don't know how to implement the two buttons (Edit and Remove) because:
Edit sends to another action method (Edit which display another view) <- this works
Remove should do (IMO) a post on the current page. In the post action, the status of the product is changed and the view is shown again.
I want both button to look like links. If I put a form for remove, then it will be displayed as a button. I would like to avoid making the button look like a link with css. Or... at least I want to use the same HTML element for both 'buttons'.
This is more an issue of displaying the elements so I have added the CSS tag to your question as some alternative answers may rely on this.
Personally I think trying to make a button look like a text link would be quite awkward, even once you turn off the border and background you have issues with lining up the text etc.
I'd say you have 2 "simple" options.
Firstly you could make the delete not post a delete request but link to a delete confirmation page (or bring up a JS modal window with your delete form and button).
Secondly you could make them both look like buttons, while you requested that it looks like a link I figured that the main point was consistency in UI than the link look specifically. You could use JQueryUI and invoke .button() on both elements, invoking JQueryUI for 1 feature is a bit overkill but it's a quick change, of course you could replicate the same idea of styling the link like the buttons but would have to spend time dealing with browser CSS issues.
the Remove link should post to the Remove action, which should in turn (after validation and DB update) redirect to the details action.
public ActionResult Details(int productId)
{
// Your current action method
return View(model);
}
public ActionResult Remove(int productId)
{
// Validate productId
// Update DB
return RedirectToAction("Details", new { productId = productId } );
}
You easily can solve your link vs button problem by using a GET instead of a POST. Don't be blinded by best practices.
Or you can use a Remove link that executes a one-liner Javascript function that posts the form:
Remove

Forms opening in the background in AX 2009

Sometimes when opening a form or when clicking on an object on the form, the form goes inactive or opens in the background. Is there a way to prevent this from occurring programatically?
I have seen this from time to time, but I don't have any documented solution.
You could try to clear the users AUC cache and see if that helps.
I have found the answer to this question. It is related to a 3rd party addition that we have installed (IEM). I had to remove some code that they have that sets forms as modal (which ends up putting them in the background because of the base timeout function in AX because the code to make the form modal takes too long to execute). I had to make a change to Classes/SysSetupFormRun: Below is the code and where it was changed
public void activate(boolean _active)
{
;
// if (_active)
// PUL_Modal::construct().hookModal(this);
super(_active);
/*
if (_active)
PUL_Modal::construct().checkModal(this);
*/
}
This returns the activate method to its previous state and prevents forms from going modal.

Resources