Direktanspringen gen. LS

Roland Gerweck

Hallo Marco,

Ich möchte nun nach meiner Routine für das Lieferschein-Erstellen aus meiner angedockten Funktion zur Kommissionierliste nach der erfolgreichen Erstellung des Lieferscheines , daß mein AddOn dann direkt den zugehörigen generierten Lieferschein-Beleg öffnet:





using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using System.ComponentModel;
using System.Diagnostics;
using SwissAddonFramework.UI.Components;
using SwissAddonFramework.UI.EventHandling.ItemEvents;
using SwissAddonFramework.UI.EventHandling.MenuEvents;
using SwissAddonFramework.DI;



namespace RGS_INVTRA
{
class Form3Logic
{
protected Form form;

public Form3Logic(Form form)
{
this.form = form;
ButtonErstellen();

}

public void ButtonErstellen()
{
Button btn = Button.CreateNew("lsge");
btn.Value = "LS-Generierung";
btn.Width = 100;
btn.Left = 180;
btn.Top = 366;
btn.Height = 19;
form.AddItem(btn);
btn.AddHandler_ItemPressed(ModeComponent.FormModes.ALL, DelNoteErstellen);
form.Update();
}

public void DelNoteErstellen(ItemEvent e)
{
DateTime oDate = DateTime.Now;

string cuno = "";
string comm = TextEdit.GetFromUID(form, "6").Value;
int picknr = int.Parse(comm);
string WhsCode = "";
string Artikel = "";
string origorno = "";
int origornov = 0;
int origlino = 0;
int lineno = 0;
double quanv = 0;
int quann = 0;


Matrix m = Matrix.GetFromUID(form, "11");
form.Freeze(true);

SAPbobsCOM.Documents oDlvNote;
oDlvNote = (SAPbobsCOM.Documents)SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);

SAPbobsCOM.Documents oOrder;
oOrder = (SAPbobsCOM.Documents)SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

SAPbobsCOM.PickLists oPickList;
oPickList = (SAPbobsCOM.PickLists)SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPickLists);

oPickList.GetByKey(picknr);

SAPbobsCOM.SerialNumbers srls2;
SAPbobsCOM.SerialNumbers srls1;




for (int i = 0; i <= m.Rows.Count - 1; i++) // Matrixhandling mit Spaltenbearbeitung
{

oPickList.Lines.SetCurrentLine(i);

lineno = int.Parse(((SAPbouiCOM.EditText)m.Columns["0"].Cells.Specific).Value);
cuno = ((SAPbouiCOM.EditText)m.Columns["17"].Cells.Specific).Value;
Artikel = ((SAPbouiCOM.EditText)m.Columns["12"].Cells.Specific).Value;
origorno = ((SAPbouiCOM.EditText)m.Columns["18"].Cells.Specific).Value;
WhsCode = ((SAPbouiCOM.EditText)m.Columns["10"].Cells.Specific).Value;
lineno = lineno - 1;
string querys = "SELECT OrderLine, PickQtty from PKL1 WHERE AbsEntry = " + comm + " AND PickEntry = " + lineno;
using (System.Data.SqlClient.SqlDataReader sqlReaders = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(querys))
{
if (sqlReaders.Read())
{
origlino = sqlReaders.GetInt32(0);
quanv = Decimal.ToDouble((Decimal)sqlReaders.GetSqlDecimal(1));
quann = Decimal.ToInt32((Decimal)sqlReaders.GetSqlDecimal(1));
}
}

string queryx = "SELECT DocEntry FROM ORDR WHERE DocNum = " + origorno;
using (System.Data.SqlClient.SqlDataReader sqlReaderx = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(queryx))
{
if (sqlReaderx.Read())
{
origornov = sqlReaderx.GetInt32(0);
}
}

oOrder.GetByKey(origornov);

int sern = 0;
string intserie = "";

string cunobase = oOrder.CardCode;
oDlvNote.CardCode = cuno;
oDlvNote.DocDueDate = oDate;
oDlvNote.Lines.ItemCode = Artikel;
oDlvNote.Lines.WarehouseCode = WhsCode;


oDlvNote.Lines.BaseEntry = origornov;
oDlvNote.Lines.BaseType = 17;
oDlvNote.Lines.BaseLine = origlino;



if (i < m.Rows.Count - 1)
{
for (int j = 0; j < quann; j++)
{
string sernst = sern.ToString();
string intsern = "";

string queryv = "Select Top 1 SysSerial, IntrSerial From OSRI Where ItemCode = '" + Artikel + "' AND U_KDAuftrag = '" + origorno + "' AND U_KDAuftrPos = '" + origlino + "' AND WhsCode = '" + WhsCode + "' AND U_KommListe = '" + comm + "' AND Status = '0' AND SysSerial > '" + sernst + "'";
using (System.Data.SqlClient.SqlDataReader sqlReaderv = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(queryv))
{
if (sqlReaderv.Read())
{
sern = sqlReaderv.GetInt32(0);
intsern = sqlReaderv.GetString(1);
sernst = sern.ToString();


srls1 = oDlvNote.Lines.SerialNumbers;
srls1.InternalSerialNumber = intsern;
srls1.SystemSerialNumber = sern;
if (srls1.InternalSerialNumber != "")
{
if (j < quann - 1) // Die SerialNumbers.Add()-Methode nicht für die letzte Serien-
{ // nummer durchlaufen
srls1.Add();
}
}

}

}
}
oDlvNote.Lines.Add();
}



if (i == m.Rows.Count - 1)
{
for (int k = 0; k < quann; k++)
{
string sernst1 = sern.ToString();
string intsern1 = "";

string queryv1 = "Select Top 1 SysSerial, IntrSerial From OSRI Where ItemCode = '" + Artikel + "' AND U_KDAuftrag = '" + origorno + "' AND U_KDAuftrPos = '" + origlino + "' AND WhsCode = '" + WhsCode + "' AND U_KommListe = '" + comm + "' AND Status = '0' AND SysSerial > '" + sernst1 + "'";
using (System.Data.SqlClient.SqlDataReader sqlReaderv = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(queryv1))
{
if (sqlReaderv.Read())
{
sern = sqlReaderv.GetInt32(0);
intsern1 = sqlReaderv.GetString(1);
sernst1 = sern.ToString();


srls2 = oDlvNote.Lines.SerialNumbers;
srls2.InternalSerialNumber = intsern1;
srls2.SystemSerialNumber = sern;

if (srls2.InternalSerialNumber != "")
{
if (k < quann - 1) // Die SerialNumbers.Add()-Methode nicht für die letzte Serien-
{ // nummer durchlaufen
srls2.Add();
}
}

}
}
}
oDlvNote.Add();
string errtext = SwissAddonFramework.B1Connector.GetB1Connector().Company.GetLastErrorDescription();

SwissAddonFramework.Messaging.StatusBar.WriteSucess("Es wurde verarbeitet" + errtext);

}

}

e.Form.Freeze(false);

}
}

}







Was wäre die Idee zum Direktaufruf des Lieferscheines nach dem oDlvNote.Add(); - Aufruf ??




Gruss,

Roland

Marco Schweighauser

Hallo Roland,

das ganze kannst du über folgende UI Steuerung erledigen:

1. Lieferscheinformular aufmachen (mit MenuClick)
2. Lieferscheinformular in den Suchmodus setzen
3. Nummer einsetzen und OK drücken

Lieferscheinformular öffnen:


deliveryCode = ""; // Delivery code
Form.AddHandler_Load("140", ModeComponent.FormModes.ALL, OpenDelivery);
MenuItem.GetFromUID("2051").Activate(); // Open delivery form


FormLoad-Handler, welcher denn entsprechenden Beleg öffnet.


private string deliveryCode;
private void OpenDelivery(FormLoad ev)
{
try
{
Form.RemoveHandler("140", ModeComponent.FormModes.ALL, OpenDelivery);
ev.Form.Select();
ev.Form.Mode = ModeComponent.FormModes.FIND;
((TextEdit)ev.Form.Items["8"]).Value = deliveryCode;
ev.Form.Items["1"].Click(Item.ClickType.Regular);
}
catch (Exception ex)
{
SwissAddonFramework.Messaging.StatusBar.WriteError("Can not open delivery. Error: " + ex.Message);
}
}


Gruss

Marco
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post