populate grid with temp table from click event handler d365fo - axapta

I am trying to populate a grid form with a temp table (inMemory) from a click event handler but the grid isn't populate. here is my code:
class ARQ_CONCCo_InventTransRegisterFormEvents
{
[FormControlEventHandler(formControlStr(InventTransRegister, ARQImportCSV), FormControlEventType::Clicked)]
public static void ARQImportCSV_OnClicked(FormControl sender, FormControlEventArgs e)
{
TmpInventTransWMS inventTransWMS, inventTransWMSAux;
FormDataSource inventTransWMS_ds;
FormRun formRun = sender.formRun() as formRun;
inventTransWMS_ds = sender.formRun().dataSource(formDataSourceStr(InventTransRegister, TmpInventTransWMS)) as FormDataSource;
inventTransWMSAux = inventTransWMS_ds.cursor();
inventTransWMS.InventQty = 10.00;
inventTransWMS.UnitId = "KG";
inventTransWMS.insert();
inventTransWMSAux.setTmpData(inventTransWMS);
}
}

Related

changing mouse cursor in chromiumwebbrowser DragEnter event in WPF

we are using chromiumwebbrowser in WPf application, added DragEnter event handler to the chromiumwebbrowser and call come to us.
wanted to change the cursor,
private void Browser_DragEnter(object sender, DragEventArgs e)
{
var currCursor = Browser.Cursor;
if (e.Effects == DragDropEffects.Move)
{
//Mouse.OverrideCursor = Cursors.Hand;
// Mouse.SetCursor(Cursors.Hand);
Debug.Write("DragDropEffects.Move\n");
}
else
Mouse.SetCursor(Cursors.Hand);
Mouse.OverrideCursor = Cursors.Pen;
Browser.Cursor = Cursors.Pen;
//Mouse.Capture(Browse);
e.Handled = true;
}
nothing works, could some help would solve this issue

How to use PKPaymentButton in Xamarin.Forms

I have a page in Xamarin.Forms in which I have to show PKPaymentButton by using the same PKPaymentButton class which is a child of UIButton in PassKit.
I have written a custom ButtonRenderer and trying to convert the button into PKPayment button.
I got so far that in custom renderer we can change the appearance of a button but can we use something like creating a new button instance in my case PKPaymentButton and replace it with Button.
UPDATE-
I have achieved this by-
public class ApplePayButtonRenderer : Xamarin.Forms.Platform.iOS.ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var button = new PKPaymentButton(PKPaymentButtonType.Buy, PKPaymentButtonStyle.Black);
SetNativeControl(button);
}
}
}
Now I am trying to get its click into Xamarin.Forms
You could use Messaging Center to send message when you click the payment Button.
in Custom Renderer
var button = new PKPaymentButton(PKPaymentButtonType.Buy, PKPaymentButtonStyle.Black);
button.TouchUpInside += Button_TouchUpInside;
SetNativeControl(button);
private void Button_TouchUpInside(object sender, EventArgs e)
{
MessagingCenter.Send<Object>(this,"PayButtonClick");
}
in Forms
Add the following code to the constructor of the ContentPage which contains the Payment Button
public xxxPage()
{
InitializeComponent();
MessagingCenter.Subscribe<Object>(this, "PayButtonClick",(args)=> {
//do some thing you want
});
}

Create a class that inherits from textbox and can display calender on click

I am trying to build a calendar that pop up when you click on textbox (in asp.net);
For this task I build a new class that inherit from text box, and inside the new class constructor I put the calendar instance, but the thing is, when I inctance my new class I only get the textbox control and on click I do not get the calender.
Does anyone have an idea way or how can i fix this? my code is:
public class TextBoxCalendar : TextBox
{
public TextBoxCalendar( int id)
{
this.ID = id.toString();
initCalender();
}
private void initCalender()
{
CalendarExtender ce = new CalendarExtender();
ce.ID = "calender";
ce.TargetControlID = this.ID;
}
}
Aside from just initializing the control, you need to add it to the controls collection at some point during the rendering process:
protected override void Render(HtmlTextWriter writer)
{
CalendarExtender ce = new CalendarExtender();
ce.ID = "calender";
ce.TargetControlID = this.ID;
Controls.Add(ce);
//render the contents to the screen
RenderContents(writer);
}
You have to override OnInit method of TextBox and write the initCalender code inside it.
protected override void OnInit(EventArgs e) {
CalendarExtender ce = new CalendarExtender();
ce.ID = "calender";
ce.TargetControlID = this.ID;
}
You could use Jquery Datepicker.

asp.net 3.5 ListView

I have a webpage with filter selects at the top, a search button and a ListView with custom pager (witch is a Repeater witch contains LinkButtons with page numbers) at the bottom.
When I select filters and click the search button, I put the results in a List<> and DataBinding them at ListView. The function witch returns the results has two properties that are StartIndex and PageSize. So when I click a page I call again the function with new PageIndex. Sometimes the results need more columns from the ListView.
So I create two classes (ResultsLayoutTemplate.cs, ResultsItemTemplate.cs) to design the layout for ListView.
The problem is when I select a page (custom pager of ListView) whitch the results need more columns to ListView, the header of table does not change the columns and keeps the previous page header design. Lines have the right columns.
For example in first page ListView has 8 columns and in second page ListView must have 13 columns. But it keeps 8 columns for the header. The same happen when the third page need 8 columns it appears 13 from the previous page. The problem is only on the header.
Here's the code.
protected void ListView1_LayoutCreated(object sender, EventArgs e)
{
results = Session["results"] as List<Res>;
if (results.Count > 0)
{
Session["columns"] = results.Max(i => i.columns.Count);
}
ListView lv = sender as ListView;
ListView1.LayoutTemplate = new ResultsLayoutTemplate((int)Session["columns"]);
ListView1.ItemTemplate = new ResultsItemTemplate((int)Session["columns"]);
ListView1.AlternatingItemTemplate = new AlterResultsItemTemplate((int)Session["columns"]);
Control newlayoutContainer = new Control();
lv.LayoutTemplate = new ResultsLayoutTemplate((int)Session["columns"]);
lv.LayoutTemplate.InstantiateIn(newlayoutContainer);
var usercontrol = newlayoutContainer.Controls[0];
usercontrol.ID = "MyLayout";
lv.Controls.Add(newlayoutContainer);
}
protected void Page_PreRender(object sender, EventArgs e)
{
int num;
bool isNum = Int32.TryParse(Session["page"].ToString(), out num);
if ((Int32.Parse(Session["page"].ToString()) > 0) && (isNum))
{
results = Session["results"] as List<Res>;
Session["platos"] = results.Max(i => i.quadruplette.Count);
ListView1.Items.Clear();
ListView1.ItemTemplate = new ResultsItemTemplate((int)Session["columns"]);
ListView1.AlternatingItemTemplate = new AlterResultsItemTemplate((int)Session["columns"]);
ListView1.DataSource = results;
ListView1.DataBind();
}
}
protected void lbPage_Click(object sender, EventArgs e)
{
LinkButton btn = sender as LinkButton;
int num;
bool isNum = Int32.TryParse(btn.Text, out num);
if (isNum)
{
Session["page"] = btn.Text;
}
results = GetResults(Filters, (Int32.Parse(Session["page"].ToString()) - 1) * PageSize, PageSize);
Session["results"] = results;
Session["columns"] = results.Max(i => i.columns.Count);
}
}
not 100% sure i understand the question, but it sounds like you're trying to reinvent the wheel. Why not use the asp.net pagercontrol and just define the layout to fit what you need. Then use a sqldatasource control with a WHERE clause bound to your filter controls. Then bind that to the listview. Then have the sqldatasource rebind when you click the go button. any special operations that need to be performed before the bind actually happens can happen in the Selecting event.

Custom DataControlField Class

I did some search but nothing is really useful in my case.
I want to inherit the DataControlField (System.Web.UI.WebControls) to be able to carry two label controls and then I want to color the two labels to get some sort of conditional formatting, I've got the conditional formatting part but how can I customize this class?
Where in my class should I define the two label controls?
How would I override the CreateField method?
P.S: I know I can accomplish this, in XHTML Markup, but I have so many columns that it would not be appropriate to include those markups in the page markup. Therefore I'm doing that in the CodeBehind page.
EDIT:
public class MyField : DataControlField
{
public MyField()
{
}
protected override DataControlField CreateField()
{
// What to put here?
}
protected override void CopyProperties(DataControlField newField)
{
((CalendarField)newField).DataField = this.DataField;
((CalendarField)newField).DataFormatString = this.DataFormatString;
((CalendarField)newField).ReadOnly = this.ReadOnly;
base.CopyProperties(newField);
}
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
// Call the base method
base.InitializeCell(cell, cellType, rowState, rowIndex);
// Initialize the contents of the cell quitting if it is a header/footer
if (cellType == DataControlCellType.DataCell)
InitializeDataCell(cell, rowState);
}
protected virtual void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
{
}
}
See here. Hope this helps you.
public class MyField : DataControlField {
public MyField() { }
protected override DataControlField CreateField() {
// What to put here?
return new MyField();
}
protected override void CopyProperties(DataControlField newField) {
((CalendarField)newField).DataField = this.DataField;
((CalendarField)newField).DataFormatString = this.DataFormatString;
((CalendarField)newField).ReadOnly = this.ReadOnly;
base.CopyProperties(newField);
}
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
// Call the base method
base.InitializeCell(cell, cellType, rowState, rowIndex);
// Initialize the contents of the cell quitting if it is a header/footer
if (cellType == DataControlCellType.DataCell)
{
cell.DataBinding += new EventHandler(cell_DataBinding);
}
}
void cell_DataBinding(object sender, EventArgs e)
{
Control ctrl = sender as Control;
var container = ctrl.NamingContainer as IDataItemContainer;
// here what you would like to show in MyField
}
}

Resources