コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strOptionID = string.Empty;

            if (null == Request.QueryString["id"])
            {
                return;
            }
            strOptionID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            OptionDAL dal = new OptionDAL();
            DataSet   ds  = dal.getOptionDetail(strOptionID);

            VOTE_Option model = new VOTE_Option();

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model = DataConvert.DataRowToModel <VOTE_Option>(ds.Tables[0].Rows[0]);
            }

            //读取模板内容
            string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Vote/OptionDetail.html"));

            JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();

            context.TempData["title"]   = "微商易";
            context.TempData["ADetail"] = model;
            context.TempData["footer"]  = "奥琦微商易";

            JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
            t.Render(Response.Output);
        }
コード例 #2
0
ファイル: OptionDAL.cs プロジェクト: zhenghua75/WeiXinEasy
        /// <summary>
        /// 添加投票选项
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddVoteOption(VOTE_Option model)
        {
            string sql = @"INSERT INTO [vote_options]
                        ([ID],[SubjectID],[Title],[ico],[contentdesc],[Order],[Amount])
                 VALUES
                        (@ID,@SubjectID,@Title,@ico,@contentdesc,@Order,@Amount)";

            System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[]
            {
                new System.Data.SqlClient.SqlParameter("@ID", model.ID),
                new System.Data.SqlClient.SqlParameter("@SubjectID", model.SubjectID),
                new System.Data.SqlClient.SqlParameter("@Title", model.Title),
                new System.Data.SqlClient.SqlParameter("@ico", model.Ico),
                new System.Data.SqlClient.SqlParameter("@contentdesc", model.Contentdesc),
                new System.Data.SqlClient.SqlParameter("@Order", model.Order),
                new System.Data.SqlClient.SqlParameter("@Amount", model.Amount)
            };
            int rowsAffected = DbHelperSQL.ExecuteSql(sql.ToString(), paras);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public void saveupdate()
        {
            string       strID = Guid.NewGuid().ToString("N").ToUpper();
            VOTE_Subject model = new VOTE_Subject();

            model.ID        = strID;
            model.Subject   = Common.Common.NoHtml(Request["txtName"]);
            model.SiteCode  = GlobalSession.strSiteCode;
            model.Content   = Common.Common.NoHtml(Request["Content"]);
            model.BeginTime = Convert.ToDateTime(Request["BeginTime"]);
            model.EndTime   = Convert.ToDateTime(Request["endtime"]);
            model.IsValid   = Convert.ToInt32(Common.Common.NoHtml(Request["IsValid"]));
            SubjectDAL dal = new SubjectDAL();

            if (dal.AddVoteinfo(model))
            {
                if (Common.Common.NoHtml(Request["Option0"]) != null && Common.Common.NoHtml(Request["Option0"]) != "")
                {
                    OptionDAL   optdal   = new OptionDAL();
                    VOTE_Option optmoedl = new VOTE_Option();
                    for (int i = 0; i < 6; i++)
                    {
                        optmoedl.Title = Common.Common.NoHtml(Request["Option" + i]);
                        if (Common.Common.NoHtml(Request["Order" + i]) != null && Common.Common.NoHtml(Request["Order" + i]) != "")
                        {
                            optmoedl.Order = Convert.ToInt32(Common.Common.NoHtml(Request["Order" + i]));
                        }
                        optmoedl.ID        = Guid.NewGuid().ToString("N").ToUpper();
                        optmoedl.SubjectID = strID;
                        if (Common.Common.NoHtml(Request["Option" + i]) != null && Common.Common.NoHtml(Request["Option" + i]) != "")
                        {
                            optdal.AddVoteOption(optmoedl);
                        }
                    }
                }
                Response.Write("{\"success\":\"true\"}");
            }
            else
            {
                Response.Write("{\"success\":\"操作失败\"}");
            }
            Response.End();
        }
コード例 #4
0
ファイル: OptionDAL.cs プロジェクト: zhenghua75/WeiXinEasy
        /// <summary>
        /// 更新投票选项信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateOption(VOTE_Option model)
        {
            string safesql = "";

            safesql = "update vote_options set ";
            if (model.SubjectID != null && model.SubjectID != "")
            {
                safesql += "[SubjectID]='" + model.SubjectID + "',";
            }
            if (model.Title != null && model.Title != "")
            {
                safesql += "[Title]='" + model.Title + "',";
            }
            if (model.Ico != null && model.Ico != "")
            {
                safesql += "[Ico]='" + model.Ico + "',";
            }
            if (model.Contentdesc != null && model.Contentdesc != "")
            {
                safesql += "[Contentdesc]='" + model.Contentdesc + "',";
            }
            if (model.Order != 0)
            {
                safesql += "[Order]=" + model.Order + ",";
            }
            else
            {
                safesql += "[Order]=" + Convert.ToInt32(GetOptionValue("[Order]", model.ID)) + ",";
            }
            safesql += "[IsDel]=" + model.IsDel;
            safesql += " where id='" + model.ID + "'";
            int rowsAffected = DbHelperSQL.ExecuteSql(safesql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
 void ShowUpdateInfo()
 {
     if (strID.Trim() != null && strID.Trim() != "")
     {
         OptionDAL dal = new OptionDAL();
         DataSet   ds  = dal.getOptionDetail(strID);
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             VOTE_Option model = DataConvert.DataRowToModel <VOTE_Option>(ds.Tables[0].Rows[0]);
             hd_content.Value = model.Contentdesc;
             optitle.Text     = model.Title;
             oporder.Text     = model.Order.ToString();
             if (model.Ico != null && model.Ico != "")
             {
                 img0.Src = "../../" + model.Ico;
             }
             if (strAction == "show")
             {
                 this.btnReset.Visible = false;
                 this.btnSave.Visible  = false;
             }
         }
     }
 }
コード例 #6
0
        public void saveupdate()
        {
            VOTE_Subject model = new VOTE_Subject();

            model.ID        = strID;
            model.Subject   = Common.Common.NoHtml(Request["txtName"]);
            model.SiteCode  = GlobalSession.strSiteCode;
            model.Content   = Common.Common.NoHtml(Request["Content"]);
            model.BeginTime = Convert.ToDateTime(Request["BeginTime"]);
            model.EndTime   = Convert.ToDateTime(Request["endtime"]);
            SubjectDAL dal = new SubjectDAL();

            if (dal.UpdateVoteInfo(model))
            {
                if (Common.Common.NoHtml(Request["Option0"]) != null && Common.Common.NoHtml(Request["Option0"]) != "")
                {
                    OptionDAL   optdal     = new OptionDAL();
                    VOTE_Option optmoedl   = new VOTE_Option();
                    int         listlength = 0; optmoedl.IsDel = 1;
                    if (Request["listlength"] != null && Request["listlength"] != "")
                    {
                        listlength = Convert.ToInt32(Common.Common.NoHtml(Request["listlength"]));
                    }
                    for (int i = 0; i < listlength; i++)
                    {
                        string optiontitle = string.Empty;
                        string optionID    = string.Empty;
                        string optionOrder = string.Empty;
                        try
                        {
                            optiontitle = Common.Common.NoHtml(Request["Option" + i]);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            optionID = Common.Common.NoHtml(Request["Option" + i + "ID"]);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            optionOrder = Common.Common.NoHtml(Request["Order" + i]);
                        }
                        catch (Exception)
                        {}
                        if (optiontitle != null && optiontitle != "")
                        {
                            optmoedl.Title = optiontitle;
                            if (optionOrder != null && optionOrder != "")
                            {
                                optmoedl.Order = Convert.ToInt32(optionOrder);
                            }
                            if (optdal.IsexistOption(optionID))
                            {
                                optmoedl.ID = optionID;
                                optdal.UpdateOption(optmoedl);
                            }
                            else if (optdal.ExistOptionTile(optiontitle))
                            {
                                Response.Write("{\"success\":\"该选项已经存在\"}");
                            }
                            else
                            {
                                optmoedl.ID        = Guid.NewGuid().ToString("N").ToUpper();
                                optmoedl.SubjectID = strID;
                                if (optiontitle != null && optiontitle != "")
                                {
                                    optdal.AddVoteOption(optmoedl);
                                }
                            }
                        }
                    }
                }
                Response.Write("{\"success\":\"true\"}");
            }
            else
            {
                Response.Write("{\"success\":\"修改失败\"}");
            }
            Response.End();
        }
コード例 #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"])
            {
                Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>");
                Response.End();
            }
            //上传图像
            string strIconFileName     = string.Empty; //图像路径
            string strIconSaveFileName = string.Empty; //网址路径

            try
            {
                if (this.file0.PostedFile.FileName == "")
                {
                    strIconSaveFileName = "";
                }
                else
                {
                    if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                    }
                    if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                    {
                        System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                    }
                    string orignalName = this.file0.PostedFile.FileName;                      //获取客户机上传文件的文件名
                    string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                    if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                    {
                        MessageBox.Show(this, "文件格式有误!");
                        return;
                    }//检查文件格式
                    string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名
                    strIconFileName     = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                    strIconSaveFileName = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                    file0.PostedFile.SaveAs(strIconFileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
            }
            OptionDAL   dal   = new OptionDAL();
            VOTE_Option model = new VOTE_Option();

            if (optitle.Text.Trim() != null && optitle.Text.Trim() != "")
            {
                model.Title       = optitle.Text;
                model.Contentdesc = hd_content.Value;
                model.Ico         = strIconSaveFileName;
                model.SubjectID   = subID;
                model.IsDel       = 1;
                if (oporder.Text.Trim() != null && oporder.Text.Trim() != "")
                {
                    model.Order = Convert.ToInt32(oporder.Text);
                }
                model.ID = strID;
                if (dal.UpdateOption(model))
                {
                    MessageBox.Show(this, "操作成功!");
                }
                else
                {
                    MessageBox.Show(this, "操作失败!");
                }
            }
            else
            {
                MessageBox.Show(this, "请输入相应名称!");
            }
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Request.QueryString["sitecode"] && !string.IsNullOrEmpty(Request.QueryString["sitecode"].ToString()))
            {
                return;
            }
            if (Request["openid"] == null || Request["openid"] == "")
            {
                if (Request["username"] == null || Request["username"] == "")
                {
                    return;
                }
            }

            string strSiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());
            string strOpenID   = string.Empty;
            string strUserName = string.Empty;

            if (Request["openid"] != null && Request["openid"] != "")
            {
                if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25)
                {
                    strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString());
                }
                else
                {
                    strOpenID = Request.QueryString["openid"].ToString();
                }
            }
            else
            {
                strUserName = Common.Common.NoHtml(Request["username"]);
            }

            //取最新抢购的优惠活动
            List <VOTE_Option> MyVoteList  = new List <VOTE_Option>();
            VoteUsersDAL       voteuserdal = new VoteUsersDAL();

            DataSet myvoteds;

            if (Request["openid"] != null && Request["openid"] != "")
            {
                myvoteds = voteuserdal.GetMyVoteList(" AND a.OpenID = '" + strOpenID + "' ");
            }
            else
            {
                myvoteds = voteuserdal.GetMyVoteList(" AND a.UserName = '******' ");
            }
            string VoteTitle   = string.Empty;
            string VoteIco     = string.Empty;
            string VoteContent = string.Empty;

            if (null != myvoteds && myvoteds.Tables.Count > 0 && myvoteds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in myvoteds.Tables[0].Rows)
                {
                    //VoteUsers model = DataConvert.DataRowToModel<VoteUsers>(row);
                    VOTE_Option model = DataConvert.DataRowToModel <VOTE_Option>(row);
                    MyVoteList.Add(model);
                }
            }
            else
            {
                strInfo = "亲,你还没有参加过任何投票!";
            }
            //读取模板内容
            string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Vote/MyVote.html"));

            JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();

            context.TempData["sitecode"]   = strSiteCode;
            context.TempData["openid"]     = strOpenID;
            context.TempData["title"]      = "投票列表";
            context.TempData["MyVoteList"] = MyVoteList;
            context.TempData["noinfo"]     = strInfo;
            context.TempData["footer"]     = "奥琦微商易";

            JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
            t.Render(Response.Output);
        }