private void CheckTranslateSymbolAndSaveToDatabase(string translateWord) { if (!string.IsNullOrEmpty(this.ProgramCode)) { try { SuGlobalTranslate translate = new SuGlobalTranslate(); translate.ProgramCode = this.ProgramCode; translate.TranslateControl = string.Empty; translate.TranslateSymbol = translateWord; translate.Active = true; translate.CreBy = UserAccount.UserID; translate.UpdBy = UserAccount.UserID; translate.UpdPgm = UserAccount.CurrentProgramCode; long translateID = SuGlobalTranslateService.AddProgramTranslateControl_Symbol(translate); if (translateID > 0) { IList <SuGlobalTranslateLang> translateLangList = new List <SuGlobalTranslateLang>(); SuGlobalTranslateLang translateTH = this.BuildSuGlobalTranslateLang(translateID, ParameterServices.DefaultLanguage, translateWord); translateLangList.Add(translateTH); SuGlobalTranslateLang translateEN = this.BuildSuGlobalTranslateLang(translateID, ParameterServices.EnglishLanguageID, translateWord); translateLangList.Add(translateEN); SuGlobalTranslateLangService.UpdateGlobalTranslateLang(translateLangList); } } catch (Exception) { } } }
protected void ctlGlobalTranslateGrid_RowCommand(object sender, GridViewCommandEventArgs e) { long translateId; if (e.CommandName == "TranslateEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; translateId = UIHelper.ParseLong(ctlGlobalTranslateGrid.DataKeys[rowIndex].Value.ToString()); ctlTranslateForm.PageIndex = (ctlGlobalTranslateGrid.PageIndex * ctlGlobalTranslateGrid.PageSize) + rowIndex; ctlTranslateForm.ChangeMode(FormViewMode.Edit); IList <SuGlobalTranslate> list = new List <SuGlobalTranslate>(); list.Add(SuGlobalTranslateService.FindByIdentity(translateId)); ctlTranslateForm.DataSource = list; ctlTranslateForm.DataBind(); ctlUpdatePanelTranslateForm.Update(); ctlGlobalTranslateGrid.DataCountAndBind(); ctlTranslateModalPopupExtender.Show(); } if (e.CommandName == "Select") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; translateId = UIHelper.ParseLong(ctlGlobalTranslateGrid.DataKeys[rowIndex].Value.ToString()); ctlTranslateLangGrid.DataSource = QueryProvider.SuGlobalTranslateLangQuery.FindTranslateLangByTranslateId(translateId); ctlTranslateLangGrid.DataBind(); ctlSubmit.Visible = true; ctlFieldSetDetailGridView.Visible = true; ctlCancel.Visible = true; ctlGlobalTranslateGrid.DataCountAndBind(); ctlUpdatePanelTranslateLangGridView.Update(); } }
protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlGlobalTranslateGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked)) { try { long id = UIHelper.ParseLong(ctlGlobalTranslateGrid.DataKeys[row.RowIndex].Value.ToString()); SuGlobalTranslate translate = SuGlobalTranslateService.FindByIdentity(id); SuGlobalTranslateService.Delete(translate); //if (ctlGlobalTranslateGrid.SelectedIndex == row.RowIndex) //{ // TranslateLangGridViewFinish(); //} //ctlGlobalTranslateGrid.DataCountAndBind(); //ctlUpdatePanelGridView.Update(); } 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); ctlGlobalTranslateGrid.DataCountAndBind(); } } } } TranslateLangGridViewFinish(); ctlGlobalTranslateGrid.DataCountAndBind(); ctlUpdatePanelGridView.Update(); //ctlGlobalTranslateGrid.DataBind(); }
protected void ctlTranslateForm_Updating(object sender, FormViewUpdateEventArgs e) { long translateId = UIHelper.ParseLong(ctlTranslateForm.DataKey.Value.ToString()); SuGlobalTranslate globalTranslate = new SuGlobalTranslate(translateId); GetSuGlobalTranslateInfo(globalTranslate); try { SuGlobalTranslateService.UpdateGlobalTranslate(globalTranslate); ctlGlobalTranslateGrid.DataCountAndBind(); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlTranslateForm_Inserting(object sender, FormViewInsertEventArgs e) { SuGlobalTranslate globalTranslate = new SuGlobalTranslate(); GetSuGlobalTranslateInfo(globalTranslate); try { SuGlobalTranslateService.AddGlobalTranslate(globalTranslate); ctlGlobalTranslateGrid.DataCountAndBind(); ctlTranslateForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
private void CheckTranslateGridViewHeader(BaseGridView control) { for (int index = 0; index < control.Columns.Count; index++) { if (control.Columns[index].HeaderText.StartsWith("$") && control.Columns[index].HeaderText.EndsWith("$")) { if (!string.IsNullOrEmpty(this.ProgramCode)) { try { string translateControl = string.Concat(control.ID, ".Columns[", index.ToString(), "]", ".HeaderText"); string translateWord = control.Columns[index].HeaderText.TrimStart('$').TrimEnd('$'); SuGlobalTranslate translate = new SuGlobalTranslate(); translate.ProgramCode = this.ProgramCode; translate.TranslateSymbol = string.Empty; translate.TranslateControl = translateControl; translate.Active = true; translate.CreBy = UserAccount.UserID; translate.UpdBy = UserAccount.UserID; translate.UpdPgm = UserAccount.CurrentProgramCode; long translateID = SuGlobalTranslateService.AddProgramTranslateControl_Symbol(translate); if (translateID > 0) { IList <SuGlobalTranslateLang> translateLangList = new List <SuGlobalTranslateLang>(); SuGlobalTranslateLang translateTH = this.BuildSuGlobalTranslateLang(translateID, ParameterServices.DefaultLanguage, translateWord); translateLangList.Add(translateTH); SuGlobalTranslateLang translateEN = this.BuildSuGlobalTranslateLang(translateID, ParameterServices.EnglishLanguageID, translateWord); translateLangList.Add(translateEN); SuGlobalTranslateLangService.UpdateGlobalTranslateLang(translateLangList); } } catch (Exception) { } } } } }