Exemplo n.º 1
0
        public static void SetItemPlace(RewardPlaceModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("RewardPlace");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From RewardPlace Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Exemplo n.º 2
0
        public static long GetMenuID(long siteId)
        {
            SQLData.Database db     = new SQLData.Database(WebInfo.Conn);
            string           sql    = $"Select Top(1) ID From Menus Where SiteID = { siteId } And DataType = 'Reward'";
            long?            menuId = db.GetFirstValue(sql) as long?;

            if (menuId.HasValue)
            {
                return(menuId.Value);
            }

            WorkV3.Areas.Backend.Models.MenusModels menus = new Areas.Backend.Models.MenusModels
            {
                SiteID     = siteId,
                Title      = "集點",
                SN         = "Reward",
                DataType   = "Reward",
                ShowStatus = 2,
                Sort       = 1,
                Creator    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id,
                CreateTime = DateTime.Now
            };
            WorkV3.Areas.Backend.Models.DataAccess.MenusDAO.SaveInfo(menus);

            return((long)db.GetFirstValue(sql));
        }
Exemplo n.º 3
0
        //wei20180808 複製功能抄徵件
        public static void Copy(long siteId, IEnumerable <long> ids)
        {
            if (ids == null || ids.Count() == 0)
            {
                return;
            }

            long        menuId = RewardDAO.GetMenuID(siteId);
            MenusModels menu   = DataAccess.MenusDAO.GetInfo(siteId, menuId);

            SQLData.Database db = new SQLData.Database(WebInfo.Conn);
            foreach (long id in ids)
            {
                SQLData.TableObject tableObj = db.GetTableObject("Reward", id);
                if (tableObj.Count == 0)
                {
                    continue;
                }

                long newId = WorkLib.GetItem.NewSN();
                tableObj["ID"] = newId;
                //tableObj["CardNo"] = Golbal.PubFunc.AddPage(siteId, menuId, menu.SN, "Reward", "Index", true);
                tableObj["Sort"]       = 1;
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;
                tableObj.Remove("Modifier");
                tableObj.Remove("ModifyTime");

                tableObj.Insert();
            }
        }
Exemplo n.º 4
0
        public static void SetItem(RewardModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Reward");
            object objSort = db.GetFirstValue(" SELECT TOP 1 Sort FROM Reward ORDER BY Sort DESC ");
            int    maxSort = (objSort == null || objSort == DBNull.Value)? 1: (int)objSort;

            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From Reward Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;
                tableObj["Sort"]       = 1;//wei 20180726 拿掉 maxSort +

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                tableObj.Remove("Sort");

                tableObj["Modifier"]   = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;
                tableObj.Update(item.ID);
            }
        }
Exemplo n.º 5
0
        public static void SetItemText(RewardTextModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("RewardText");
            tableObj.GetDataFromObject(item);

            string sql             = "Select top 1 * From RewardText Where ID = @ID and SiteID= @SiteID ";
            ParameterCollection a1 = new ParameterCollection();

            a1.Add("ID", item.ID);
            a1.Add("SiteID", item.SiteID);
            bool isNew = db.GetFirstValue(sql, a1) == null;

            if (isNew)
            {
                tableObj["Creator"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                //tableObj.Remove("SiteID");
                //tableObj.Remove("Creator");
                //tableObj.Remove("CreateTime");

                //tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                //tableObj["ModifyTime"] = DateTime.Now;
                string a = "UPDATE RewardText  set Text =@Text ,Modifier=@Modifier,ModifyTime=@ModifyTime Where ID = @ID2 and SiteID= @SiteID2";

                SQLData.ParameterCollection paraList = new SQLData.ParameterCollection();
                paraList.Add("ID2", item.ID);
                paraList.Add("SiteID2", item.SiteID);
                paraList.Add("Text", item.Text);
                paraList.Add("Modifier", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id);
                paraList.Add("ModifyTime", DateTime.Now);
                int exeCount = db.ExecuteNonQuery(a, paraList);
            }
        }