如何使用Action创建Employee

时间:2017-04-25 17:15:23

标签: acumatica

我试图创建一个带有操作的员工。

我已将UI中的最低必填字段标识为: - EmployeeID(关键字段) - LastName(联系DAC) - 员工班 - 部门

我最初尝试输入这些值,只希望SetValueExt运行默认事件并分配其他请求的字段,但在运行操作后,我得到了不同的消息,请求这些附加字段。所以我也包括了它们。

我的代码如下:

private WriteableBitmap ChangeBrightness(WriteableBitmap source, byte change_value)
    {
        WriteableBitmap dest = new WriteableBitmap(source);

        byte[] color = new byte[4];

        using (Stream s = source.PixelBuffer.AsStream())
        {
            using (Stream d = dest.PixelBuffer.AsStream())
            {
                // read the pixel color
                while (s.Read(color, 0, 4) > 0)
                {
                    // color[0] = b
                    // color[1] = g 
                    // color[2] = r
                    // color[3] = a

                    // do the adding algo per byte (skip the alpha)
                    for (int i = 0; i < 4; i++)
                    {
                        if ((int)color[i] + change_value > 255) color[i] = 255; else color[i] = (byte)(color[i] + change_value);
                    }

                    // write the new pixel color
                    d.Write(color, 0, 4);
                }
            }
        }

        // return the new bitmap
        return dest;
    }

使用当前版本,我收到消息:  &#34; 错误:&#39;分支&#39;不能为空。错误:&#39;默认位置&#39;不能为空。错误:&#39;路由电子邮件&#39;不能为空。&#34;

我在BAccount,员工,供应商(员工DAC继承自它),联系人和地址表中寻找数据库中的分支字段,没有运气。 知道错误是什么吗?

感谢。

1 个答案:

答案 0 :(得分:1)

有关在操作中创建员工的示例,请参阅下面的代码段:

public PXAction<EPEmployee> CreateEmployee;
[PXButton]
[PXUIField(DisplayName = "Create Employee")]
protected void createEmployee()
{
    EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
    EPEmployee epEmployeeRow = new EPEmployee();
    epEmployeeRow.AcctCD = "EMPLOYEE1";
    epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);

    Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
    contactRow.FirstName = "John";
    contactRow.LastName = "Green";
    employeeMaintGraph.Contact.Update(contactRow);

    Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
    addressRow.CountryID = "US";
    addressRow = employeeMaintGraph.Address.Update(addressRow);
    addressRow.State = "DC";
    employeeMaintGraph.Address.Update(addressRow);

    epEmployeeRow.VendorClassID = "EMPSTAND";
    epEmployeeRow.DepartmentID = "FINANCE";
    employeeMaintGraph.Employee.Update(epEmployeeRow);

    employeeMaintGraph.Actions.PressSave();

    throw new PXRedirectRequiredException(employeeMaintGraph, null);
}