/// <summary> /// Update record by using the table's primary key. /// </summary> /// <param name="database"></param> /// <param name="data">Data which to update.</param> /// <param name="oldLANG_CD">Old Key #1</param> /// <returns></returns> public int UpdateWithPK(Database database, LangDTO data, NZString oldLANG_CD) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" UPDATE " + data.TableName); sb.AppendLine(" SET "); sb.AppendLine(" " + LangDTO.eColumns.LANG_CD + "=:LANG_CD"); sb.AppendLine(" ," + LangDTO.eColumns.LANG_NAME + "=:LANG_NAME"); sb.AppendLine(" ," + LangDTO.eColumns.UPD_BY + "=:UPD_BY"); sb.AppendLine(" ," + LangDTO.eColumns.UPD_DATE + "=SYSDATE"); sb.AppendLine(" ," + LangDTO.eColumns.UPD_MACHINE + "=:UPD_MACHINE"); sb.AppendLine(" WHERE "); sb.AppendLine(" " + LangDTO.eColumns.LANG_CD + "=:oldLANG_CD"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("LANG_CD", DataType.VarChar, data.LANG_CD.Value); req.Parameters.Add("LANG_NAME", DataType.NVarChar, data.LANG_NAME.Value); req.Parameters.Add("UPD_BY", DataType.NVarChar, data.UPD_BY.Value); req.Parameters.Add("UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value); req.Parameters.Add("oldLANG_CD", DataType.VarChar, oldLANG_CD.Value); #endregion return(db.ExecuteNonQuery(req)); }
/// <summary> /// Check exist before manipulate data. If found record will update data. Otherwise insert new data. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNewOrUpdate(Database database, LangDTO data) { Database db = UseDatabase(database); if (Exist(database, data.LANG_CD)) { return(UpdateWithoutPK(db, data)); } return(AddNew(db, data)); }
public IActionResult SetLanguage([FromForm] LangDTO request) { #region SetLangCookie var resp = new ServiceNode <object, Lang>(_localizer, _fc).GetClient("/api/lang/get/" + request.culture); Response.Cookies.Append("LangKey", resp.Data.id.ToString(), new CookieOptions { Expires = DateTimeOffset.UtcNow.AddDays(1) }); Response.Cookies.Append( CookieRequestCultureProvider.DefaultCookieName, CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(resp.Data.valueKey)), new CookieOptions { Expires = DateTimeOffset.UtcNow.AddDays(1) } ); #endregion return(LocalRedirect(request.returnurl)); }
/// <summary> /// Insert new record into database. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNew(Database database, LangDTO data) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" INSERT INTO " + data.TableName + "("); sb.AppendLine(" " + LangDTO.eColumns.LANG_CD); sb.AppendLine(" ," + LangDTO.eColumns.LANG_NAME); sb.AppendLine(" ," + LangDTO.eColumns.IS_DEFAULT); sb.AppendLine(" ," + LangDTO.eColumns.CRT_BY); sb.AppendLine(" ," + LangDTO.eColumns.CRT_DATE); sb.AppendLine(" ," + LangDTO.eColumns.CRT_MACHINE); sb.AppendLine(" ," + LangDTO.eColumns.UPD_BY); sb.AppendLine(" ," + LangDTO.eColumns.UPD_DATE); sb.AppendLine(" ," + LangDTO.eColumns.UPD_MACHINE); sb.AppendLine(") VALUES("); sb.AppendLine(" :LANG_CD"); sb.AppendLine(" ,:LANG_NAME"); sb.AppendLine(" ,:IS_DEFAULT"); sb.AppendLine(" ,:CRT_BY"); sb.AppendLine(" ,GETDATE()"); sb.AppendLine(" ,:CRT_MACHINE"); sb.AppendLine(" ,:UPD_BY"); sb.AppendLine(" ,GETDATE()"); sb.AppendLine(" ,:UPD_MACHINE"); sb.AppendLine(" )"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("LANG_CD", DataType.VarChar, data.LANG_CD.Value); req.Parameters.Add("LANG_NAME", DataType.NVarChar, data.LANG_NAME.Value); req.Parameters.Add("IS_DEFAULT", DataType.VarChar, data.IS_DEFAULT.Value); req.Parameters.Add("CRT_BY", DataType.NVarChar, data.CRT_BY.Value); req.Parameters.Add("CRT_MACHINE", DataType.NVarChar, data.CRT_MACHINE.Value); req.Parameters.Add("UPD_BY", DataType.NVarChar, data.UPD_BY.Value); req.Parameters.Add("UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value); #endregion return(db.ExecuteNonQuery(req)); }
public void ImportData(List <ScreenImportUIDM> ScreenImportList, List <ScreenDetailUIDM> UIDMScreenDetailList) { LangBIZ bizLang = new LangBIZ(); LangDTO dtoLang = new LangDTO(); ScreenDetailBIZ bizScreenDetail = new ScreenDetailBIZ(); List <ScreenDTO> screenDTOList = new List <ScreenDTO>(); List <ScreenLangDTO> screenLangDTOList = new List <ScreenLangDTO>(); List <ScreenDetailDTO> screenDetailDTOList = new List <ScreenDetailDTO>(); List <ScreenDetailLangDTO> screenDetailLangDTOList = new List <ScreenDetailLangDTO>(); // count lang detail List <LangDTO> langDTOList = bizLang.LoadAll(); #region Collect Data foreach (ScreenImportUIDM ScreenImport in ScreenImportList) { // check if screen is never been import then import to screen ms if (ScreenImport.ImportStatus.StrongValue.ToUpper() == "NOTIMPORT") { ScreenDTO dtoScreen = new ScreenDTO(); dtoScreen.SCREEN_CD = ScreenImport.ScreenCD; dtoScreen.SCREEN_NAME = ScreenImport.ScreenName; dtoScreen.ORIGINAL_TITLE = ScreenImport.ScreenName; dtoScreen.IMAGE_CD.Value = "DEFAULT"; dtoScreen.SCREEN_TYPE = ScreenImport.ScreenType; dtoScreen.SCREEN_ACTION.Value = 0; dtoScreen.EXT_PROGRAM.Value = string.Empty; dtoScreen.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreen.CRT_DATE.Value = DateTime.Now; dtoScreen.CRT_MACHINE.Value = Environment.MachineName; dtoScreen.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreen.UPD_DATE.Value = DateTime.Now; dtoScreen.UPD_MACHINE.Value = Environment.MachineName; screenDTOList.Add(dtoScreen); if (langDTOList.Count > 0) { foreach (LangDTO langdto in langDTOList) { ScreenLangDTO dtoScreenLang = new ScreenLangDTO(); // add multilang for screen name dtoScreenLang.SCREEN_CD = ScreenImport.ScreenCD; dtoScreenLang.SCREEN_DESC = ScreenImport.ScreenName; dtoScreenLang.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenLang.CRT_DATE.Value = DateTime.Now; dtoScreenLang.CRT_MACHINE.Value = Environment.MachineName; dtoScreenLang.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenLang.UPD_DATE.Value = DateTime.Now; dtoScreenLang.UPD_MACHINE.Value = Environment.MachineName; dtoScreenLang.LANG_CD = langdto.LANG_CD; //bizScreenLang.AddNew(dtoScreenLang); screenLangDTOList.Add(dtoScreenLang); } } } } foreach (ScreenDetailUIDM ScreenDetail in UIDMScreenDetailList) { ScreenDetailDTO dtoScreenDetail = new ScreenDetailDTO(); dtoScreenDetail.SCREEN_CD = ScreenDetail.ScreenCD; dtoScreenDetail.CONTROL_TYPE = ScreenDetail.ControlType; dtoScreenDetail.ORIGINAL_TITLE = ScreenDetail.ControlCaption; dtoScreenDetail.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenDetail.CRT_DATE.Value = DateTime.Now; dtoScreenDetail.CRT_MACHINE.Value = Environment.MachineName; dtoScreenDetail.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenDetail.UPD_DATE.Value = DateTime.Now; dtoScreenDetail.UPD_MACHINE.Value = Environment.MachineName; dtoScreenDetail.CONTROL_CD = ScreenDetail.ControlCD; screenDetailDTOList.Add(dtoScreenDetail); if (langDTOList.Count > 0) { foreach (LangDTO langdto in langDTOList) { ScreenDetailLangDTO dtoScreenDetailLang = new ScreenDetailLangDTO(); // add spread column to screen detail ms dtoScreenDetailLang.SCREEN_CD = ScreenDetail.ScreenCD; dtoScreenDetailLang.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenDetailLang.CRT_DATE.Value = DateTime.Now; dtoScreenDetailLang.CRT_MACHINE.Value = Environment.MachineName; dtoScreenDetailLang.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dtoScreenDetailLang.UPD_DATE.Value = DateTime.Now; dtoScreenDetailLang.UPD_MACHINE.Value = Environment.MachineName; // add multilang for spread column dtoScreenDetailLang.CONTROL_CD = ScreenDetail.ControlCD; //.Value = fpsspread.Name + ".Column[" + i.ToString() + "]"; dtoScreenDetailLang.CONTROL_CAPTION = ScreenDetail.ControlCaption; //.Value = fpsspread.Sheets[0].Columns[i].Label; dtoScreenDetailLang.LANG_CD = langdto.LANG_CD; screenDetailLangDTOList.Add(dtoScreenDetailLang); } } } #endregion ImportScreenBIZ bizImportScreen = new ImportScreenBIZ(); bizImportScreen.ImportData(screenDTOList, screenLangDTOList, screenDetailDTOList, screenDetailLangDTOList); }