Skip to main content

Save value to table from run time control in MSD Axapta

Save value to table from run time control in Axapta

 void SaveAll()  
 {  
 int i;  
 int a;  
 int c;  
 boolean flg=true,flg1=true;  
 FormStringControl FormStr1;  
 FormStringControl formStringControl1;  
 FormGroupControl formGroupControl1;  
 str oldqid,tid,oldtxt;  
 FormTabControl formTabControl1;  
 FormTabPageControl formTabPageControl1;  
 FormBuildTabControl formBuildTabControl;  
 FormBuildGroupControl formBuildGroupControl;  
 FormBuildTabPageControl formBuildTabPageControl;  
 FormBuildStringControl formBuildStringControl;  
 _TestResult _testResult1;  
 str s,fcname;  
 formControl fc,fc1;  
 boolean f=false;  
 FormStringControl control = element.controlCallingMethod();  
 Integer yy,x;  
 int cnt=0,cnt1=0;  
 str id,AnsTxtGrid;  
 int t;  
 int rcnt,tmpcnt,rowid1;  
 str 10 AnsTxt;  
 str lable;  
 DictTable dictTable;  
 TableId tableID;  
 object formRunCaller;  
 TestId testId2;  
 ;  
 idrow=1;  
 rowid1=1;  
 //tmpcnt=16;  
 formRunCaller = element.args().caller();  
 testId2=formRunCaller.MethodA();  
 i = 1;  
 x=12000;  
 for(yy = x;yy <20000;yy++)  
  { fc = element.Control(yy);  
 if (fc)  
  {  
 while select * from _Question where (_Question.TestID==testid2) //order by RecId  
 {  
 while select * from tmpControlId where tmpControlId.ControlID==int2str(yy)  
  {  
 flg=false;  
  }  
 //select * from _TestResult; _TestResult.QId = _Question.QId;  
  _TestResult.Text= ""; a = 1;  
  while select * from answer where answer.GroupId == _Question.GroupId  
  {  
  if(_Question.ControlId == QuestionControlInputType::CheckBox)  
  {  
 }  
  if(_Question.ControlId == QuestionControlInputType::RadioButton)  
 {  
 }  
 a = a+1;  
  }  
  if(_Question.ControlId == QuestionControlInputType::Text)  
 {  
 // formGroupControl if(fc.name()=="QuestionStr")  
 {  
 // cnt=cnt+1;  
  // cnt1=i-12;  
 if (flg1==true)  
 {  
 fc = element.Control(yy);  
 //formBuildStringControl = formBuildTabPageControl.controlNum(i);  
 // lable =formBuildStringControl.name();  
  _TestResult.GroupId ="0";  
  _TestResult.RowId = "0";  
  // if(cnt==cnt1)  
 ///ss  
  while select _testResult1 where _testResult1.QId ==_Question.QId && _testResult1.TestId==testid2 {  
  flg=false;  
 }  
 if (flg==false)  
  {  
 flg=true;  
  }  
  else if(flg==true)  
  {  
 // _testResult.ItemID=inventTrans1.ItemId;  
 // _testResult.ItemName=InventTable::find(inventTrans1.ItemId).ItemName;  
 AnsTxt=fc.valueStr();  
  _TestResult1.Text=AnsTxt;  
 _TestResult1.QId = _Question.QId; _TestResult1.TestId=testId2;  
 //"1";  
 _TestResult1.GroupId ="0";  
 _TestResult1.RowId = "0";  
  _testResult1.insert();  
 tmpControlId.ControlID=int2str(yy);  
  tmpControlId.Qid=_question.QId;  
  tmpControlId.insert(); } flg=true;  
 } }  
  else  
  { flg1=true;  
 } ///ss  
 // _testResult.insert();  
 }  
 else if (_Question.ControlId == QuestionControlInputType::Grid)  
 {  
 // rcnt=rcnt+1  
 info(_testGridResult1.Row); fcname=fc.name(); if(substr(fc.name(),12,16)=="Col1")  
  {  
  idrow=rowid1;  
 _TestGridResult1.Column="1";  
  fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  rowid1=idrow+1;  
 }  
  else if(substr(fc.name(),12,16)=="Col2")  
 { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="2";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
  else if(substr(fc.name(),12,16)=="Col3")  
  {  
  fc = element.Control(yy);  
  _TestGridResult1.Column="3";  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col4")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="4";  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col5")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="5";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col6")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="6";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  }  
  else if(substr(fc.name(),12,16)=="Col7")  
 {  
  fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="7";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col8")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="8";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col9")  
  { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="9";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col10")  
  {  
 fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="10";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 } //ss else if(substr(fc.name(),12,16)=="Col11")  
  { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="11";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col12")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="12";  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
  else if(substr(fc.name(),12,16)=="Col13")  
 { fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="13";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 } else if(substr(fc.name(),12,16)=="Col14")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="14";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col15")  
 { fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="15";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col16")  
 { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="16";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert(); }  
 //rowid=rowid1; //ss i = i+1; } i = i+1;  
 }  
  }  
 }  
 info ("Record Saved Success");  
 }  

Popular posts from this blog

Code to get Invoice settlement data for customer in ax 2012

This is simple Code to get Invoice settlement amount data for customer payment in ax 2012. This data is after posting of data. select sum(SettleAmountCur) from custSettlement where custSettlement.TransRecId == custtrans.RecId If you want get settlement amount before posting than you can refer spectrans table.The table SpecTrans contains all the transactions marked for settlement for payment journal. while select spectrans join custtransopen join custtrans where spectrans.SpecCompany == ledgerjournaltrans.DataAreaId && spectrans.SpecTableId == ledgerjournaltrans.TableId && spectrans.SpecRecId == ledgerjournaltrans.RecId && spectrans.RefCompany == custtranssopen.DataAreaId && spectrans.RefTableId == custtranssopen.TableId && spectrans.RefRecId == custtranssopen.RecId && custtransopen.RefRecId == custtrans.RecId && custtransopen.AccountNum == custtrans.AccountNum { info...

Cancel Deliver Remainder through X++ (Sales Order ) DAX

 To Cancel Deliver Remainder through X++ you can use below code sample. Thanks. static void _CancelDeliverRemainder_Sales(Args _args) {     SalesLine SalesLine = SalesLine::find('SO0013', true);     ;           if (SalesLine)     {         // Set remaining inventory Qty to zero         SalesLine.RemainInventPhysical  = 0;           // Set remaining physical Qty to zero         SalesLine.RemainSalesPhysical   = 0;                                   // We have to cancel the SalesLine                  SalesLine.PurchStatus           = PurchStatus::Canceled;                    SalesLine.update();         ...

Add Miscellaneous Charges to a Purchase Order in MSD Axapta

Add Miscellaneous Charges to a Purchase Order To add miscellaneous charges to a purchase order, follow these steps: 1. Click Accounts payable > Purchase Order Details. 2. Select a purchase order and then click Posting > Invoice. 3. Enter or select an invoice. 4. Select which miscellaneous charges transactions to add, change, or delete: a. To add, change, or delete miscellaneous charges transactions for the invoice header, click Setup > Misc. charges on the Overview tab. b. To add, change, or delete miscellaneous charges transactions for an invoice line, click the Lines tab, and then click Misc. charges. c. To add, change, or delete miscellaneous charges for the invoice header for a summary invoice that is selected on the Overview tab, click the Purchases tab, and then click Setup > Misc. charges. 5. In the Misc. charges transactions form, enter the miscellaneous charge from the invoice that you received from your vendor. 6. If necessary, you can click ...