/// <summary> /// 添加合作信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult addCooperationApplication(JMP.MDL.CoCooperationApplication model) { object retJson = new { success = 0, msg = "操作失败" }; JMP.BLL.CoCooperationApplication bll = new JMP.BLL.CoCooperationApplication(); model.EmailAddress = string.IsNullOrEmpty(model.EmailAddress) ? "" : model.EmailAddress; model.CreatedOn = DateTime.Now; model.State = 0; try { int cg = bll.Add(model); if (cg > 0) { retJson = new { success = 1, msg = "发送成功" }; } else { retJson = new { success = 0, msg = "发送失败" }; } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString(); //报错信息 JMP.TOOL.AddLocLog.AddLog(1, 4, "", "官网,商务咨询添加报错", "报错信息:" + bcxx); //写入报错日志 retJson = new { success = 0, msg = "操作失败" }; } return(Json(retJson)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.CoCooperationApplication model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CoCooperationApplication("); strSql.Append("LatestReadTime,GrabbedDate,GrabbedById,GrabbedByName,State,Name,EmailAddress,MobilePhone,QQ,Website,RequestContent,CreatedOn,ReadCount"); strSql.Append(") values ("); strSql.Append("@LatestReadTime,@GrabbedDate,@GrabbedById,@GrabbedByName,@State,@Name,@EmailAddress,@MobilePhone,@QQ,@Website,@RequestContent,@CreatedOn,@ReadCount"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@LatestReadTime", SqlDbType.DateTime), new SqlParameter("@GrabbedDate", SqlDbType.DateTime), new SqlParameter("@GrabbedById", SqlDbType.Int, 4), new SqlParameter("@GrabbedByName", SqlDbType.NVarChar, 50), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 255), new SqlParameter("@MobilePhone", SqlDbType.NVarChar, 20), new SqlParameter("@QQ", SqlDbType.NVarChar, 15), new SqlParameter("@Website", SqlDbType.NVarChar, 255), new SqlParameter("@RequestContent", SqlDbType.NVarChar, -1), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@ReadCount", SqlDbType.Int, 4) }; parameters[0].Value = model.LatestReadTime; parameters[1].Value = model.GrabbedDate; parameters[2].Value = model.GrabbedById; parameters[3].Value = model.GrabbedByName; parameters[4].Value = model.State; parameters[5].Value = model.Name; parameters[6].Value = model.EmailAddress; parameters[7].Value = model.MobilePhone; parameters[8].Value = model.QQ; parameters[9].Value = model.Website; parameters[10].Value = model.RequestContent; parameters[11].Value = model.CreatedOn; parameters[12].Value = model.ReadCount; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.CoCooperationApplication model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CoCooperationApplication set "); strSql.Append(" LatestReadTime = @LatestReadTime , "); strSql.Append(" GrabbedDate = @GrabbedDate , "); strSql.Append(" GrabbedById = @GrabbedById , "); strSql.Append(" GrabbedByName = @GrabbedByName , "); strSql.Append(" State = @State , "); strSql.Append(" Name = @Name , "); strSql.Append(" EmailAddress = @EmailAddress , "); strSql.Append(" MobilePhone = @MobilePhone , "); strSql.Append(" QQ = @QQ , "); strSql.Append(" Website = @Website , "); strSql.Append(" RequestContent = @RequestContent , "); strSql.Append(" CreatedOn = @CreatedOn , "); strSql.Append(" ReadCount = @ReadCount "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@LatestReadTime", SqlDbType.DateTime), new SqlParameter("@GrabbedDate", SqlDbType.DateTime), new SqlParameter("@GrabbedById", SqlDbType.Int, 4), new SqlParameter("@GrabbedByName", SqlDbType.NVarChar, 50), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 255), new SqlParameter("@MobilePhone", SqlDbType.NVarChar, 20), new SqlParameter("@QQ", SqlDbType.NVarChar, 15), new SqlParameter("@Website", SqlDbType.NVarChar, 255), new SqlParameter("@RequestContent", SqlDbType.NVarChar, -1), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@ReadCount", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.LatestReadTime; parameters[2].Value = model.GrabbedDate; parameters[3].Value = model.GrabbedById; parameters[4].Value = model.GrabbedByName; parameters[5].Value = model.State; parameters[6].Value = model.Name; parameters[7].Value = model.EmailAddress; parameters[8].Value = model.MobilePhone; parameters[9].Value = model.QQ; parameters[10].Value = model.Website; parameters[11].Value = model.RequestContent; parameters[12].Value = model.CreatedOn; parameters[13].Value = model.ReadCount; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.CoCooperationApplication GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, LatestReadTime, GrabbedDate, GrabbedById, GrabbedByName, State, Name, EmailAddress, MobilePhone, QQ, Website, RequestContent, CreatedOn, ReadCount "); strSql.Append(" from CoCooperationApplication "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; JMP.MDL.CoCooperationApplication model = new JMP.MDL.CoCooperationApplication(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["LatestReadTime"].ToString() != "") { model.LatestReadTime = DateTime.Parse(ds.Tables[0].Rows[0]["LatestReadTime"].ToString()); } if (ds.Tables[0].Rows[0]["GrabbedDate"].ToString() != "") { model.GrabbedDate = DateTime.Parse(ds.Tables[0].Rows[0]["GrabbedDate"].ToString()); } if (ds.Tables[0].Rows[0]["GrabbedById"].ToString() != "") { model.GrabbedById = int.Parse(ds.Tables[0].Rows[0]["GrabbedById"].ToString()); } model.GrabbedByName = ds.Tables[0].Rows[0]["GrabbedByName"].ToString(); if (ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.EmailAddress = ds.Tables[0].Rows[0]["EmailAddress"].ToString(); model.MobilePhone = ds.Tables[0].Rows[0]["MobilePhone"].ToString(); model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString(); model.Website = ds.Tables[0].Rows[0]["Website"].ToString(); model.RequestContent = ds.Tables[0].Rows[0]["RequestContent"].ToString(); if (ds.Tables[0].Rows[0]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedOn"].ToString()); } if (ds.Tables[0].Rows[0]["ReadCount"].ToString() != "") { model.ReadCount = int.Parse(ds.Tables[0].Rows[0]["ReadCount"].ToString()); } return(model); } else { return(null); } }