Пример #1
0
        protected void lnkSave_Click(object sender, EventArgs e)
        {
            if (Action == string.Empty || Action == Constants.ViewAction)
            {
                Action = Constants.InsertAction;
            }
            if (Action == Constants.InsertAction)
            {
                QueryArgument queryArgument = new QueryArgument(UserContext.DataBaseInfo)
                {
                    FilterKey = CountryId,
                    filter1   = Constants.CountryType,
                    QueryType = Constants.TableMCatHeader
                };
                if (_transactionManager.ValidateKey(queryArgument))
                {
                    CustomMessageControl.MessageBodyText = "Country Code already exist";
                    CustomMessageControl.MessageType     = MessageTypes.Error;
                    CustomMessageControl.ShowMessage();
                    txtId.Focus();
                    return;
                }
            }
            var country = new Country
            {
                CountryId      = CountryId,
                CountryName    = CountryName,
                CurrencyCode   = CurrencyCode,
                CurrencyName   = CurrencyName.ToTrimString(),
                CurrencySymbol = CurrencySymbol,
                Denomination   = Denomination,
                Action         = Action,
                DataBaseInfo   = UserContext.DataBaseInfo
            };
            var countries = new Countries {
                country
            };

            if (_controlPanel.SetCountry(countries))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.CountrySaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                AuditLog.LogEvent(SysEventType.INFO, "Country Saved",
                                  GlobalCustomResource.CountrySaved);
                ClearForm();
                BindData(BindType.List);
                IsVisibleSave = false;
                txtId.Enabled = true;
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "openTabFunctionCall", "openTab(1)", true);
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.CountryFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                AuditLog.LogEvent(SysEventType.INFO, "Country update failed",
                                  GlobalCustomResource.CountryFailed);
            }
            CustomMessageControl.ShowMessage();
        }