コード例 #1
0
 public void ResetValue()
 {
     ctlCountryCode.Text  = string.Empty;
     ctlComment.Text      = string.Empty;
     ctlActiveChk.Checked = true;
     ctlCountryLangGrid.DataCountAndBind();
     UpdatePanelCountryForm.Update();
 }
コード例 #2
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();
     }
 }
コード例 #3
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();
            }
        }