on 04-22-2011 2:04 AM
Hello:
Need this done as soon as possible. Here is the logic.
So get the document.
and set the line, delete the line
and add a special line with some text.
Whole thing seems pretty simple. If there are already one line of text line there it will not add another one. I don't know why. Any ideas?
For example.
if I have line 0 and LIne 1. Both of which I need to replace.
When the code go through the first time, It is correct. Line 0 is not a text line.
Next go through. However. Line 1 is now deleted, but so is the line text from line 0 instead it is been replaced by LIne 1's text.
Same thing if it is multiple lines.
When it create a new text line it seems always somehow delete the previous text line.
if (Global.oDoc.GetByKey(Docentry) != true)
{
Global.ocompany.GetLastError(out errcode, out errtext);
return false;
}
Global.orecord2.DoQuery("select count(*) as 'count' from qut1 where docentry = "+Docentry +" and linenum < "+linenum);
linenum2 = System.Convert.ToInt16(Global.orecord2.Fields.Item("count").Value.ToString());
Global.oDoc.Lines.SetCurrentLine(linenum2);
Global.oDoc.Lines.Delete();
//Global.oDoc.SpecialLines.Add();
Global.oDoc.SpecialLines.LineType = SAPbobsCOM.BoDocSpecialLineType.dslt_Text;
Global.oDoc.SpecialLines.LineText = "Line: " + linenum + " Itemcode : " + itemcode.ToString() + " Quantity(" + quantity + ")/Price(" + price + ") Was Removed Because " + message.ToString();
Global.oDoc.SpecialLines.AfterLineNumber = linenum2 - 1;
Global.oDoc.SpecialLines.Add();
if (Global.oDoc.Update() != 0)
{
Global.ocompany.GetLastError(out errcode, out errtext);
errtext = "Can Not Add Text Line " + errtext;
return false;
}
Edited by: Bo Peng on Apr 22, 2011 3:05 AM
I think I got this solved, need to add the special line and then set the current lines before specify the current line details.
f (Global.oDoc.GetByKey(Docentry) != true)
{
Global.ocompany.GetLastError(out errcode, out errtext);
return false;
}
Global.orecord2.DoQuery("select count(*) as 'count' from qut1 where docentry = "+Docentry +" and linenum < "+linenum);
linenum2 = System.Convert.ToInt16(Global.orecord2.Fields.Item("count").Value.ToString());
Global.oDoc.Lines.SetCurrentLine(linenum2);
Global.oDoc.Lines.Delete();
Global.orecord2.DoQuery("select count(*) as 'count' from qut10 where docentry = " + Docentry);
Global.oDoc.SpecialLines.Add();
Global.oDoc.SpecialLines.SetCurrentLine(System.Convert.ToInt16(Global.orecord2.Fields.Item("count").Value.ToString()));
Global.oDoc.SpecialLines.LineType = SAPbobsCOM.BoDocSpecialLineType.dslt_Text;
Global.oDoc.SpecialLines.LineText = "Line: " + linenum + " Itemcode : " + itemcode.ToString() + " Quantity(" + quantity + ")/Price(" + price + ") Was Removed Because " + message.ToString();
Global.oDoc.SpecialLines.AfterLineNumber = linenum2 - 1;
if (Global.oDoc.Update() != 0)
{
Global.ocompany.GetLastError(out errcode, out errtext);
errtext = "Can Not Add Text Line " + errtext;
return false;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
9 | |
8 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.