Exemplo n.º 1
0
        protected void ctlCountryGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UserEdit")
            {
                int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                CTID = Convert.ToInt16(ctlCountryGrid.DataKeys[rowIndex].Value);
                CountryEditor.Initialize(FlagEnum.EditFlag, CTID);
                CountryEditor.ShowPopUp();
            }
            if (e.CommandName == "UserDelete")
            {
                try
                {
                    int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    CTID = UIHelper.ParseShort(ctlCountryGrid.DataKeys[rowIndex].Value.ToString());
                    DbCountry ct = ScgDbQueryProvider.DbCountryQuery.FindByIdentity(CTID);
                    DbCountryService.Delete(ct);

                }
                catch (Exception ex)
                {
                    if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                            "alert('This data is now in use.');", true);
                        ctlCountryGrid.DataCountAndBind();
                    }
                }

                ctlCountryGrid.DataCountAndBind();
                ctlUpdatePanelGridview.Update();

            }
        }
Exemplo n.º 2
0
 public DbCountry GetCriteria()
 {
     DbCountry ct = new DbCountry();
     ct.CountryCode = ctlCountryCodeCri.Text;
     ct.Comment = ctlCommentCri.Text;
     return ct;
 }
Exemplo n.º 3
0
 protected void ctlDelete_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlCountryGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelectChk")).Checked))
         {
             try
             {
                 short countryId = Convert.ToInt16(ctlCountryGrid.DataKeys[row.RowIndex].Value);
                 DbCountry country = DbCountryService.FindByIdentity(countryId);
                 DbCountryService.Delete(country);
             }
             catch (Exception ex)
             {
                 if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                         "alert('This data is now in use.');", true);
                     ctlCountryGrid.DataCountAndBind();
                     ctlUpdatePanelGridview.Update();
                 }
             }
         }
     }
     ctlCountryGrid.DataCountAndBind();
     ctlUpdatePanelGridview.Update();
 }
Exemplo n.º 4
0
        private void Countries_SelectedIndexChanged(object sender, EventArgs e)
        {
            DbCountry country = (DbCountry)cbCountries.SelectedItem;

            new Func <DbCountry, string[]>((s) => ScanAppContext.QueryCountryCodes(s.CountryId)).RunAsync(
                new Action <string[]>((sc) =>
                                      this.InvokeSf(new MethodInvoker(() => { cbSiteCodes.DataSource = sc; }))), country);
        }
Exemplo n.º 5
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var country = new DbCountry {
                    CountryId = request.CountryId, RowVersion = request.RowVersion
                };

                _context.Set <DbCountry>().Attach(country);
                _context.Set <DbCountry>().Remove(country);
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Exemplo n.º 6
0
        protected void ctlSubmit_Click(object sender, EventArgs e)
        {
            IList <DbCountry> list = new List <DbCountry>();

            foreach (GridViewRow row in ctlCountryGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    short     id      = UIHelper.ParseShort(ctlCountryGrid.DataKeys[row.RowIndex].Values["CountryID"].ToString());
                    DbCountry country = DbCountryService.FindByIdentity(id);
                    list.Add(country);
                }
            }
            CallOnObjectLookUpReturn(list);
            this.ModalPopupExtender1.Hide();
        }
Exemplo n.º 7
0
 public void Initialize(string mode, short id)
 {
     Mode = mode.ToString();
     CID  = id;
     if (mode.Equals(FlagEnum.EditFlag))
     {
         DbCountry ct = ScgDbQueryProvider.DbCountryQuery.FindByIdentity(CID);
         ctlCountryCode.Text  = ct.CountryCode;
         ctlComment.Text      = ct.Comment;
         ctlActiveChk.Checked = ct.Active;
         ctlCountryLangGrid.DataCountAndBind();
         UpdatePanelCountryForm.Update();
     }
     else if (mode.ToString() == FlagEnum.NewFlag)
     {
         ResetValue();
     }
 }
Exemplo n.º 8
0
        protected void ctlAdd_Click(object sender, ImageClickEventArgs e)
        {
            DbCountry ct = new DbCountry();

            if (Mode.Equals(FlagEnum.EditFlag))
            {
                ct.CountryID = CID;
            }

            ct.CountryCode = ctlCountryCode.Text;
            ct.Comment     = ctlComment.Text;
            ct.Active      = ctlActiveChk.Checked;
            ct.UpdBy       = UserAccount.UserID;
            ct.UpdDate     = DateTime.Now;
            ct.UpdPgm      = UserAccount.CurrentLanguageCode;
            ct.CreDate     = DateTime.Now;
            ct.CreBy       = UserAccount.UserID;
            try
            {
                // save or update PB
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    DbCountryService.UpdateCountry(ct);
                }
                else
                {
                    short cId = DbCountryService.AddCountry(ct);
                    ct.CountryID = cId;
                }
                IList <DbCountryLang> list = new List <DbCountryLang>();

                foreach (GridViewRow row in ctlCountryLangGrid.Rows)
                {
                    short languageId = UIHelper.ParseShort(ctlCountryLangGrid.DataKeys[row.RowIndex]["LanguageID"].ToString());

                    TextBox  CountryName = row.FindControl("ctlCountryName") as TextBox;
                    TextBox  Comment     = (TextBox)row.FindControl("ctlComment") as TextBox;
                    CheckBox Active      = (CheckBox)row.FindControl("ctlActive") as CheckBox;


                    DbCountryLang ctLang = new DbCountryLang();
                    ctLang.Active      = Active.Checked;
                    ctLang.CreBy       = UserAccount.UserID;
                    ctLang.CreDate     = DateTime.Now;
                    ctLang.Comment     = Comment.Text;
                    ctLang.Language    = new DbLanguage(languageId);
                    ctLang.Country     = ct;
                    ctLang.UpdBy       = UserAccount.UserID;
                    ctLang.UpdDate     = DateTime.Now;
                    ctLang.UpdPgm      = UserAccount.CurrentLanguageCode;
                    ctLang.CountryName = CountryName.Text;
                    list.Add(ctLang);
                }

                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    DbCountryLangService.UpdateCountryLang(list);
                }
                if (Mode.Equals(FlagEnum.NewFlag))
                {
                    DbCountryLangService.UpdateCountryLang(list);
                }

                Notify_Ok(sender, e);
            }
            catch (ServiceValidationException ex)
            {
                this.ValidationErrors.MergeErrors(ex.ValidationErrors);
                UpdatePanelCountryForm.Update();
            }
        }