Esempio n. 1
0
        private void GetSuGlobalTranslateInfo(SuGlobalTranslate globalTranslate)
        {
            //DropDownList program = ctlTranslateForm.FindControl("ctlProgramList") as DropDownList;
            TextBox  programCode      = ctlTranslateForm.FindControl("ctlProgramCodeText") as TextBox;
            TextBox  symbol           = ctlTranslateForm.FindControl("ctlSymbol") as TextBox;
            TextBox  comment          = ctlTranslateForm.FindControl("ctlComment") as TextBox;
            CheckBox active           = ctlTranslateForm.FindControl("ctlActive") as CheckBox;
            TextBox  translateControl = ctlTranslateForm.FindControl("ctlTranslateControl") as TextBox;

            globalTranslate.TranslateSymbol  = symbol.Text;
            globalTranslate.Comment          = comment.Text;
            globalTranslate.Active           = active.Checked;
            globalTranslate.TranslateControl = translateControl.Text;

            //SuProgram pro = QueryProvider.SuProgramQuery.FindByIdentity(UIHelper.ParseShort(program.SelectedValue));
            if (!string.IsNullOrEmpty(programCode.Text))
            {
                globalTranslate.ProgramCode = programCode.Text;
            }
            globalTranslate.CreBy   = UserAccount.UserID;
            globalTranslate.CreDate = DateTime.Now.Date;
            globalTranslate.UpdBy   = UserAccount.UserID;
            globalTranslate.UpdDate = DateTime.Now.Date;
            globalTranslate.UpdPgm  = ProgramCode;
        }
        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) { }
            }
        }
Esempio n. 3
0
        protected void ctlSubmit_Click(object sender, EventArgs e)
        {
            IList <SuGlobalTranslateLang> list = new List <SuGlobalTranslateLang>();
            long translateId            = UIHelper.ParseLong(ctlGlobalTranslateGrid.SelectedValue.ToString());
            SuGlobalTranslate translate = new SuGlobalTranslate(translateId);

            foreach (GridViewRow row in ctlTranslateLangGrid.Rows)
            {
                TextBox  translateWord = row.FindControl("ctlTranslateWord") as TextBox;
                TextBox  comment       = row.FindControl("ctlCommentTranslateLang") as TextBox;
                CheckBox active        = row.FindControl("ctlActiveTranslateLang") as CheckBox;

                if ((!string.IsNullOrEmpty(translateWord.Text)) || (!string.IsNullOrEmpty(comment.Text)))
                {
                    short      languageId = UIHelper.ParseShort(ctlTranslateLangGrid.DataKeys[row.RowIndex].Values["LanguageId"].ToString());
                    DbLanguage lang       = new DbLanguage(languageId);

                    SuGlobalTranslateLang translateLang = new SuGlobalTranslateLang();
                    translateLang.Translate     = translate;
                    translateLang.Language      = lang;
                    translateLang.TranslateWord = translateWord.Text;
                    translateLang.Comment       = comment.Text;
                    translateLang.Active        = active.Checked;

                    GetSuGlobalTranslateLangInfo(translateLang);
                    list.Add(translateLang);
                }
            }

            SuGlobalTranslateLangService.UpdateGlobalTranslateLang(list);
            ctlMessage.Message = GetMessage("SaveSuccessFully");
            //ctlUpdatePanelTranslateLangGridView.Update();
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
        public SuGlobalTranslate GetTranslateCriteria()
        {
            SuGlobalTranslate criteria = new SuGlobalTranslate();

            criteria.ProgramCode      = ctlProgramCode.Text;
            criteria.TranslateControl = ctlControlName.Text;
            criteria.TranslateSymbol  = ctlSymbol.Text;

            return(criteria);
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        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) { }
                    }
                }
            }
        }
Esempio n. 9
0
        protected void ctlTranslateForm_DataBound(object sender, EventArgs e)
        {
            TextBox ctlProgramCode = ctlTranslateForm.FindControl("ctlProgramCodeText") as TextBox;

            //DropDownList program = ctlTranslateForm.FindControl("ctlProgramList") as DropDownList;
            //program.DataSource = QueryProvider.SuProgramQuery.FindSuProgramByLanguageId(UserAccount.CurrentLanguageID);
            //program.DataTextField = "ProgramName";
            //program.DataValueField = "ProgramCode";
            //program.DataBind();
            //program.Items.Insert(0, new ListItem("--Please Select--", ""));
            if (ctlTranslateForm.CurrentMode != FormViewMode.ReadOnly)
            {
                TextBox ctlSymbol = ctlTranslateForm.FindControl("ctlSymbol") as TextBox;
                ctlProgramCode.Focus();
            }
            if (ctlTranslateForm.CurrentMode.Equals(FormViewMode.Edit))
            {
                SuGlobalTranslate translate = ctlTranslateForm.DataItem as SuGlobalTranslate;
                if (!string.IsNullOrEmpty(translate.ProgramCode))
                {
                    ctlProgramCode.Text = translate.ProgramCode;
                }
            }
        }