Exemplo n.º 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();
        }
Exemplo n.º 2
0
        protected void lnkSaveState_Click(object sender, EventArgs e)
        {
            var states = new States();

            lnkAddNew.Enabled = true;
            foreach (GridViewRow gvRow in GridViewState.Rows)
            {
                var action  = ((HiddenField)gvRow.FindControl("hdnAction")).Value;
                var stateId = ((TextBox)gvRow.FindControl("txtStateId")).Text.ToTrimString();
                states.Add(new State
                {
                    //Slno = gvRow.FindControl("lblRowIndex").,
                    StateId      = stateId,
                    StateName    = ((TextBox)gvRow.FindControl("txtStateName")).Text,
                    Action       = action,
                    DataBaseInfo = UserContext.DataBaseInfo
                });
                if (action == Constants.InsertAction)
                {
                    QueryArgument queryArgument = new QueryArgument(UserContext.DataBaseInfo)
                    {
                        FilterKey = CountryId,
                        filter1   = Constants.CountryType,
                        filter2   = stateId,
                        QueryType = Constants.TableMCatDetls
                    };
                    if (_transactionManager.ValidateKey(queryArgument))
                    {
                        CustomMessageControl.MessageBodyText = "State Code already exist";
                        CustomMessageControl.MessageType     = MessageTypes.Error;
                        CustomMessageControl.ShowMessage();
                        ((TextBox)gvRow.FindControl("txtStateId")).Focus();
                        return;
                    }
                }
            }
            if (states.Where(x => x.StateId.ToTrimString() == string.Empty).Any())
            {
                CustomMessageControl.MessageBodyText = "Please Enter State ID";
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                return;
            }
            if (states.Where(x => x.StateName.ToTrimString() == string.Empty).Any())
            {
                CustomMessageControl.MessageBodyText = "Please Enter State Name";
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                return;
            }
            if (Action == string.Empty || Action == Constants.ViewAction)
            {
                Action = Constants.InsertAction;
            }
            var country = new Country
            {
                CountryId      = CountryId,
                CountryName    = CountryName,
                CurrencyCode   = CurrencyCode,
                CurrencyName   = CurrencyName.ToTrimString(),
                CurrencySymbol = CurrencySymbol,
                Denomination   = Denomination,
                Action         = Action,
                DataBaseInfo   = UserContext.DataBaseInfo,
                States         = states
            };
            var countries = new Countries {
                country
            };

            if (_controlPanel.SetCountry(countries))
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.StateSaved;
                CustomMessageControl.MessageType     = MessageTypes.Success;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(SysEventType.INFO, "STATE SAVED",
                                  GlobalCustomResource.StateSaved);
                BindData(BindType.Form);
                lnkAddState.Enabled = true;
                lnkAddState.Style.Add("cursor", "Pointer");
            }
            else
            {
                CustomMessageControl.MessageBodyText = GlobalCustomResource.StateFailed;
                CustomMessageControl.MessageType     = MessageTypes.Error;
                CustomMessageControl.ShowMessage();
                AuditLog.LogEvent(SysEventType.INFO, "STATE UPDATE FAILED",
                                  GlobalCustomResource.StateFailed);
            }
        }