I have a Custom Inventory module (utilizing the UD102 & UD102A tables).
My part validation works great, however, after the Inventory group is posted I do not want any changes allowed to the Part Number, Quantity Counted, or the Void Tag checkbox.
Currently using a Switch / Case statement which works for ShortChar01(Part Number). It will not allow a change to be made to the part number after it is posted. When I add Case 2: Count Quantity(Number02) and Case 3: VoidTag(CheckBox02) it won’t allow a part number to be entered even if the Inventory Group is not posted.
This is the code:
private void UD102A_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
{
switch (args.Column.ColumnName)
{
case "ShortChar01":
//case "Number02":
//case "CheckBox02":
if ((bool)isPosted (edvUD102.dataView[edvUD102.Row]["Key1"].ToString())== false)
{
//MessageBox.Show(args.ProposedValue.ToString());
getPartInformation(args.ProposedValue.ToString(),false);
}
else
{
MessageBox.Show("Inventory group is posted");
oTrans.Refresh();
}
break;
}
}
Any suggestions would be appreciated.
Thanks,
Carol
switch (args.Column.ColumName)
{
case "ShortChar01":
goto case "Checkbox02";
case "Number02":
goto case "Checkbox02";
case "Checkbox02":
If ...{
}
break;
}
Upon further reading of that MS article I posted, it looks like your original code should work as you have only one case ever executing, and it has a break; at the end. Maybe you just need to add
So UD102.CheckBox02 is set by whatever that posting process you mentioned. And you want to prevent changes to fields ShortChar01, Number02, and CheckBox02, of records that have CheckbBox02 set. That correct?
Would this be simpler with an extended properties wizard? Or even an In-Tran DD on UD102 that stops updates of records where CheckBox02 is already set.
The default: would be just like one of the case statements, so at the same level.
switch(i){
case 0:
/* do something if i == 0*/
break;
case 1:
/* do something if i == 1*/
break;
default:
/* stuf to do if none of the cases matched*/
break;
}
Actually, CheckBox01 is set to true when the Update Counts process is ran (which updates our inventory on hand).
But once the process is ran and the group is “posted” , I do not want users to be able to go back in and change a part number, or change a quantity, or check the void tag checkbox.
Yes,
A new group (UD102Key1) is created by the User. There is a method to generate the desired tag number range ChildKey1. This allows us to create our own tag numbers which is necessary for our inventory process.
After all tags are entered and variances are reviewed and any/all corrections are made the Update Counts method updates our on hand for the warehouse selected.
Once this process runs the Inventory Group cannot be modified or deleted. The last piece is to disallow any change to the Part number, quantity or to check/uncheck a tag that was marked “void”.
I’d put a DD on UD102A to prevent updates to those fields when UD102.CheckBoxXX is set (your flag that a group was posted).
In the form that you enter the UD102 and UD102A info, use the wizard for Extend Properties, to make those fields read only, when the posted field is set. Not really necessary, as the DD would prevent changes - but it looks better when you disable those fields, so that people know that they’ve been posted.
You can not un-check the CheckBox01 on the parent (my “posted” flag)
You cannot save a child record if its parten has CheckBox01 checked, and either the Number01 or ShortChar01 are changed)
The UI will let you change thes, but saves won’t happen. Down side is the UI retains the changes made to the protected field. Hitting Refresh will show that actual value in the DB.
This is why the second part would be to customize the form to disable those fields when the parten’s posted field is set.