I will try that. I was sending my routine up, but it failed, so in the meantime I found online that if I initialized the values with m after the value it will make them decimal and not default to double, so I changed back to decimal.
The calculations are working and I just have some cleanup, so I can present tomorrow.
Thanks for your help.
Greg
// **************************************************
// Custom code for UD04Form
// Created: 2/14/2013 11:58:14 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinToolbars;
using Infragistics.Win.UltraWinDock;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnPartNum.Click += new System.EventHandler(this.btnPartNum_Click);
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
this.btnCalc.Click += new System.EventHandler(this.btnCalc_Click);
this.txtLocation.AfterExitEditMode += new System.EventHandler(this.txtLocation_AfterExitEditMode);
this.txtPartNum.AfterExitEditMode += new System.EventHandler(this.txtPartNum_AfterExitEditMode);
// End Wizard Added Custom Method Calls
//Hide the top Toolbar
baseToolbarsManager.Visible = false;
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.btnPartNum.Click -= new System.EventHandler(this.btnPartNum_Click);
this.btnClear.Click -= new System.EventHandler(this.btnClear_Click);
this.btnCalc.Click -= new System.EventHandler(this.btnCalc_Click);
this.txtLocation.AfterExitEditMode -= new System.EventHandler(this.txtLocation_AfterExitEditMode);
this.txtPartNum.AfterExitEditMode -= new System.EventHandler(this.txtPartNum_AfterExitEditMode);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void UD04Form_Load(object sender, EventArgs args)
{
// Add Event Handler Code
Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel TreeViewPanel = (Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)csm.GetNativeControlReference("d3a4fa73-e037-484e-8c93-1f930be38abf");
Epicor.Mfg.UI.App.UD04Entry.MainPanel MainPanel = (Epicor.Mfg.UI.App.UD04Entry.MainPanel)csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e274b");
TreeViewPanel.Dispose();
MainPanel.Dispose();
// intialize Values
numLaborRate.Value = .45m;
numScrapPct.Value = 1m;
numFreightPct.Value = 2m;
numResale.Value = 0m;
numMaterialCost.Value = 0m;
numLaborMinutes.Value = 0m;
numLaborCost.Value = 0m;
numLaborCost.Value = 0m;
numScrapCost.Value = 0m;
numFreightCost.Value = 0m;
numTotalCost.Value = 0m;
numGPDollars.Value = 0m;
numGPPct.Value = 0m;
numGPPerHr.Value = 0m;
//numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value; //+ (decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
}
private void txtPartNum_AfterExitEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
bool oBool = false;
DataSet ds = new DataSet();
ds = SearchFunctions.listLookup(oTrans, "PartAdapter", out oBool, false, "");
try
{
if(ds.Tables[0].Rows.Count > 0)
{
txtPartNum.Text = ds.Tables[0].Rows[0]["PartNum"].ToString();
txtPartNumDesc.Text = ds.Tables[0].Rows[0]["PartDescription"].ToString();
numLaborMinutes.Value = ds.Tables[0].Rows[0]["Number01"];
numResale.Value = ds.Tables[0].Rows[0]["UnitPrice"];
}
}
catch{}
}
private void btnPartNum_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
bool oBool = false;
DataSet ds = new DataSet();
ds = SearchFunctions.listLookup(oTrans, "PartAdapter", out oBool, true, "");
try
{
if(ds.Tables[0].Rows.Count > 0)
{
txtPartNum.Text = ds.Tables[0].Rows[0]["PartNum"].ToString();
txtPartNumDesc.Text = ds.Tables[0].Rows[0]["PartDescription"].ToString();
numLaborMinutes.Value = ds.Tables[0].Rows[0]["Number01"];
numResale.Value = ds.Tables[0].Rows[0]["UnitPrice"];
}
}
catch{}
}
private void txtLocation_AfterExitEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numLaborRate.Value = .45m;
if ((txtLocation.Text.IndexOf("FIN50") != -1) || (txtLocation.Text.IndexOf("FIN6") != -1) || (txtLocation.Text.IndexOf("FIN7") != -1))
{
numLaborRate.Value = .40m;
}
if (txtLocation.Text.IndexOf("FIN502") != -1)
{
numLaborRate.Value = .37m;
}
if (txtLocation.Text.IndexOf("FIN00") != -1)
{
numLaborRate.Value = .55m;
}
if (txtLocation.Text.IndexOf("FIN004") != -1)
{
numLaborRate.Value = .4m;
}
if (txtLocation.Text.IndexOf("FIN005") != -1)
{
numLaborRate.Value = .4m;
}
}
private void btnClear_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numLaborRate.Value = .45;
// intialize Values
numLaborRate.Value = .45m;
numScrapPct.Value = 1m;
numFreightPct.Value = 2m;
numResale.Value = 0m;
numMaterialCost.Value = 0m;
numLaborMinutes.Value = 0m;
numLaborCost.Value = 0m;
numLaborCost.Value = 0m;
numScrapCost.Value = 0m;
numFreightCost.Value = 0m;
numTotalCost.Value = 0m;
numGPDollars.Value = 0m;
numGPPct.Value = 0m;
numGPPerHr.Value = 0m;
}
private void btnCalc_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numScrapCost.Value = (decimal)numMaterialCost.Value * ((decimal)numScrapPct.Value / 100 );
numFreightCost.Value = (decimal)numMaterialCost.Value * ((decimal)numFreightPct.Value / 100);
numLaborCost.Value = (decimal)numLaborMinutes.Value * (decimal)numLaborRate.Value;
numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value +
(decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value + (decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
numGPDollars.Value = (decimal)numResale.Value - (decimal)numTotalCost.Value;
if ((decimal)numResale.Value > 0.0m)
{
numGPPct.Value = ((decimal)numGPDollars.Value / (decimal)numResale.Value * 100);
}
if ((decimal)numLaborMinutes.Value != 0m)
{
numGPPerHr.Value = (60/(decimal)numLaborMinutes.Value) * ((decimal)numResale.Value - (decimal)numTotalCost.Value);
}
}
}
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Sean McDaniel
Sent: Monday, February 25, 2013 4:09 PM
To: vantage@yahoogroups.com
Subject: RE: [Vantage] C# simple math - 905.700C
Sorry, had a moment :o)
Probably might try this:
numTotalCost.value = (double.Parse(numLaborCost.Value) + double.Parse(nummaterialCost.Value)).ToString();
________________________________
From: vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com> on behalf of Greg Payne
Sent: Mon 2/25/2013 2:43 PM
To: vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>
Subject: [Vantage] C# simple math - 905.700C
I am trying to write a simple margin calculator on the UD04 screen. I have numeric fields all set as double ( I also tried decimal).
I have several inputs and then 4 calculations on submit. it fails with a casting exception and after trying to learn C# on the fly today I am still clueless.
Can I get a simple example of how to make the addition below work?
Thanks
Greg Payne
numMaterialCost.Value = 10;
numLaborCost.Value = 4.5;
numTotalCost.Value = (double)numLaborCost.Value + (double)numMaterialCost.Value;
________________________________
CONFIDENTIALITY NOTICE
The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.
"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
________________________________
CONFIDENTIALITY NOTICE
The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.
"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."
[Non-text portions of this message have been removed]
The calculations are working and I just have some cleanup, so I can present tomorrow.
Thanks for your help.
Greg
// **************************************************
// Custom code for UD04Form
// Created: 2/14/2013 11:58:14 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinToolbars;
using Infragistics.Win.UltraWinDock;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnPartNum.Click += new System.EventHandler(this.btnPartNum_Click);
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
this.btnCalc.Click += new System.EventHandler(this.btnCalc_Click);
this.txtLocation.AfterExitEditMode += new System.EventHandler(this.txtLocation_AfterExitEditMode);
this.txtPartNum.AfterExitEditMode += new System.EventHandler(this.txtPartNum_AfterExitEditMode);
// End Wizard Added Custom Method Calls
//Hide the top Toolbar
baseToolbarsManager.Visible = false;
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.btnPartNum.Click -= new System.EventHandler(this.btnPartNum_Click);
this.btnClear.Click -= new System.EventHandler(this.btnClear_Click);
this.btnCalc.Click -= new System.EventHandler(this.btnCalc_Click);
this.txtLocation.AfterExitEditMode -= new System.EventHandler(this.txtLocation_AfterExitEditMode);
this.txtPartNum.AfterExitEditMode -= new System.EventHandler(this.txtPartNum_AfterExitEditMode);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void UD04Form_Load(object sender, EventArgs args)
{
// Add Event Handler Code
Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel TreeViewPanel = (Epicor.Mfg.UI.FrameWork.EpiTreeViewPanel)csm.GetNativeControlReference("d3a4fa73-e037-484e-8c93-1f930be38abf");
Epicor.Mfg.UI.App.UD04Entry.MainPanel MainPanel = (Epicor.Mfg.UI.App.UD04Entry.MainPanel)csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e274b");
TreeViewPanel.Dispose();
MainPanel.Dispose();
// intialize Values
numLaborRate.Value = .45m;
numScrapPct.Value = 1m;
numFreightPct.Value = 2m;
numResale.Value = 0m;
numMaterialCost.Value = 0m;
numLaborMinutes.Value = 0m;
numLaborCost.Value = 0m;
numLaborCost.Value = 0m;
numScrapCost.Value = 0m;
numFreightCost.Value = 0m;
numTotalCost.Value = 0m;
numGPDollars.Value = 0m;
numGPPct.Value = 0m;
numGPPerHr.Value = 0m;
//numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value; //+ (decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
}
private void txtPartNum_AfterExitEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
bool oBool = false;
DataSet ds = new DataSet();
ds = SearchFunctions.listLookup(oTrans, "PartAdapter", out oBool, false, "");
try
{
if(ds.Tables[0].Rows.Count > 0)
{
txtPartNum.Text = ds.Tables[0].Rows[0]["PartNum"].ToString();
txtPartNumDesc.Text = ds.Tables[0].Rows[0]["PartDescription"].ToString();
numLaborMinutes.Value = ds.Tables[0].Rows[0]["Number01"];
numResale.Value = ds.Tables[0].Rows[0]["UnitPrice"];
}
}
catch{}
}
private void btnPartNum_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
bool oBool = false;
DataSet ds = new DataSet();
ds = SearchFunctions.listLookup(oTrans, "PartAdapter", out oBool, true, "");
try
{
if(ds.Tables[0].Rows.Count > 0)
{
txtPartNum.Text = ds.Tables[0].Rows[0]["PartNum"].ToString();
txtPartNumDesc.Text = ds.Tables[0].Rows[0]["PartDescription"].ToString();
numLaborMinutes.Value = ds.Tables[0].Rows[0]["Number01"];
numResale.Value = ds.Tables[0].Rows[0]["UnitPrice"];
}
}
catch{}
}
private void txtLocation_AfterExitEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numLaborRate.Value = .45m;
if ((txtLocation.Text.IndexOf("FIN50") != -1) || (txtLocation.Text.IndexOf("FIN6") != -1) || (txtLocation.Text.IndexOf("FIN7") != -1))
{
numLaborRate.Value = .40m;
}
if (txtLocation.Text.IndexOf("FIN502") != -1)
{
numLaborRate.Value = .37m;
}
if (txtLocation.Text.IndexOf("FIN00") != -1)
{
numLaborRate.Value = .55m;
}
if (txtLocation.Text.IndexOf("FIN004") != -1)
{
numLaborRate.Value = .4m;
}
if (txtLocation.Text.IndexOf("FIN005") != -1)
{
numLaborRate.Value = .4m;
}
}
private void btnClear_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numLaborRate.Value = .45;
// intialize Values
numLaborRate.Value = .45m;
numScrapPct.Value = 1m;
numFreightPct.Value = 2m;
numResale.Value = 0m;
numMaterialCost.Value = 0m;
numLaborMinutes.Value = 0m;
numLaborCost.Value = 0m;
numLaborCost.Value = 0m;
numScrapCost.Value = 0m;
numFreightCost.Value = 0m;
numTotalCost.Value = 0m;
numGPDollars.Value = 0m;
numGPPct.Value = 0m;
numGPPerHr.Value = 0m;
}
private void btnCalc_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
numScrapCost.Value = (decimal)numMaterialCost.Value * ((decimal)numScrapPct.Value / 100 );
numFreightCost.Value = (decimal)numMaterialCost.Value * ((decimal)numFreightPct.Value / 100);
numLaborCost.Value = (decimal)numLaborMinutes.Value * (decimal)numLaborRate.Value;
numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value +
(decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
numTotalCost.Value = (decimal)numLaborCost.Value + (decimal)numMaterialCost.Value + (decimal)numScrapCost.Value + (decimal)numFreightCost.Value;
numGPDollars.Value = (decimal)numResale.Value - (decimal)numTotalCost.Value;
if ((decimal)numResale.Value > 0.0m)
{
numGPPct.Value = ((decimal)numGPDollars.Value / (decimal)numResale.Value * 100);
}
if ((decimal)numLaborMinutes.Value != 0m)
{
numGPPerHr.Value = (60/(decimal)numLaborMinutes.Value) * ((decimal)numResale.Value - (decimal)numTotalCost.Value);
}
}
}
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Sean McDaniel
Sent: Monday, February 25, 2013 4:09 PM
To: vantage@yahoogroups.com
Subject: RE: [Vantage] C# simple math - 905.700C
Sorry, had a moment :o)
Probably might try this:
numTotalCost.value = (double.Parse(numLaborCost.Value) + double.Parse(nummaterialCost.Value)).ToString();
________________________________
From: vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com> on behalf of Greg Payne
Sent: Mon 2/25/2013 2:43 PM
To: vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>
Subject: [Vantage] C# simple math - 905.700C
I am trying to write a simple margin calculator on the UD04 screen. I have numeric fields all set as double ( I also tried decimal).
I have several inputs and then 4 calculations on submit. it fails with a casting exception and after trying to learn C# on the fly today I am still clueless.
Can I get a simple example of how to make the addition below work?
Thanks
Greg Payne
numMaterialCost.Value = 10;
numLaborCost.Value = 4.5;
numTotalCost.Value = (double)numLaborCost.Value + (double)numMaterialCost.Value;
________________________________
CONFIDENTIALITY NOTICE
The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.
"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
________________________________
CONFIDENTIALITY NOTICE
The information contained in this communication, including attachments, is privileged and confidential. It is intended only for the exclusive use of the addressee. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us at 727-578-6280 and immediately delete the communication.
"This (document/presentation) may contain technical data as defined in the International Traffic In Arms Regulations (ITAR) 22 CFR 120.10. Export of this material is restricted by the Arms Export Control Act (22 U.S.C. 2751 et seq.) and may not be exported to foreign persons without prior approval form the U.S. Department of State."
[Non-text portions of this message have been removed]