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

strScan and Find a first occurrence of a string in a string using x++

strScan (Find a first occurrence of a string in a string) info("int strScan(str _text1,str _text2,int _position,int _number)"); info("Searches a text string for the occurrence of another string."); info("_text1 - The text string to search."); info("_text2 - The string to find."); info("_position - The position at which the search should start."); info("_number - The number of characters that should be searched."); info(int2str(strScan("ABCDEFGHIJ","DE",1,10)));

Get record from table on the basis of field id in Microsoft dynamics axapta x++

How to Get record from table on the basis of field id in dynamics axapta x++. just try following code in job to understand better way. emplTable emplTable; FieldId fieldId; ; fieldId = fieldNum(emplTable, Emplid); select emplTable; info(emplTable.(fieldId)); select emplTable where emplTable.(fieldId) == '1101'; info(emplTable.Name);

Code to get customer Primary Address in Ax 2012

Below Code to get customer Primary Address in Ax 2012. CustTable custTable_P; DirPartyTable dirPartyTable_P; DirPartyLocation dirPartyLocation_P; DirPartyLocationRole dirPartyLocationRole_P; LogisticsLocation logisticsLocation_P; LogisticsLocationRole logisticsLocationRole_P; LogisticsPostalAddress logisticsPostalAddress_P; LogisticsPostalAddress primaryAddress_P; while select custTable_P where custTable_P.AccountNum =='ED_01029' join dirPartyTable_P where dirPartyTable_P.RecId == custTable_P.Party join dirPartyLocation_P where dirPartyLocation_P.Party == custTable_P.Party && dirPartyLocation_P.IsPrimary==NoYes::Yes join dirPartyLocationRole_P where dirPartyLocationRole_P.PartyLocation == dirPartyLocation_P.RecId join logisticsLocationRole_P where logisticsLocationRole_P.RecId == dirPartyLocationRole