public static long Insert(c_voteitemEntity item) { long id = 0; try { DataTable dt = DBAccess.DataAccess.Miou_GetDataSetBySql(DBAccess.LogUName, string.Format("select * from {0} where {1} = {2} ;", tableName, keyName, 0)).Tables[0]; dt.TableName = tableName; DataRow dr = dt.NewRow(); item.createtime = DateTime.Now; item.lasttime = item.createtime; DBAccess.FillDataRow(ref dr, item); List <long> ids = new List <long>(); dt.Rows.Add(dr); if (DBAccess.DataAccess.Miou_UpdateDataTablesNoTranWithIndentity(DBAccess.LogUName , new List <DataTable> { dt }, out ids).StartsWith("000")) { if (ids.Count > 0) { id = ids[0]; } } } catch (Exception ex) { string ss = ex.ToString(); } return(id); }
public static bool Update(c_voteitemEntity item, ref string info) { bool rv = true; try { DataTable dt = DBAccess.DataAccess.Miou_GetDataSetBySql(DBAccess.LogUName, string.Format("select * from {0} where {1} = {2} ;", tableName, keyName, item.svoteid)).Tables[0]; if (dt.Rows.Count > 0) { item.lasttime = DateTime.Now; DataRow dr = dt.Rows[0]; DBAccess.FillDataRow(ref dr, item); string vs = DBAccess.DataAccess.Miou_UpdateDataSet(DBAccess.LogUName, tableName, "*", "1<>1", "", dt); if (!vs.StartsWith("000000")) { rv = false; info = vs.Substring(6); } } else { rv = false; info = "找不到记录!"; } } catch (Exception ex) { info = ex.Message; rv = false; } return(rv); }
public static c_voteitemEntity GetByKeyId(int id, ref string info) { try { c_voteitemEntity entity = new c_voteitemEntity(); DataTable dt = DBAccess.DataAccess.Miou_GetDataSetBySql(DBAccess.LogUName, string.Format("select * from {0} where {1} = {2} ;", tableName, keyName, id)).Tables[0]; var list = DBAccess.GetEntityList <c_voteitemEntity>(dt); if (list != null && list.Count > 0) { entity = list[0]; } return(entity); } catch (Exception ex) { info = ex.Message; return(new c_voteitemEntity()); } }
public JsonResult submitvoteitem(string title, int vid) { if (!Common.HeistMon.HMon.GetInstance().AddMon("submitvote_" + base.GetUserid(), 20)) { this.HttpContext.Response.Write("FireWall!"); this.HttpContext.Response.End(); return(null); } AjaxResult ajax = new AjaxResult(); ajax.ErrorMessage = ""; ajax.RetCode = 1; if (string.IsNullOrEmpty(title.Trim())) { ajax.ErrorMessage = "投票项目名未填."; return(Json(ajax)); } var u = GetUser(); if (u == null || u.uid <= 0) { ajax.ErrorMessage = "用户登录超时,请重新登录."; return(Json(ajax)); } string info = ""; var list = c_voteDal.GetListByWhere(" and uid=" + u.uid + " and voteid=" + vid, ref info); if (list == null || list.Count == 0) { ajax.ErrorMessage = "数据未找到."; return(Json(ajax)); } if (list[0].enddate <= DateTime.Now.Date) { ajax.ErrorMessage = "投票已结束,不能操作."; return(Json(ajax)); } if (list[0].votestatus != 0) { ajax.ErrorMessage = "投票已结束,不能操作."; return(Json(ajax)); } var slist = c_voteitemDal.GetListByWhere(" and voteid=" + vid, ref info); if (slist.Count > 10) { ajax.ErrorMessage = "投票项不能超过10项."; return(Json(ajax)); } c_voteitemEntity vote = new c_voteitemEntity(); vote.voteid = vid; vote.lasttime = DateTime.Now; vote.title = title; vote.createtime = DateTime.Now; if (c_voteitemDal.Insert(vote) > 0) { ajax.ErrorMessage = vid.ToString(); } else { ajax.ErrorMessage = "保存失败,请重试试."; return(Json(ajax)); } ajax.RetCode = 0; return(Json(ajax)); }