/// <summary> /// 得到一个对象实体 /// </summary> public Model.message DataRowToModel(DataRow row) { Model.message model = new Model.message(); if (row != null) { if (row["MSGCD"] != null) { model.MSGCD = row["MSGCD"].ToString(); } if (row["MSG"] != null) { model.MSG = row["MSG"].ToString(); } if (row["RLZBH"] != null) { model.RLZBH = row["RLZBH"].ToString(); } if (row["RLR"] != null) { model.RLR = row["RLR"].ToString(); } if (row["RLSJ"] != null) { model.RLSJ = row["RLSJ"].ToString(); } if (row["RLDMM"] != null) { model.RLDMM = row["RLDMM"].ToString(); } } return(model); }
//在个人信息界面显示导师信息 public Model.message GetModel(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,name,sex,grade,major,class,phone,email,introduce,academy from stupasswordtable "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Char, 11) }; parameters[0].Value = id; Model.message model = new Model.message(); DataTable dt = SqlDbHelper.ExecuteDataTable(strSql.ToString(), CommandType.Text, parameters); if (dt.Rows.Count > 0) { model.id = dt.Rows[0]["id"].ToString(); model.name = dt.Rows[0]["name"].ToString(); model.sex = dt.Rows[0]["sex"].ToString(); model.grade = dt.Rows[0]["grade"].ToString(); model.major = dt.Rows[0]["major"].ToString(); model.Class = dt.Rows[0]["class"].ToString(); model.phone = dt.Rows[0]["phone"].ToString(); model.email = dt.Rows[0]["email"].ToString(); model.introduce = dt.Rows[0]["introduce"].ToString(); model.academy = dt.Rows[0]["academy"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.message model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update message set "); if (model.MSG != null) { strSql.Append("MSG='" + model.MSG + "',"); } else { strSql.Append("MSG= null ,"); } if (model.RLZBH != null) { strSql.Append("RLZBH='" + model.RLZBH + "',"); } else { strSql.Append("RLZBH= null ,"); } if (model.RLR != null) { strSql.Append("RLR='" + model.RLR + "',"); } else { strSql.Append("RLR= null ,"); } if (model.RLSJ != null) { strSql.Append("RLSJ='" + model.RLSJ + "',"); } else { strSql.Append("RLSJ= null ,"); } if (model.RLDMM != null) { strSql.Append("RLDMM='" + model.RLDMM + "',"); } else { strSql.Append("RLDMM= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where MSGCD='" + model.MSGCD + "' "); int rowsAffected = DbHelperMySql.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.message model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.MSGCD != null) { strSql1.Append("MSGCD,"); strSql2.Append("'" + model.MSGCD + "',"); } if (model.MSG != null) { strSql1.Append("MSG,"); strSql2.Append("'" + model.MSG + "',"); } if (model.RLZBH != null) { strSql1.Append("RLZBH,"); strSql2.Append("'" + model.RLZBH + "',"); } if (model.RLR != null) { strSql1.Append("RLR,"); strSql2.Append("'" + model.RLR + "',"); } if (model.RLSJ != null) { strSql1.Append("RLSJ,"); strSql2.Append("'" + model.RLSJ + "',"); } if (model.RLDMM != null) { strSql1.Append("RLDMM,"); strSql2.Append("'" + model.RLDMM + "',"); } strSql.Append("insert into message("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperMySql.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
public void t() { var model = new Model.message(); model.id = 3; model.state = 1; var bll = new BLL.messageBLL(); bll.Update(model, new[] { "id", "state" }); if (!bll.Exist(p => p.id == 3)) { Console.WriteLine(true); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.message GetModel(string MSGCD) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" MSGCD,MSG,RLZBH,RLR,RLSJ,RLDMM "); strSql.Append(" from message "); strSql.Append(" where MSGCD='" + MSGCD + "' "); Model.message model = new Model.message(); DataSet ds = DbHelperMySql.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void stu_message_Load(object sender, EventArgs e) { BLL.message bll = new BLL.message(); Model.message model = bll.GetModel(id);//绑定账号 if (model == null) { MessageBox.Show("数据查询出错"); return; } else { name_stu.Text = model.name; sex_stu.Text = model.sex; number_stu.Text = model.id; major_stu.Text = model.major; grade.Text = model.grade; ban.Text = model.Class; phone.Text = model.phone; email.Text = model.email; textBox1.Text = model.introduce; } }
/// <summary> /// 发送消息 /// </summary> /// <param name="title"></param> /// <param name="remark"></param> /// <param name="receiverId">接收者</param> /// <param name="senderId">发送者0为系统</param> /// <param name="type">类型0系统1站内信</param> /// <returns></returns> public static bool sendMessage(string title,string remark,int receiverId,int senderId,int type ) { try { BLL.message mbll = new BLL.message(); Model.message model = new Model.message(); model.receiverId = receiverId; model.receiverName = new BLL.users().GetModel(receiverId).userName; model.senderId = senderId; if (senderId == 0) { model.senderName = "系统"; } else { model.senderName = new BLL.users().GetModel(senderId).userName; } model.title = title; model.remark = remark; model.type = type; model.addTime = DateTime.Now; model.status = StatusHelpercs.Message_Status_UnRead; mbll.Add(model); return true; } catch { return false; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.message GetModel(string MSGCD) { StringBuilder strSql=new StringBuilder(); strSql.Append("select "); strSql.Append(" MSGCD,MSG,RLZBH,RLR,RLSJ,RLDMM "); strSql.Append(" from message "); strSql.Append(" where MSGCD='"+MSGCD+"' " ); Model.message model=new Model.message(); DataSet ds=DbHelperMySql.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.message DataRowToModel(DataRow row) { Model.message model=new Model.message(); if (row != null) { if(row["MSGCD"]!=null) { model.MSGCD=row["MSGCD"].ToString(); } if(row["MSG"]!=null) { model.MSG=row["MSG"].ToString(); } if(row["RLZBH"]!=null) { model.RLZBH=row["RLZBH"].ToString(); } if(row["RLR"]!=null) { model.RLR=row["RLR"].ToString(); } if(row["RLSJ"]!=null) { model.RLSJ=row["RLSJ"].ToString(); } if(row["RLDMM"]!=null) { model.RLDMM=row["RLDMM"].ToString(); } } return model; }