public void PBRoleNameBind(short RoleID) { DbpbLang pbLang = new DbpbLang(); pbLang.LanguageID = new SS.DB.DTO.DbLanguage(); pbLang.LanguageID.Languageid = UserAccount.UserLanguageID; IList <SS.DB.DTO.ValueObject.TranslatedListItem> trnslatedList = ScgDbQueryProvider.DbPbLangQuery.GetPBLangByCriteria(pbLang, RoleID); ctlPBDropdown.DataSource = trnslatedList; ctlPBDropdown.DataTextField = "IDSymbol"; ctlPBDropdown.DataValueField = "strID"; ctlPBDropdown.DataBind(); }
protected void ctlAdd_Click(object sender, ImageClickEventArgs e) { Dbpb pb = new Dbpb(); if (Mode.Equals(FlagEnum.EditFlag)) { pb.Pbid = PBID; } pb.PBCode = ctlPBCode.Text; pb.Supplementary = ctlSupplementary.Text; pb.Active = ctlActive.Checked; pb.UpdBy = UserAccount.UserID; pb.UpdDate = DateTime.Now; pb.UpdPgm = UserAccount.CurrentLanguageCode; pb.CreDate = DateTime.Now; pb.CreBy = UserAccount.UserID; pb.CurrencyID = UIHelper.ParseLong(ctlMainCurrencyDropdown.SelectedValue); pb.RepOffice = ctlRepOffice.Checked; if (!string.IsNullOrEmpty(ctlMainCurrencyDropdown.SelectedValue)) { pb.MainCurrencyID = UIHelper.ParseShort(ctlMainCurrencyDropdown.SelectedValue); } try { pb.PettyCashLimit = UIHelper.ParseDouble(ctlPettyCashLimit.Text); DbCompany com = ScgDbQueryProvider.DbCompanyQuery.FindByIdentity(UIHelper.ParseLong(ctlCompanyField.CompanyID)); pb.CompanyCode = com.CompanyCode; pb.CompanyID = com; } catch (Exception) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); errors.AddError("PB.Error", new ErrorMessage("Check For Petty Cash Limit or Company Code.")); ValidationErrors.MergeErrors(errors); return; } try { // save or update PB if (Mode.Equals(FlagEnum.EditFlag)) { DbPBService.UpdatePB(pb, PbDataSet); } else { long PBId = DbPBService.AddPB(pb, PbDataSet); pb.Pbid = PBId; } // save or update PBlang IList <DbpbLang> list = new List <DbpbLang>(); foreach (GridViewRow row in ctlPBEditorGrid.Rows) { short languageId = UIHelper.ParseShort(ctlPBEditorGrid.DataKeys[row.RowIndex]["LanguageID"].ToString()); TextBox Description = row.FindControl("ctrDescription") as TextBox; TextBox Comment = (TextBox)row.FindControl("ctrComment") as TextBox; CheckBox Active = (CheckBox)row.FindControl("ctlActive") as CheckBox; //comment by oum 02/06/2009 //ไม่ต้อง check description is null or empty เพราะว่าไม่ใช่ require field //if ((!string.IsNullOrEmpty(Description.Text))) //{ DbpbLang pbLang = new DbpbLang(); pbLang.Active = Active.Checked; pbLang.CreBy = UserAccount.UserID; pbLang.CreDate = DateTime.Now; pbLang.Description = Description.Text; pbLang.Comment = Comment.Text; pbLang.LanguageID = new DbLanguage(languageId); pbLang.PBID = pb; pbLang.UpdBy = UserAccount.UserID; pbLang.UpdDate = DateTime.Now; pbLang.UpdPgm = UserAccount.CurrentLanguageCode; list.Add(pbLang); //} } if (Mode.Equals(FlagEnum.EditFlag)) { DbPBLangService.UpdatePBLang(list); } if (Mode.Equals(FlagEnum.NewFlag)) { DbPBLangService.AddPBLang(list); } Notify_Ok(sender, e); } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); } //} }