Ejemplo n.º 1
0
    /// <summary>
    /// override
    /// saves the values in the dialog and fires the save
    /// event if the save was successful
    /// </summary>
    /// <returns></returns>
    public override CStatus SaveControl()
    {
        CServiceDataItem di = new CServiceDataItem();

        di.ServiceLabel = txtService.Text;
        di.IsActive     = chkActive.Checked;

        CServiceData service = new CServiceData(BaseMstr.BaseData);
        CStatus      status  = new CStatus();

        switch (EditMode)
        {
        case k_EDIT_MODE.INSERT:
            long lServiceID = -1;
            status = service.InsertService(di, out lServiceID);
            if (status.Status)
            {
                LongID   = lServiceID;
                EditMode = k_EDIT_MODE.UPDATE;
            }
            break;

        case k_EDIT_MODE.UPDATE:
            di.ServiceID = LongID;
            status       = service.UpdateService(di);
            break;

        default:
            status.Status        = false;
            status.StatusCode    = k_STATUS_CODE.Failed;
            status.StatusComment = Resources.ErrorMessages.ERROR_INVALID_EDITMODE;
            break;
        }

        if (!status.Status)
        {
            return(status);
        }

        if (_Save != null)
        {
            CAppUserControlArgs args = new CAppUserControlArgs(
                k_EVENT.INSERT,
                k_STATUS_CODE.Success,
                string.Empty,
                LongID.ToString());

            _Save(this, args);
        }

        return(new CStatus());
    }
    /// <summary>
    /// save the control
    /// </summary>
    /// <returns></returns>
    public override CStatus SaveControl()
    {
        CStatus status = new CStatus();

        //user input is ok so save
        switch (EditMode)
        {
        case k_EDIT_MODE.INSERT:
            long lOSID = -1;
            status = InsertOutcomeState(out lOSID);
            if (status.Status)
            {
                LongID   = lOSID;
                EditMode = k_EDIT_MODE.UPDATE;
            }
            break;

        case k_EDIT_MODE.UPDATE:
            status = UpdateOutcomeState(LongID);
            break;

        default:
            status.Status        = false;
            status.StatusCode    = k_STATUS_CODE.Failed;
            status.StatusComment = Resources.ErrorMessages.ERROR_INVALID_EDITMODE;
            break;
        }

        if (!status.Status)
        {
            return(status);
        }

        if (_Save != null)
        {
            CAppUserControlArgs args = new CAppUserControlArgs(
                k_EVENT.INSERT,
                k_STATUS_CODE.Success,
                string.Empty,
                LongID.ToString());

            _Save(this, args);
        }

        return(new CStatus());
    }