public JsonResult Edit(JMP.MDL.jmp_merchant model) { var json = new JsonResponseModel { success = 1, msg = "" }; var bll = new JMP.BLL.jmp_merchant(); var exsits = bll.GetModelList(string.Format("m_loginname='{0}'", model.m_loginname)); if (exsits.Count <= 0) { json.success = 0; json.msg = "数据不存在"; return(Json(json)); } model.m_realname = model.m_realname.Trim(); var entity = exsits[0]; Logger.ModifyLog("修改商户信息", entity, model); entity.m_realname = model.m_realname; entity.m_pwd = DESEncrypt.Encrypt(model.m_pwd); bll.Update(entity); json.success = 1; json.msg = "操作成功"; return(Json(json)); }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_merchant GetModel(string m_loginname) { StringBuilder strSql = new StringBuilder(); strSql.Append("select m_id, m_loginname, m_pwd, m_realname, m_count, m_state "); strSql.Append(" from jmp_merchant "); strSql.Append(" where m_loginname=@m_loginname"); SqlParameter[] parameters = { new SqlParameter("@m_loginname", SqlDbType.NVarChar, -1) }; parameters[0].Value = m_loginname; JMP.MDL.jmp_merchant model = new JMP.MDL.jmp_merchant(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["m_id"].ToString() != "") { model.m_id = int.Parse(ds.Tables[0].Rows[0]["m_id"].ToString()); } model.m_loginname = ds.Tables[0].Rows[0]["m_loginname"].ToString(); model.m_pwd = ds.Tables[0].Rows[0]["m_pwd"].ToString(); model.m_realname = ds.Tables[0].Rows[0]["m_realname"].ToString(); if (ds.Tables[0].Rows[0]["m_count"].ToString() != "") { model.m_count = int.Parse(ds.Tables[0].Rows[0]["m_count"].ToString()); } if (ds.Tables[0].Rows[0]["m_state"].ToString() != "") { model.m_state = int.Parse(ds.Tables[0].Rows[0]["m_state"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_merchant model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_merchant set "); strSql.Append(" m_loginname = @m_loginname , "); strSql.Append(" m_pwd = @m_pwd , "); strSql.Append(" m_realname = @m_realname , "); strSql.Append(" m_count = @m_count , "); strSql.Append(" m_state = @m_state "); strSql.Append(" where m_id=@m_id "); SqlParameter[] parameters = { new SqlParameter("@m_id", SqlDbType.Int, 4), new SqlParameter("@m_loginname", SqlDbType.NVarChar, -1), new SqlParameter("@m_pwd", SqlDbType.NVarChar, -1), new SqlParameter("@m_realname", SqlDbType.NVarChar, -1), new SqlParameter("@m_count", SqlDbType.Int, 4), new SqlParameter("@m_state", SqlDbType.Int, 4) }; parameters[0].Value = model.m_id; parameters[1].Value = model.m_loginname; parameters[2].Value = model.m_pwd; parameters[3].Value = model.m_realname; parameters[4].Value = model.m_count; parameters[5].Value = model.m_state; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public JsonResult Create(JMP.MDL.jmp_merchant model) { var json = new JsonResponseModel { success = 1, msg = "" }; var bll = new JMP.BLL.jmp_merchant(); model.m_loginname = model.m_loginname.Trim(); var exsits = bll.GetModelList(string.Format("m_loginname='{0}'", model.m_loginname)); if (exsits.Count > 0) { json.success = 0; json.msg = "登录名已存在"; return(Json(json)); } model.m_realname = model.m_realname.Trim(); model.m_pwd = DESEncrypt.Encrypt(model.m_pwd); bll.Add(model); Logger.CreateLog("信息商户信息", model); json.success = 1; json.msg = "操作成功"; return(Json(json)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_merchant model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_merchant("); strSql.Append("m_loginname,m_pwd,m_realname,m_count,m_state"); strSql.Append(") values ("); strSql.Append("@m_loginname,@m_pwd,@m_realname,@m_count,@m_state"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@m_loginname", SqlDbType.NVarChar, -1), new SqlParameter("@m_pwd", SqlDbType.NVarChar, -1), new SqlParameter("@m_realname", SqlDbType.NVarChar, -1), new SqlParameter("@m_count", SqlDbType.Int, 4), new SqlParameter("@m_state", SqlDbType.Int, 4) }; parameters[0].Value = model.m_loginname; parameters[1].Value = model.m_pwd; parameters[2].Value = model.m_realname; parameters[3].Value = model.m_count; parameters[4].Value = model.m_state; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }