Пример #1
0
 /// <summary>
 /// 获取主题,如果当前主题不存在,则返回最新的调查主题
 /// </summary>
 /// <param name="identify"></param>
 /// <returns></returns>
 public Vote GetTheme(int identify)
 {
     Song.Entities.Vote theme = null;
     if (identify > 0)
     {
         theme = Gateway.Default.From <Vote>().Where(Vote._.Vt_IsTheme == true && Vote._.Vt_Id == identify).ToFirst <Vote>();
     }
     //如果当前主题不存在
     if (theme == null || identify < 1)
     {
         theme = Gateway.Default.From <Vote>().Where(Vote._.Vt_IsTheme == true).OrderBy(Vote._.Vt_CrtTime.Desc).ToFirst <Vote>();
     }
     return(theme);
 }
Пример #2
0
 /// <summary>
 /// 修改是否显示的状态
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void sbShow_Click(object sender, EventArgs e)
 {
     try
     {
         StateButton ub    = (StateButton)sender;
         int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
         int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());
         //
         Song.Entities.Vote entity = Business.Do <IVote>().GetSingle(id);
         entity.Vt_IsShow = !entity.Vt_IsShow;
         Business.Do <IVote>().ItemSave(entity);
         BindData(null, null);
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Пример #3
0
 /// <summary>
 /// 设置初始界面
 /// </summary>
 private void fillTheme()
 {
     try
     {
         //设置调查主题
         Song.Entities.Vote mm;
         if (id != 0)
         {
             mm = Business.Do <IVote>().GetSingle(id);
             cbIsShow.Checked     = mm.Vt_IsShow;
             cbIsUse.Checked      = mm.Vt_IsUse;
             cbIsAllowSee.Checked = mm.Vt_IsAllowSee;
             //唯一标识
             ViewState["UID"] = mm.Vt_UniqueId;
             //调查类别,单选还是多选
             ListItem li = rbSelType.Items.FindByValue(mm.Vt_SelectType.ToString());
             if (li != null)
             {
                 li.Selected = true;
             }
             //图片
             if (mm.Vt_IsImage && !string.IsNullOrEmpty(mm.Vt_Image))
             {
                 this.imgShow.Src = Upload.Get[_uppath].Virtual + mm.Vt_ImageSmall;
             }
         }
         else
         {
             mm = new Song.Entities.Vote();
             ViewState["UID"] = WeiSha.Common.Request.UniqueID();
         }
         tbName.Text  = mm.Vt_Name;
         tbIntro.Text = mm.Vt_Intro;
         //是否为图片调查
         cbIsImg.Checked     = mm.Vt_IsImage;
         tdImageArea.Visible = mm.Vt_IsImage;
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Пример #4
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     //设置调查主题
     Song.Entities.Vote mm = null;
     try
     {
         if (id != 0)
         {
             mm = Business.Do <IVote>().GetSingle(id);
         }
         else
         {
             mm = new Song.Entities.Vote();
         }
         mm.Vt_Name   = tbName.Text;
         mm.Vt_Intro  = tbIntro.Text;
         mm.Vt_IsShow = cbIsShow.Checked;
         mm.Vt_IsUse  = cbIsUse.Checked;
         mm.Vt_Type   = 1;
         //是否允许查看结果
         mm.Vt_IsAllowSee = cbIsAllowSee.Checked;
         //是否为图片调查
         mm.Vt_IsImage = cbIsImg.Checked;
         //唯一标识
         mm.Vt_UniqueId = this.getUID();
         //调查类别,单选还是多选
         mm.Vt_SelectType = Convert.ToInt32(rbSelType.SelectedValue);
         //图片
         if (cbIsImg.Checked && fuLoad.PostedFile.FileName != "")
         {
             try
             {
                 fuLoad.UpPath       = _uppath;
                 fuLoad.IsMakeSmall  = true;
                 fuLoad.IsConvertJpg = true;
                 fuLoad.SmallHeight  = 300;
                 fuLoad.SmallWidth   = 400;
                 fuLoad.SaveAndDeleteOld(mm.Vt_Image);
                 //记录新图片文件,以及缩略图文件
                 mm.Vt_Image      = fuLoad.File.Server.FileName;
                 mm.Vt_ImageSmall = fuLoad.File.Server.SmallFileName;
                 //
                 imgShow.Src = fuLoad.File.Server.VirtualPath;
             }
             catch (Exception ex)
             {
                 this.Alert(ex.Message);
             }
         }
         if (id != 0)
         {
             Business.Do <IVote>().ItemSave(mm);
         }
         else
         {
             Business.Do <IVote>().ThemeAdd(mm);
         }
         //保存子项
         DataTable dt = Business.Do <IVote>().GetVoteItem(mm.Vt_UniqueId);
         foreach (System.Web.UI.WebControls.GridViewRow gvr in GridView1.Rows)
         {
             TextBox newName = (TextBox)(gvr.FindControl("tbItemName"));
             if (newName.Text.Trim() == "")
             {
                 continue;
             }
             //Label lbNumber = (Label)(gvr.FindControl("tbItemNumber"));
             //int iNumber = Convert.ToInt32(lbNumber.Text);
             int itemId = Convert.ToInt32(GridView1.DataKeys[gvr.RowIndex].Value);
             if (itemId > -1)
             {
                 //修改子项的记录
                 Song.Entities.Vote mod = Business.Do <IVote>().GetSingle(itemId);
                 mod.Vt_UniqueId = this.getUID();
                 mod.Vt_Name     = newName.Text;
                 mod.Vt_Tax      = gvr.RowIndex;
                 Business.Do <IVote>().ItemSave(mod);
                 //当前操作的子项id,如果已经存在于数据库,则在dt中清除,清到最后,剩下的将是不需保留的。
                 int index = -1;
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     int oid = Convert.ToInt32(dt.Rows[i]["Vt_Id"].ToString());
                     if (itemId == oid)
                     {
                         index = i;
                         break;
                     }
                 }
                 if (index > -1)
                 {
                     dt.Rows.RemoveAt(index);
                 }
             }
             else
             {
                 //新增的子项记录
                 Song.Entities.Vote add = new Song.Entities.Vote();
                 add.Vt_UniqueId = this.getUID();
                 add.Vt_Name     = newName.Text;
                 add.Vt_Tax      = gvr.RowIndex;
                 Business.Do <IVote>().ItemAdd(add);
             }
         }
         //删除剩余的
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             int oid = Convert.ToInt32(dt.Rows[i]["Vt_Id"].ToString());
             Business.Do <IVote>().ItemDelete(oid);
         }
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }