class NEC_MultiCount
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormEventHandler(formStr(WHSWorkLineCycleCount), FormEventType::Initialized)]
public static void WHSWorkLineCycleCount_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormGridControl grid = sender.control(sender.controlId(formControlStr(WHSWorkLineCycleCount,Grid))) as FormGridControl;
grid.multiSelect(true);
grid.showRowLabels(true);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(WHSWorkTableListPage, AcceptCount), FormControlEventType::Clicked)]
public static void AcceptCount_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource whsWorkTable_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkTable)) as FormDataSource; //Form
// FormDataSource whsWorkLine_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkLine)) as FormDataSource; //Form
WHSWorkTable rec;
WHSWorkLineCycleCountForm whsWorkLineCycleCountForm;
WHSWorkLineCycleCount whsWorkLineCycleCount;
WHSWorkExecute workExecute = new WHSWorkExecute();
WHSWorkTable workTable;// = WHSWorkTable::find(_whsWorkLineCycleCount.WorkId);
WHSWorkLine workLine;// = WHSWorkLine::find(whsWorkLineCycleCount.WorkId, _whsWorkLineCycleCount.LineNum);
InventDim inventDim;// = InventDim::find(whsWorkLineCycleCount.InventDimId);
WHSWorkId workId;
WHSUserId userId;// = workLine.UserId ? workLine.UserId : WHSParameters::find().GenericWorkUserId;
int i;
JournalNameId journalNum;
for (rec = whsWorkTable_ds.getFirst(true) ? whsWorkTable_ds.getFirst(true) : whsWorkTable_ds.cursor();
rec;
rec = whsWorkTable_ds.getNext())
{
select workTable where workTable.WorkId == rec.WorkId
join workLine
where workLine.WorkId == workTable.WorkId;
if( workLine.WorkId)
{
userId = workLine.UserId ? workLine.UserId : WHSParameters::find().GenericWorkUserId;
if (!userId)
{
throw error("@WAX2758");
}
while select whsWorkLineCycleCount
where whsWorkLineCycleCount.WorkId == workLine.WorkId
&& whsWorkLineCycleCount.LineNum == workLine.LineNum
{
if(whsWorkLineCycleCount.RecId)
{
journalNum = whsWorkLineCycleCount.displayInventJournalId();
//info(strFmt("%1",journalNum));
if(!journalNum)
{
ttsbegin;
inventDim = InventDim::find(whsWorkLineCycleCount.InventDimId);
if (whsWorkLineCycleCount.QtyCounted != whsWorkLineCycleCount.QtyExpected)
{
WHSInventAdjustmentCreateParameters params = WHSInventAdjustmentCreateParameters::construct();
params.WorkUserId = userId;
params.ItemId = whsWorkLineCycleCount.ItemId;
params.InventDim = inventDim;
params.AdjustmentQty = whsWorkLineCycleCount.QtyCounted - whsWorkLineCycleCount.QtyExpected;
params.AdjustmentUnit = InventTableModule::find(whsWorkLineCycleCount.ItemId, ModuleInventPurchSales::Invent).UnitId;
params.WmsLocationId = workLine.wmsLocationId;
params.InventLocationId = workTable.InventLocationId;
params.AdjustmentTypeCode = WHSParameters::find().CycleCountAdjustmentTypeCode;
params.LicensePlateId = inventDim.LicensePlateId;
params.WorkTransType = WHSWorkTransType::CycleCountAccepted;
params.WorkType = WHSWorkType::Count;
params.WorkCreatedBy = HcmWorker::findByPerson(DirPersonUser::find(curUserId()).PersonParty).RecId;
WHSInventAdjustmentCreate createAdj = WHSInventAdjustmentCreate::newFromParams(params);
createAdj.run();
workId = createAdj.createdWorkId();
}
whsWorkLineCycleCount.AcceptReject = WHSAcceptReject::Accept;
whsWorkLineCycleCount.CycleCountReconcile = NoYes::Yes;
if(workId)
{
whsWorkLineCycleCount.AdjustmentWorkId = workId;
}
else
{
whsWorkLineCycleCount.AdjustmentWorkId = ' ';
}
whsWorkLineCycleCount.selectForUpdate(true);
whsWorkLineCycleCount.update();
workExecute.updateWorkStatusCycleCount(rec.WorkId);
ttscommit;
}
}
}
}
++i;
}
if (i == 1)
{
WHSWorkTable_ds.research(true);
}
else
{
WHSWorkTable_ds.executeQuery();
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(WHSWorkTableListPage, RejectCount), FormControlEventType::Clicked)]
public static void RejectCount_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource whsWorkTable_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkTable)) as FormDataSource; //Form
// FormDataSource whsWorkLine_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkLine)) as FormDataSource; //Form
WHSWorkTable rec;
WHSWorkLineCycleCountForm whsWorkLineCycleCountForm;
WHSWorkTable workTable;
WHSWorkLine workLine;
WHSWorkLineCycleCount whsWorkLineCycleCount;
WHSWorkExecute workExecute = new WHSWorkExecute();
int i;
JournalNameId journalNum;
for (rec = whsWorkTable_ds.getFirst(true) ? whsWorkTable_ds.getFirst(true) : whsWorkTable_ds.cursor();
rec;
rec = whsWorkTable_ds.getNext())
{
while select workTable where workTable.WorkId == rec.WorkId
join workLine
where workLine.WorkId == workTable.WorkId
join whsWorkLineCycleCount
where whsWorkLineCycleCount.WorkId == workLine.WorkId
&& whsWorkLineCycleCount.LineNum == workLine.LineNum
{
ttsbegin;
if(whsWorkLineCycleCount.WorkId)
{
journalNum = whsWorkLineCycleCount.displayInventJournalId();
if(!journalNum)
{
whsWorkLineCycleCount.AcceptReject = WHSAcceptReject::Reject;
whsWorkLineCycleCount.CycleCountReconcile = NoYes::Yes;
whsWorkLineCycleCount.AdjustmentWorkId = ' ';
whsWorkLineCycleCount.selectForUpdate(true);
whsWorkLineCycleCount.update();
workExecute.updateWorkStatusCycleCount(whsWorkLineCycleCount.WorkId);
}
}
ttscommit;
}
++i;
}
if (i == 1)
{
WHSWorkTable_ds.research(true);
}
else
{
WHSWorkTable_ds.executeQuery();
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(WHSWorkTableListPage, WHSWorkTable), FormDataSourceEventType::MarkChanged)]
public static void WHSWorkTable_OnMarkChanged(FormDataSource sender, FormDataSourceEventArgs e)
{
WHSWorkTable rec;
boolean flag = false;
WHSWorkTable whsWorkTable = sender.cursor();
FormDataSource whsWorkTable_ds = sender.formRun().dataSource("whsWorkTable");
FormRun element = sender.formRun();
FormControl Accepet = element.design(0).controlName("AcceptCount");
FormControl Reject = element.design(0).controlName("RejectCount");
for (rec = getFirstSelection(whsWorkTable_ds); rec; rec = whsWorkTable_ds.getNext())
{
if(rec.WorkId && rec.WorkStatus != WHSWorkStatus::PendingReview && rec.WorkTransType != WHSWorkTransType::CycleCount )
{
flag = false;
break;
}
else if(rec.WorkId && rec.WorkStatus == WHSWorkStatus::PendingReview && rec.WorkTransType == WHSWorkTransType::CycleCount )
{
flag = true;
}
}
if(flag == true)
{
Accepet.enabled(true);
Reject.enabled(true);
}
else
{
Accepet.enabled(false);
Reject.enabled(false);
}
}
}
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormEventHandler(formStr(WHSWorkLineCycleCount), FormEventType::Initialized)]
public static void WHSWorkLineCycleCount_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormGridControl grid = sender.control(sender.controlId(formControlStr(WHSWorkLineCycleCount,Grid))) as FormGridControl;
grid.multiSelect(true);
grid.showRowLabels(true);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(WHSWorkTableListPage, AcceptCount), FormControlEventType::Clicked)]
public static void AcceptCount_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource whsWorkTable_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkTable)) as FormDataSource; //Form
// FormDataSource whsWorkLine_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkLine)) as FormDataSource; //Form
WHSWorkTable rec;
WHSWorkLineCycleCountForm whsWorkLineCycleCountForm;
WHSWorkLineCycleCount whsWorkLineCycleCount;
WHSWorkExecute workExecute = new WHSWorkExecute();
WHSWorkTable workTable;// = WHSWorkTable::find(_whsWorkLineCycleCount.WorkId);
WHSWorkLine workLine;// = WHSWorkLine::find(whsWorkLineCycleCount.WorkId, _whsWorkLineCycleCount.LineNum);
InventDim inventDim;// = InventDim::find(whsWorkLineCycleCount.InventDimId);
WHSWorkId workId;
WHSUserId userId;// = workLine.UserId ? workLine.UserId : WHSParameters::find().GenericWorkUserId;
int i;
JournalNameId journalNum;
for (rec = whsWorkTable_ds.getFirst(true) ? whsWorkTable_ds.getFirst(true) : whsWorkTable_ds.cursor();
rec;
rec = whsWorkTable_ds.getNext())
{
select workTable where workTable.WorkId == rec.WorkId
join workLine
where workLine.WorkId == workTable.WorkId;
if( workLine.WorkId)
{
userId = workLine.UserId ? workLine.UserId : WHSParameters::find().GenericWorkUserId;
if (!userId)
{
throw error("@WAX2758");
}
while select whsWorkLineCycleCount
where whsWorkLineCycleCount.WorkId == workLine.WorkId
&& whsWorkLineCycleCount.LineNum == workLine.LineNum
{
if(whsWorkLineCycleCount.RecId)
{
journalNum = whsWorkLineCycleCount.displayInventJournalId();
//info(strFmt("%1",journalNum));
if(!journalNum)
{
ttsbegin;
inventDim = InventDim::find(whsWorkLineCycleCount.InventDimId);
if (whsWorkLineCycleCount.QtyCounted != whsWorkLineCycleCount.QtyExpected)
{
WHSInventAdjustmentCreateParameters params = WHSInventAdjustmentCreateParameters::construct();
params.WorkUserId = userId;
params.ItemId = whsWorkLineCycleCount.ItemId;
params.InventDim = inventDim;
params.AdjustmentQty = whsWorkLineCycleCount.QtyCounted - whsWorkLineCycleCount.QtyExpected;
params.AdjustmentUnit = InventTableModule::find(whsWorkLineCycleCount.ItemId, ModuleInventPurchSales::Invent).UnitId;
params.WmsLocationId = workLine.wmsLocationId;
params.InventLocationId = workTable.InventLocationId;
params.AdjustmentTypeCode = WHSParameters::find().CycleCountAdjustmentTypeCode;
params.LicensePlateId = inventDim.LicensePlateId;
params.WorkTransType = WHSWorkTransType::CycleCountAccepted;
params.WorkType = WHSWorkType::Count;
params.WorkCreatedBy = HcmWorker::findByPerson(DirPersonUser::find(curUserId()).PersonParty).RecId;
WHSInventAdjustmentCreate createAdj = WHSInventAdjustmentCreate::newFromParams(params);
createAdj.run();
workId = createAdj.createdWorkId();
}
whsWorkLineCycleCount.AcceptReject = WHSAcceptReject::Accept;
whsWorkLineCycleCount.CycleCountReconcile = NoYes::Yes;
if(workId)
{
whsWorkLineCycleCount.AdjustmentWorkId = workId;
}
else
{
whsWorkLineCycleCount.AdjustmentWorkId = ' ';
}
whsWorkLineCycleCount.selectForUpdate(true);
whsWorkLineCycleCount.update();
workExecute.updateWorkStatusCycleCount(rec.WorkId);
ttscommit;
}
}
}
}
++i;
}
if (i == 1)
{
WHSWorkTable_ds.research(true);
}
else
{
WHSWorkTable_ds.executeQuery();
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(WHSWorkTableListPage, RejectCount), FormControlEventType::Clicked)]
public static void RejectCount_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource whsWorkTable_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkTable)) as FormDataSource; //Form
// FormDataSource whsWorkLine_ds = formRun.dataSource(formDataSourceStr(WHSWorkTableListPage,WHSWorkLine)) as FormDataSource; //Form
WHSWorkTable rec;
WHSWorkLineCycleCountForm whsWorkLineCycleCountForm;
WHSWorkTable workTable;
WHSWorkLine workLine;
WHSWorkLineCycleCount whsWorkLineCycleCount;
WHSWorkExecute workExecute = new WHSWorkExecute();
int i;
JournalNameId journalNum;
for (rec = whsWorkTable_ds.getFirst(true) ? whsWorkTable_ds.getFirst(true) : whsWorkTable_ds.cursor();
rec;
rec = whsWorkTable_ds.getNext())
{
while select workTable where workTable.WorkId == rec.WorkId
join workLine
where workLine.WorkId == workTable.WorkId
join whsWorkLineCycleCount
where whsWorkLineCycleCount.WorkId == workLine.WorkId
&& whsWorkLineCycleCount.LineNum == workLine.LineNum
{
ttsbegin;
if(whsWorkLineCycleCount.WorkId)
{
journalNum = whsWorkLineCycleCount.displayInventJournalId();
if(!journalNum)
{
whsWorkLineCycleCount.AcceptReject = WHSAcceptReject::Reject;
whsWorkLineCycleCount.CycleCountReconcile = NoYes::Yes;
whsWorkLineCycleCount.AdjustmentWorkId = ' ';
whsWorkLineCycleCount.selectForUpdate(true);
whsWorkLineCycleCount.update();
workExecute.updateWorkStatusCycleCount(whsWorkLineCycleCount.WorkId);
}
}
ttscommit;
}
++i;
}
if (i == 1)
{
WHSWorkTable_ds.research(true);
}
else
{
WHSWorkTable_ds.executeQuery();
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(WHSWorkTableListPage, WHSWorkTable), FormDataSourceEventType::MarkChanged)]
public static void WHSWorkTable_OnMarkChanged(FormDataSource sender, FormDataSourceEventArgs e)
{
WHSWorkTable rec;
boolean flag = false;
WHSWorkTable whsWorkTable = sender.cursor();
FormDataSource whsWorkTable_ds = sender.formRun().dataSource("whsWorkTable");
FormRun element = sender.formRun();
FormControl Accepet = element.design(0).controlName("AcceptCount");
FormControl Reject = element.design(0).controlName("RejectCount");
for (rec = getFirstSelection(whsWorkTable_ds); rec; rec = whsWorkTable_ds.getNext())
{
if(rec.WorkId && rec.WorkStatus != WHSWorkStatus::PendingReview && rec.WorkTransType != WHSWorkTransType::CycleCount )
{
flag = false;
break;
}
else if(rec.WorkId && rec.WorkStatus == WHSWorkStatus::PendingReview && rec.WorkTransType == WHSWorkTransType::CycleCount )
{
flag = true;
}
}
if(flag == true)
{
Accepet.enabled(true);
Reject.enabled(true);
}
else
{
Accepet.enabled(false);
Reject.enabled(false);
}
}
}
No comments:
Post a Comment