예제 #1
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();
        }
예제 #2
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();
            }
        }