public static long Insert(c_voteEntity 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_voteEntity 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.voteid)).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_voteEntity GetByKeyId(int id, ref string info) { try { c_voteEntity entity = new c_voteEntity(); 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_voteEntity>(dt); if (list != null && list.Count > 0) { entity = list[0]; } return(entity); } catch (Exception ex) { info = ex.Message; return(new c_voteEntity()); } }
public JsonResult submitvote(string title, string remark, DateTime enddte, int vid = 0) { 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; var u = GetUser(); if (u == null || u.uid <= 0) { ajax.ErrorMessage = "用户登录超时,请重新登录."; return(Json(ajax)); } if (u.isvip == 0 && u.vipdate <= DateTime.Now.Date) { ajax.ErrorMessage = "您无发起投票的权限,请联系社区相关人员."; return(Json(ajax)); } if (string.IsNullOrEmpty(title.Trim())) { ajax.ErrorMessage = "投票主题未填."; return(Json(ajax)); } if (enddte < DateTime.Now.Date.AddDays(1)) { ajax.ErrorMessage = "日期不能小于当天."; return(Json(ajax)); } double addvoteprice = 0; double joinvoteprice = 0; if (vid == 0) { if (LinkTokenSQ.MvcApplication.Syspar.ContainsKey("addvoteprice")) { double.TryParse(LinkTokenSQ.MvcApplication.Syspar["addvoteprice"].keyvalue, out addvoteprice); } if (LinkTokenSQ.MvcApplication.Syspar.ContainsKey("joinvoteprice")) { double.TryParse(LinkTokenSQ.MvcApplication.Syspar["joinvoteprice"].keyvalue, out joinvoteprice); } } string info = ""; c_voteEntity vote = new c_voteEntity(); if (vid > 0) { var list = c_voteDal.GetListByWhere(string.Format(" and voteid={0} and uid={1} ", vid, u.uid), ref info); if (list == null || list.Count == 0) { ajax.ErrorMessage = "数据未找到."; return(Json(ajax)); } vote = list[0]; } else { vote.createtime = DateTime.Now; } vote.lasttime = DateTime.Now; vote.votetitle = title; vote.votestatus = 0; vote.votetype = 0; vote.remark = remark; vote.paywkcamount = addvoteprice; vote.uid = u.uid; vote.voteid = vid; vote.enddate = enddte; if (vote.voteid == 0) { long voteid = c_voteDal.Insert(vote); if (voteid > 0) { if (addvoteprice > 0) { if (DBAccess.UserPay(u.uid, addvoteprice) != 1) { c_voteDal.Del(voteid.ToString(), ref info); ajax.ErrorMessage = "支付失败,可能账户余额不足."; return(Json(ajax)); } } ajax.ErrorMessage = voteid.ToString(); } else { ajax.ErrorMessage = "保存失败,请重试试."; return(Json(ajax)); } } else { if (vote.votestatus > 3) { ajax.ErrorMessage = "不能修改."; return(Json(ajax)); } if (!c_voteDal.Update(vote, ref info)) { ajax.ErrorMessage = "保存失败,请重试试."; return(Json(ajax)); } else { ajax.ErrorMessage = "已保存."; return(Json(ajax)); } } ajax.RetCode = 0; return(Json(ajax)); }