Beispiel #1
0
        /// <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="oldMENU_SUB_CD">Old Key #1</param>
        /// <param name="oldMENU_SET_CD">Old Key #2</param>
        /// <returns></returns>
        public int UpdateWithPK(Database database, MenuSetDetailDTO data, NZString oldMENU_SUB_CD, NZString oldMENU_SET_CD)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" UPDATE " + data.TableName);
            sb.AppendLine(" SET ");
            sb.AppendLine("  " + MenuSetDetailDTO.eColumns.MENU_SUB_CD + "=:MENU_SUB_CD");
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.MENU_SET_CD + "=:MENU_SET_CD");
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.DISP_SEQ + "=:DISP_SEQ");
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_BY + "=:UPD_BY");
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_DATE + "=GETDATE()");
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_MACHINE + "=:UPD_MACHINE");
            sb.AppendLine(" WHERE ");
            sb.AppendLine("  " + MenuSetDetailDTO.eColumns.MENU_SUB_CD + "=:oldMENU_SUB_CD");
            sb.AppendLine("  AND " + MenuSetDetailDTO.eColumns.MENU_SET_CD + "=:oldMenuSetDetail");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("MENU_SUB_CD", DataType.VarChar, data.MENU_SUB_CD.Value);
            req.Parameters.Add("MENU_SET_CD", DataType.VarChar, data.MENU_SET_CD.Value);
            req.Parameters.Add("DISP_SEQ", DataType.Number, data.DISP_SEQ.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("oldMENU_SUB_CD", DataType.VarChar, oldMENU_SUB_CD.Value);
            req.Parameters.Add("oldMENU_SET_CD", DataType.VarChar, oldMENU_SET_CD.Value);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Beispiel #2
0
        internal int DeleteMenuSetDetail(string menuSetCD, string menuSubCD)
        {
            MenuSetMaintenanceBIZ biz = new MenuSetMaintenanceBIZ();
            MenuSetDetailDTO      dto = new MenuSetDetailDTO();

            dto.MENU_SET_CD.Value = menuSetCD;
            dto.MENU_SUB_CD.Value = menuSubCD;
            return(biz.DeleteMenuSetDetail(dto));
        }
Beispiel #3
0
        /// <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, MenuSetDetailDTO data)
        {
            Database db = UseDatabase(database);

            if (Exist(database, data.MENU_SUB_CD, data.MENU_SET_CD))
            {
                return(UpdateWithoutPK(db, data));
            }

            return(AddNew(db, data));
        }
Beispiel #4
0
        public MenuRegisterUIDM LoadMenuList()
        {
            MenuRegisterUIDM model = new MenuRegisterUIDM();

            MenuSetMaintenanceBIZ bizMenuSet = new MenuSetMaintenanceBIZ();
            MenuSubMaintenanceBIZ bizMenuSub = new MenuSubMaintenanceBIZ();
            NZString langCD = CommonLib.Common.CurrentUserInfomation.LanguageCD;

            // Load All MenuSet
            List <MenuSetDTO> listMenuSetDTO = bizMenuSet.LoadAllMenuSet();

            for (int i = 0; i < listMenuSetDTO.Count; i++)
            {
                MenuSetDTO menuSetDTO            = listMenuSetDTO[i];
                MenuRegisterUIDM.MenuSet menuSet = new MenuRegisterUIDM.MenuSet();
                menuSet.MENU_SET_CD.Value   = menuSetDTO.MENU_SET_CD.Value;
                menuSet.MENU_SET_NAME.Value = menuSetDTO.MENU_SET_NAME.Value;



                // Load MenuSub which is child of MenuSet.
                List <MenuSetDetailDTO> listMenuSetDetail = bizMenuSet.LoadAllMenuSubByMenuSetCD(menuSet.MENU_SET_CD.StrongValue);
                for (int iDetail = 0; iDetail < listMenuSetDetail.Count; iDetail++)
                {
                    MenuSetDetailDTO menuSetDetailDTO = listMenuSetDetail[iDetail];

                    // Load description of each MenuSub
                    DataTable dtMenuSubDescription = bizMenuSub.LoadMenuSubWithLang(menuSetDetailDTO.MENU_SUB_CD, langCD);


                    MenuRegisterUIDM.MenuSub menuSub = new MenuRegisterUIDM.MenuSub(menuSet);
                    menuSub.MENU_SUB_CD.Value = menuSetDetailDTO.MENU_SUB_CD.Value;
                    if (dtMenuSubDescription.Rows.Count > 0)
                    {
                        menuSub.MENU_SUB_NAME.Value = dtMenuSubDescription.Rows[0][(int)MenuSubDTO.eColumns.MENU_SUB_NAME];
                        menuSub.MENU_SUB_DESC.Value = dtMenuSubDescription.Rows[0][(int)MenuSubLangDTO.eColumns.MENU_SUB_DESC];
                    }


                    // Add menuSub object into MenuSet object.
                    menuSet.ListMenuSub.Add(menuSub);
                }

                model.ListMenuHierachy.Add(menuSet);
            }

            return(model);
        }
Beispiel #5
0
        internal int AddMenuSetDetail(string MenuSetCD, string MenuSubCD)
        {
            MenuSetMaintenanceBIZ biz = new MenuSetMaintenanceBIZ();
            MenuSetDetailDTO      dto = new MenuSetDetailDTO();

            dto.MENU_SET_CD.Value = MenuSetCD;
            dto.MENU_SUB_CD.Value = MenuSubCD;
            dto.DISP_SEQ.Value    = GetLastDisplaySEQ(MenuSetCD) + 1;
            dto.CRT_BY            = CommonLib.Common.CurrentUserInfomation.UserCD;
            dto.CRT_DATE.Value    = DateTime.Now;
            dto.CRT_MACHINE       = CommonLib.Common.CurrentUserInfomation.Machine;
            dto.UPD_BY            = CommonLib.Common.CurrentUserInfomation.UserCD;
            dto.UPD_DATE.Value    = DateTime.Now;
            dto.UPD_MACHINE       = CommonLib.Common.CurrentUserInfomation.Machine;
            return(biz.AddMenuSetDetail(dto));
        }
Beispiel #6
0
        internal int UpdateMenuSetDetailWithoutPK(MenuSetDetailDTO dto)
        {
            CommonLib.Common.CurrentDatabase.KeepConnection = true;
            CommonLib.Common.CurrentDatabase.BeginTransaction();

            try
            {
                IMenuSetDetailDAO dao = DAOFactory.CreateMenuSetDetailDAO(CommonLib.Common.CurrentDatabase);
                dao.UpdateWithoutPK(null, dto);
                CommonLib.Common.CurrentDatabase.Commit();
                return(1);
            }
            catch
            {
                CommonLib.Common.CurrentDatabase.Rollback();
                throw;
            }
        }
Beispiel #7
0
        internal int DeleteMenuSetDetail(MenuSetDetailDTO dto)
        {
            CommonLib.Common.CurrentDatabase.KeepConnection = true;
            CommonLib.Common.CurrentDatabase.BeginTransaction();

            try
            {
                IMenuSetDetailDAO dao = DAOFactory.CreateMenuSetDetailDAO(CommonLib.Common.CurrentDatabase);
                dao.Delete(null, dto.MENU_SUB_CD, dto.MENU_SET_CD);
                CommonLib.Common.CurrentDatabase.Commit();
                return(1);
            }
            catch
            {
                CommonLib.Common.CurrentDatabase.Rollback();
                throw;
            }
        }
Beispiel #8
0
        internal void UpdateDisplaySEQ(string MenuSetCD, string MenuSubCD_UP, string MenuSubCD_DOWN, int DisplaySQ_UP, int DisplaySQ_DOWN)
        {
            MenuSetMaintenanceBIZ biz = new MenuSetMaintenanceBIZ();
            MenuSetDetailDTO      dto = new MenuSetDetailDTO();

            dto.MENU_SET_CD.Value = MenuSetCD;
            dto.MENU_SUB_CD.Value = MenuSubCD_UP;
            dto.DISP_SEQ.Value    = DisplaySQ_UP;

            dto.UPD_BY         = CommonLib.Common.CurrentUserInfomation.UserCD;
            dto.UPD_DATE.Value = DateTime.Now;
            dto.UPD_MACHINE    = CommonLib.Common.CurrentUserInfomation.Machine;
            biz.UpdateMenuSetDetailWithoutPK(dto);

            dto.MENU_SET_CD.Value = MenuSetCD;
            dto.MENU_SUB_CD.Value = MenuSubCD_DOWN;
            dto.DISP_SEQ.Value    = DisplaySQ_DOWN;
            biz.UpdateMenuSetDetailWithoutPK(dto);
        }
Beispiel #9
0
        /// <summary>
        /// Insert new record into database.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNew(Database database, MenuSetDetailDTO data)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" INSERT INTO " + data.TableName + "(");
            sb.AppendLine("  " + MenuSetDetailDTO.eColumns.MENU_SUB_CD);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.MENU_SET_CD);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.DISP_SEQ);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.CRT_BY);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.CRT_DATE);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.CRT_MACHINE);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_BY);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_DATE);
            sb.AppendLine("  ," + MenuSetDetailDTO.eColumns.UPD_MACHINE);
            sb.AppendLine(") VALUES(");
            sb.AppendLine("   :MENU_SUB_CD");
            sb.AppendLine("   ,:MENU_SET_CD");
            sb.AppendLine("   ,:DISP_SEQ");
            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("MENU_SUB_CD", DataType.VarChar, data.MENU_SUB_CD.Value);
            req.Parameters.Add("MENU_SET_CD", DataType.VarChar, data.MENU_SET_CD.Value);
            req.Parameters.Add("DISP_SEQ", DataType.Number, data.DISP_SEQ.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));
        }
Beispiel #10
0
        internal int AddMenuSetDetail(MenuSetDetailDTO dto)
        {
            IMenuSetDetailDAO dao = DAOFactory.CreateMenuSetDetailDAO(CommonLib.Common.CurrentDatabase);

            return(dao.AddNew(null, dto));
        }