Example #1
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            VoteItemInfo voteItem = new VoteItemInfo();

            voteItem.ID = RequestHelper.GetQueryString <int>("ID");

            voteItem.VoteID          = VoteBLL.ReadVoteFullFatherID(Convert.ToInt32(VoteType.Text));
            voteItem.ItemName        = ItemName.Text;
            voteItem.Department      = Department.Text;
            voteItem.Image           = Photo.Text;
            voteItem.Solution        = Solution.Text;
            voteItem.Point           = Point.Text;
            voteItem.CoverDepartment = CoverDepartment.Text;
            voteItem.Detail          = Content.Value;
            voteItem.Exp1            = MobileContent.Value;//手机站内容
            voteItem.OrderID         = Convert.ToInt32(OrderID.Text);
            voteItem.Exp2            = IsShow.Text;
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (voteItem.ID == int.MinValue)
            {
                CheckAdminPower("AddVoteItem", PowerCheckType.Single);
                int id = VoteItemBLL.AddVoteItem(voteItem);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("VoteItem"), id);
            }
            else
            {
                CheckAdminPower("UpdateVoteItem", PowerCheckType.Single);
                VoteItemBLL.UpdateVoteItem(voteItem);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("VoteItem"), voteItem.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
        }
Example #2
0
        public int Insert(VoteItemInfo itemInfo)
        {
            var voteItemId = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(itemInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        voteItemId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(voteItemId);
        }
Example #3
0
        private void InitForModify()
        {
            VoteItemInfo dataById = SinGooCMS.BLL.VoteItem.GetDataById(base.OpID);

            this.TextBox1.Text = dataById.VoteOption;
            this.TextBox2.Text = dataById.VoteNum.ToString();
        }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         base.CheckAdminPower("ReadVoteItem", PowerCheckType.Single);
         string queryString = RequestHelper.GetQueryString <string>("Action");
         this.voteID = RequestHelper.GetQueryString <int>("VoteID");
         int id = RequestHelper.GetQueryString <int>("ItemID");
         if ((queryString != string.Empty) && (id != -2147483648))
         {
             string str2 = queryString;
             if (str2 != null)
             {
                 if (!(str2 == "Up"))
                 {
                     if (str2 == "Down")
                     {
                         VoteItemBLL.ChangeVoteItemOrder(ChangeAction.Down, id);
                     }
                 }
                 else
                 {
                     VoteItemBLL.ChangeVoteItemOrder(ChangeAction.Up, id);
                 }
             }
         }
         int num2 = RequestHelper.GetQueryString <int>("ID");
         if (num2 != -2147483648)
         {
             VoteItemInfo info = VoteItemBLL.ReadVoteItem(num2);
             this.ItemName.Text = info.ItemName;
         }
         base.BindControl(VoteItemBLL.ReadVoteItemByVote(this.voteID), this.RecordList);
     }
 }
Example #5
0
        public int Insert(VoteItemInfo itemInfo)
        {
            var voteItemID = 0;

            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(itemInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, SQL_INSERT, parms);

                        voteItemID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(voteItemID);
        }
Example #6
0
        public void Update(VoteItemInfo itemInfo)
        {
            IDataParameter[] parms = null;
            var SQL_UPDATE         = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(itemInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            ExecuteNonQuery(SQL_UPDATE, parms);
        }
Example #7
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         int          @int     = WebUtils.GetInt((sender as LinkButton).CommandArgument);
         VoteItemInfo dataById = SinGooCMS.BLL.VoteItem.GetDataById(@int);
         if (dataById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa");
         }
         else if (SinGooCMS.BLL.VoteItem.DeleteWithLog(@int))
         {
             this.BindData();
             PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除在线调查选项[" + dataById.VoteOption + "] thành công");
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
         }
         else
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
         }
     }
 }
Example #8
0
 /// <summary>
 /// 增加一条投票选项数据
 /// </summary>
 /// <param name="voteItem">投票选项模型变量</param>
 public static int AddVoteItem(VoteItemInfo voteItem)
 {
     voteItem.ID = dal.AddVoteItem(voteItem);
     //VoteBLL.ChangeVoteCount(VoteBLL.GetLastClassID(voteItem.VoteID), ChangeAction.Plus);
     VoteBLL.ChangeVoteCountByGeneral(voteItem.ID.ToString(), ChangeAction.Plus);
     return(voteItem.ID);
 }
Example #9
0
 public void UpdateVoteItem(VoteItemInfo voteItem)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@itemName", SqlDbType.NVarChar) };
     pt[0].Value = voteItem.ID;
     pt[1].Value = voteItem.ItemName;
     ShopMssqlHelper.ExecuteNonQuery(ShopMssqlHelper.TablePrefix + "UpdateVoteItem", pt);
 }
Example #10
0
        public void Update(VoteItemInfo itemInfo)
        {
            IDataParameter[] parms = null;
            var sqlUpdate          = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(itemInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            ExecuteNonQuery(sqlUpdate, parms);
        }
Example #11
0
        private void btnEditVote_Click(object sender, System.EventArgs e)
        {
            if (SubsiteStoreHelper.GetVoteCounts(this.voteId) > 0)
            {
                this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
                return;
            }
            VoteInfo voteInfo = new VoteInfo();

            voteInfo.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
            voteInfo.VoteId   = this.voteId;
            voteInfo.IsBackup = this.checkIsBackup.Checked;
            int maxCheck;

            if (int.TryParse(this.txtMaxCheck.Text.Trim(), out maxCheck))
            {
                voteInfo.MaxCheck = maxCheck;
            }
            else
            {
                voteInfo.MaxCheck = -2147483648;
            }
            if (string.IsNullOrEmpty(this.txtValues.Text.Trim()))
            {
                this.ShowMsg("投票选项不能为空", false);
                return;
            }
            System.Collections.Generic.IList <VoteItemInfo> list = new System.Collections.Generic.List <VoteItemInfo>();
            string text = this.txtValues.Text.Trim().Replace("\r\n", "\n");

            string[] array = text.Replace("\n", "*").Split(new char[]
            {
                '*'
            });
            for (int i = 0; i < array.Length; i++)
            {
                VoteItemInfo voteItemInfo = new VoteItemInfo();
                if (array[i].Length > 60)
                {
                    this.ShowMsg("投票选项长度限制在60个字符以内", false);
                    return;
                }
                voteItemInfo.VoteItemName = Globals.HtmlEncode(array[i]);
                list.Add(voteItemInfo);
            }
            voteInfo.VoteItems = list;
            if (!this.ValidationVote(voteInfo))
            {
                return;
            }
            if (SubsiteStoreHelper.UpdateVote(voteInfo))
            {
                this.ShowMsg("修改投票成功", true);
                return;
            }
            this.ShowMsg("修改投票失败", false);
        }
 private void btnEditVote_Click(object sender, EventArgs e)
 {
     if (SubsiteStoreHelper.GetVoteCounts(this.voteId) > 0)
     {
         this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
     }
     else
     {
         int      num;
         VoteInfo vote = new VoteInfo();
         vote.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
         vote.VoteId   = this.voteId;
         vote.IsBackup = this.checkIsBackup.Checked;
         if (int.TryParse(this.txtMaxCheck.Text.Trim(), out num))
         {
             vote.MaxCheck = num;
         }
         else
         {
             vote.MaxCheck = -2147483648;
         }
         IList <VoteItemInfo> list = null;
         if (!string.IsNullOrEmpty(this.txtValues.Text.Trim()))
         {
             list = new List <VoteItemInfo>();
             string[] strArray = this.txtValues.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 VoteItemInfo item = new VoteItemInfo();
                 if (strArray[i].Length > 60)
                 {
                     this.ShowMsg("投票选项长度限制在60个字符以内", false);
                     return;
                 }
                 item.VoteItemName = Globals.HtmlEncode(strArray[i]);
                 list.Add(item);
             }
         }
         else
         {
             this.ShowMsg("投票选项不能为空", false);
             return;
         }
         vote.VoteItems = list;
         if (this.ValidationVote(vote))
         {
             if (SubsiteStoreHelper.UpdateVote(vote))
             {
                 this.ShowMsg("修改投票成功", true);
             }
             else
             {
                 this.ShowMsg("修改投票失败", false);
             }
         }
     }
 }
Example #13
0
 /// <summary>
 /// 增加一条投票选项数据
 /// </summary>
 /// <param name="voteItem">投票选项模型变量</param>
 public int AddVoteItem(VoteItemInfo entity)
 {
     using (var conn = new SqlConnection(connectString))
     {
         string sql = @"INSERT INTO VoteItem([VoteID],[ItemName],[VoteCount],[OrderID],[Image],[Department],[Solution],[Point],[CoverDepartment],[Detail],[Exp1],[Exp2],[Exp3],[Exp4],[Exp5]) VALUES(@VoteID,@ItemName,@VoteCount,@OrderID,@Image,@Department,@Solution,@Point,@CoverDepartment,@Detail,@Exp1,@Exp2,@Exp3,@Exp4,@Exp5);
                     select SCOPE_IDENTITY()";
         return(conn.Query <int>(sql, entity).Single());
     }
 }
Example #14
0
 public int AddVoteItem(VoteItemInfo voteItem)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@voteID", SqlDbType.Int), new SqlParameter("@itemName", SqlDbType.NVarChar), new SqlParameter("@voteCount", SqlDbType.Int), new SqlParameter("@orderID", SqlDbType.Int) };
     pt[0].Value = voteItem.VoteID;
     pt[1].Value = voteItem.ItemName;
     pt[2].Value = voteItem.VoteCount;
     pt[3].Value = voteItem.OrderID;
     return Convert.ToInt32(ShopMssqlHelper.ExecuteScalar(ShopMssqlHelper.TablePrefix + "AddVoteItem", pt));
 }
Example #15
0
        /// <summary>
        /// 更新一条投票选项数据
        /// </summary>
        /// <param name="voteItem">投票选项模型变量</param>
        public void UpdateVoteItem(VoteItemInfo entity)
        {
            using (var conn = new SqlConnection(connectString))
            {
                string sql = @"update VoteItem Set [VoteID]=@VoteID,[ItemName]=@ItemName,[VoteCount]=@VoteCount,[OrderID]=@OrderID,[Image]=@Image,[Department]=@Department,[Solution]=@Solution,[Point]=@Point,[CoverDepartment]=@CoverDepartment,[Detail]=@Detail,[Exp1]=@Exp1,[Exp2]=@Exp2,[Exp3]=@Exp3,[Exp4]=@Exp4,[Exp5]=@Exp5  WHERE [ID]=@ID";

                conn.Execute(sql, entity);
            }
        }
Example #16
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         int          queryInt     = WebUtils.GetQueryInt("voteid", 0);
         VoteItemInfo voteItemInfo = new VoteItemInfo();
         if (base.IsEdit)
         {
             voteItemInfo = SinGooCMS.BLL.VoteItem.GetDataById(base.OpID);
         }
         voteItemInfo.VoteOption = WebUtils.GetString(this.TextBox1.Text);
         voteItemInfo.VoteNum    = WebUtils.GetInt(this.TextBox2.Text);
         if (string.IsNullOrEmpty(voteItemInfo.VoteOption))
         {
             base.ShowMsg("请输入在在线调查选项名称");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 voteItemInfo.VoteID        = queryInt;
                 voteItemInfo.AutoTimeStamp = System.DateTime.Now;
                 voteItemInfo.Lang          = base.cultureLang;
                 if (SinGooCMS.BLL.VoteItem.Add(voteItemInfo) > 0)
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加在线调查选项[" + voteItemInfo.VoteOption + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("添加在线调查选项失败");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (SinGooCMS.BLL.VoteItem.Update(voteItemInfo))
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改在线调查选项[" + voteItemInfo.VoteOption + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("修改在线调查选项失败");
                 }
             }
         }
     }
 }
Example #17
0
        private void btnAddVote_Click(object sender, EventArgs e)
        {
            int      num;
            VoteInfo vote = new VoteInfo();

            vote.VoteName = Globals.HtmlEncode(txtAddVoteName.Text.Trim());
            vote.IsBackup = checkIsBackup.Checked;
            if (int.TryParse(txtMaxCheck.Text.Trim(), out num))
            {
                vote.MaxCheck = num;
            }
            else
            {
                vote.MaxCheck = -2147483648;
            }
            IList <VoteItemInfo> list = null;

            if (!string.IsNullOrEmpty(txtValues.Text.Trim()))
            {
                list = new List <VoteItemInfo>();
                string[] strArray = txtValues.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    VoteItemInfo item = new VoteItemInfo();
                    if (strArray[i].Length > 60)
                    {
                        ShowMsg("投票选项长度限制在60个字符以内", false);
                        return;
                    }
                    item.VoteItemName = Globals.HtmlEncode(strArray[i]);
                    list.Add(item);
                }
            }
            else
            {
                ShowMsg("投票选项不能为空", false);
                return;
            }
            vote.VoteItems = list;
            if (ValidationVote(vote))
            {
                if (StoreHelper.CreateVote(vote) > 0)
                {
                    ShowMsg("成功的添加了一个投票", true);
                    txtAddVoteName.Text   = string.Empty;
                    checkIsBackup.Checked = false;
                    txtMaxCheck.Text      = string.Empty;
                    txtValues.Text        = string.Empty;
                }
                else
                {
                    ShowMsg("添加投票失败", false);
                }
            }
        }
Example #18
0
        public static void UpdateVoteItem(VoteItemInfo voteItem)
        {
            VoteItemInfo info = ReadVoteItem(voteItem.ID);

            dal.UpdateVoteItem(voteItem);
            if (voteItem.VoteID != info.VoteID)
            {
                VoteBLL.ChangeVoteCount(info.VoteID, ChangeAction.Minus);
                VoteBLL.ChangeVoteCount(voteItem.VoteID, ChangeAction.Plus);
            }
        }
 public override int CreateVoteItem(VoteItemInfo voteItem, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO distro_VoteItems(VoteId, VoteItemName, ItemCount) Values(@VoteId, @VoteItemName, @ItemCount)");
     this.database.AddInParameter(sqlStringCommand, "VoteId", DbType.Int64, voteItem.VoteId);
     this.database.AddInParameter(sqlStringCommand, "VoteItemName", DbType.String, voteItem.VoteItemName);
     this.database.AddInParameter(sqlStringCommand, "ItemCount", DbType.Int32, voteItem.ItemCount);
     if (dbTran == null)
     {
         return this.database.ExecuteNonQuery(sqlStringCommand);
     }
     return this.database.ExecuteNonQuery(sqlStringCommand, dbTran);
 }
Example #20
0
 public bool UpdateVoteAll(VoteInfo vote)
 {
     try
     {
         VoteInfo voteById = this.GetVoteById(vote.VoteId);
         if ((voteById != null) && (vote.VoteItems.Count > 0))
         {
             using (IEnumerator <VoteItemInfo> enumerator = vote.VoteItems.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     Func <VoteItemInfo, bool> predicate = null;
                     VoteItemInfo item = enumerator.Current;
                     if (voteById.VoteItems.Count == 0)
                     {
                         this.CreateVoteItem(item);
                     }
                     else
                     {
                         if (predicate == null)
                         {
                             predicate = x => x.VoteItemName.Equals(item.VoteItemName);
                         }
                         if (voteById.VoteItems.Where <VoteItemInfo>(predicate).ToList <VoteItemInfo>().Count == 0)
                         {
                             this.CreateVoteItem(item);
                         }
                     }
                 }
             }
             List <string> nowId = (from q in vote.VoteItems select q.VoteItemName).ToList <string>();
             IEnumerable <VoteItemInfo> source = from x in voteById.VoteItems
                                                 where !nowId.Contains(x.VoteItemName)
                                                 select x;
             if (source.Count <VoteItemInfo>() > 0)
             {
                 foreach (VoteItemInfo info2 in source)
                 {
                     this.DeleteItem(info2.VoteItemId);
                 }
             }
         }
         else
         {
             return(false);
         }
         return(this.UpdateVote(vote));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #21
0
 public void PrepareVoteItemModel(SqlDataReader dr, List<VoteItemInfo> voteItemList)
 {
     while (dr.Read())
     {
         VoteItemInfo item = new VoteItemInfo();
         item.ID = dr.GetInt32(0);
         item.VoteID = dr.GetInt32(1);
         item.ItemName = dr[2].ToString();
         item.VoteCount = dr.GetInt32(3);
         item.OrderID = dr.GetInt32(4);
         voteItemList.Add(item);
     }
 }
Example #22
0
 public bool CreateVoteItem(VoteItemInfo item)
 {
     try
     {
         string    query            = string.Format("INSERT INTO [Hishop_VoteItems] ([VoteId],[VoteItemName],[ItemCount]) VALUES ({0},'{1}',{2})", item.VoteId, item.VoteItemName, item.ItemCount);
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
         return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #23
0
        public static int Add(VoteItemInfo entity)
        {
            int result;

            if (entity == null)
            {
                result = 0;
            }
            else
            {
                result = BizBase.dbo.InsertModel <VoteItemInfo>(entity);
            }
            return(result);
        }
Example #24
0
 public bool UpdateVoteItem(VoteItemInfo item)
 {
     try
     {
         string    query            = "UPDATE [Hishop_VoteItems] SET [VoteItemName] = @VoteItemName where VoteItemId=@VoteItemId";
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
         this.database.AddInParameter(sqlStringCommand, "VoteItemName", DbType.String, item.VoteItemName);
         this.database.AddInParameter(sqlStringCommand, "VoteItemId", DbType.Int64, item.VoteItemId);
         return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #25
0
        public override VoteItemInfo GetVoteItemById(long voteItemId)
        {
            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_VoteItems WHERE VoteItemId = @VoteItemId");
            this.database.AddInParameter(sqlStringCommand, "VoteItemId", System.Data.DbType.Int64, voteItemId);
            VoteItemInfo result = null;

            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    result = DataMapper.PopulateVoteItem(dataReader);
                }
            }
            return(result);
        }
Example #26
0
        public override IList <VoteItemInfo> GetVoteItems(long voteId)
        {
            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_VoteItems WHERE VoteId = @VoteId");
            this.database.AddInParameter(sqlStringCommand, "VoteId", System.Data.DbType.Int64, voteId);
            IList <VoteItemInfo> list = new List <VoteItemInfo>();

            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (dataReader.Read())
                {
                    VoteItemInfo item = DataMapper.PopulateVoteItem(dataReader);
                    list.Add(item);
                }
            }
            return(list);
        }
Example #27
0
        public VoteItemInfo GetVoteItem(long voteItemId)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Ecshop_VoteItems WHERE VoteItemId = @VoteItemId");

            this.database.AddInParameter(sqlStringCommand, "VoteItemId", DbType.Int64, voteItemId);
            VoteItemInfo result = null;

            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    result = DataMapper.PopulateVoteItem(dataReader);
                }
            }
            return(result);
        }
Example #28
0
        public override VoteItemInfo GetVoteItemById(long voteItemId)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_VoteItems WHERE VoteItemId = @VoteItemId");

            this.database.AddInParameter(sqlStringCommand, "VoteItemId", DbType.Int64, voteItemId);
            VoteItemInfo info = null;

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateVoteItem(reader);
                }
            }
            return(info);
        }
Example #29
0
        public bool CreateVoteItem(VoteItemInfo item)
        {
            bool result;

            try
            {
                string query = string.Format("INSERT INTO [Hishop_VoteItems] ([VoteId],[VoteItemName],[ItemCount]) VALUES ({0},'{1}',{2})", item.VoteId, item.VoteItemName, item.ItemCount);
                System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
                result = (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
            }
            catch (Exception var_2_48)
            {
                result = false;
            }
            return(result);
        }
Example #30
0
        public override IList <VoteItemInfo> GetVoteItems(long voteId)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_VoteItems WHERE VoteId = @VoteId");

            this.database.AddInParameter(sqlStringCommand, "VoteId", DbType.Int64, voteId);
            IList <VoteItemInfo> list = new List <VoteItemInfo>();

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                VoteItemInfo item = null;
                while (reader.Read())
                {
                    item = DataMapper.PopulateVoteItem(reader);
                    list.Add(item);
                }
            }
            return(list);
        }