コード例 #1
0
 // обработчик нажатия на кнопку добавления продукта в БД
 private void btnSave_Click(object sender, EventArgs e)
 {
     CurrentEntity.Amount       = Convert.ToDecimal(txtAmount.Text);
     CurrentEntity.InterestRate = Convert.ToDecimal(txtInterestrate.Text);
     CurrentEntity.AccountId    = Convert.ToString((lueAccount.LookupResultValue as IAccount).Id);
     CurrentEntity.FbMyProduct  = lueFbMyProduct.LookupResultValue as IFbMyProduct;
     CurrentEntity.Save();
     DialogService.CloseEventHappened(sender, e);
     PanelRefresh.RefreshAll();
 }
コード例 #2
0
    private void SaveMyProduct(bool saveNew)
    {
        // проверка существования сущности
        if (CurrentEntity == null)
        {
            return;
        }

        // проверка заполнения необходимых полей
        var message        = string.Empty;
        var messageInvalid = string.Empty;

        if (string.IsNullOrWhiteSpace(txtProductName.Text))
        {
            message += (string.IsNullOrEmpty(message) ? string.Empty : "<br />") + " - " + Convert.ToString(GetLocalResourceObject("resProductName")).Replace(":", string.Empty);
        }
        if (string.IsNullOrWhiteSpace(txtProductType.Text))
        {
            message += (string.IsNullOrEmpty(message) ? string.Empty : "<br />") + " - " + Convert.ToString(GetLocalResourceObject("resProductType")).Replace(":", string.Empty);
        }
        if (message.IsNotNullOrEmpty() || messageInvalid.IsNotNullOrEmpty())
        {
            if (message.IsNotNullOrEmpty())
            {
                message = $"{GetLocalResourceObject("RequiredFieldsValidation.Message")}<br />{message}<br />";
            }
            if (messageInvalid.IsNotNullOrEmpty())
            {
                message += $"<br />{GetLocalResourceObject("RequiredFieldsValidation.Invalid.Message")}<br />{messageInvalid}";
            }
            message = "setTimeout(function() { Sage.UI.Dialogs.alert('" + message + "'); }, 1);";
            ScriptManager.RegisterStartupScript(this, GetType(), ClientID + "_RequiredFieldsValidation", message, true);
            return;
        }

        // сохраниение сущности
        CurrentEntity.Save();

        // перенаправление после сохранения в зависимости от нажатой кнопки
        Response.Redirect(saveNew ? "FbInsertMyProduct.aspx?modeid=Insert" : string.Format("FbMyProduct.aspx?entityId={0}", CurrentEntity.Id));
    }
    private void UpdateDataEvent(object sender, EventArgs e)
    {
        var groupId = string.Empty;
        var message = string.Empty;

        using (var session = new SessionScopeWrapper())
        {
            groupId = session.CreateSQLQuery("select FB_COMGACC.FB_COMPANIESGROUPID from FB_COMGACC where FB_COMGACC.ENTITYID = :accountId")
                      .SetString("accountId", Convert.ToString(ParentAccount.Id))
                      .List <string>()
                      .FirstOrDefault();
        }

        if (groupId == null)
        {
            message += (string.IsNullOrEmpty(message) ? string.Empty : "<br/>") + " - " + Convert.ToString(GetLocalResourceObject("lblCompanyGroupName.Text")).Replace(":", string.Empty);
        }

        if (!string.IsNullOrEmpty(message))
        {
            ScriptManager.RegisterStartupScript(this, GetType(), ClientID + "_RequiredFiledsValidation", "setTimeout(function() { Sage.UI.Dialogs.alert('" + GetLocalResourceObject("RequiredFiledsValidation.Message") + "<br/>" + message + "'); }, 1);", true);
            return;
        }

        CurrentEntity.Category         = "3" + pklCategory.PickListValue;
        CurrentEntity.RegistrationDate = dtpRegistrationDate.DateTimeValue.HasValue ? (DateTime?)dtpRegistrationDate.DateTimeValue.Value.ToLocalTime() : null;
        CurrentEntity.Save();

        using (var session = new SessionScopeWrapper())
        {
            session.Refresh(CurrentEntity);
        }

        PanelRefresh.RefreshAll();
        DialogService.CloseEventHappened(sender, e);
    }