public bool UpdateStat(SchSystem.Model.WebSchChn model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update WebSchChn set "); strSql.Append("Stat=@Stat"); strSql.Append(" where ChnId=@ChnId"); SqlParameter[] parameters = { new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@ChnId", SqlDbType.Int, 4) }; parameters[0].Value = model.Stat;; parameters[1].Value = model.ChnId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { //先得到操作类型 SchSystem.BLL.WebSchChn schchn_bll = new SchSystem.BLL.WebSchChn(); SchSystem.Model.WebSchChn schchn_model = new SchSystem.Model.WebSchChn(); SysType = Com.Public.SqlEncStr(Request.Params["dotype"].ToString()); if (SysType == "e")//修改,不能修改用户的类型及学校参数 { //获取修改的对应用户的 ChnId = Com.Public.SqlEncStr(Request.Params["id"].ToString()); schchn_model = schchn_bll.GetModel(int.Parse(ChnId)); if (schchn_model != null && schchn_model.ChnId > 0) { umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(schchn_model); } else { Response.Write("无该名称!"); Response.End(); } chndrp = Com.Public.GetDrp("chn", Com.Session.schid, "1", false, ChnId, schchn_model.Pid.ToString()); } else//不在添加及修改之内,则返回 { chndrp = Com.Public.GetDrp("chn", Com.Session.schid, "1", false, "", ""); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.WebSchChn model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into WebSchChn("); strSql.Append("Pid,SchId,ChnName,ChnCode,OrderId,Stat,IsTop,Note,IsWrite,IsPlc,RecUser,RecName,RecTime,RecIp,IsLink,LinkUrl)"); strSql.Append(" values ("); strSql.Append("@Pid,@SchId,@ChnName,@ChnCode,@OrderId,@Stat,@IsTop,@Note,@IsWrite,@IsPlc,@RecUser,@RecName,@RecTime,@RecIp,@IsLink,@LinkUrl)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.VarChar, 50), new SqlParameter("@ChnName", SqlDbType.VarChar, 50), new SqlParameter("@ChnCode", SqlDbType.Int, 4), new SqlParameter("@OrderId", SqlDbType.Int, 4), new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@IsTop", SqlDbType.TinyInt, 1), new SqlParameter("@Note", SqlDbType.VarChar, 300), new SqlParameter("@IsWrite", SqlDbType.TinyInt, 1), new SqlParameter("@IsPlc", SqlDbType.TinyInt, 1), new SqlParameter("@RecUser", SqlDbType.VarChar, 30), new SqlParameter("@RecName", SqlDbType.VarChar, 30), new SqlParameter("@RecTime", SqlDbType.DateTime), new SqlParameter("@RecIp", SqlDbType.VarChar, 20), new SqlParameter("@IsLink", SqlDbType.TinyInt, 1), new SqlParameter("@LinkUrl", SqlDbType.VarChar, 300) }; parameters[0].Value = model.Pid; parameters[1].Value = model.SchId; parameters[2].Value = model.ChnName; parameters[3].Value = model.ChnCode; parameters[4].Value = model.OrderId; parameters[5].Value = model.Stat; parameters[6].Value = model.IsTop; parameters[7].Value = model.Note; parameters[8].Value = model.IsWrite; parameters[9].Value = model.IsPlc; parameters[10].Value = model.RecUser; parameters[11].Value = model.RecName; parameters[12].Value = model.RecTime; parameters[13].Value = model.RecIp; parameters[14].Value = model.IsLink; parameters[15].Value = model.LinkUrl; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public static Com.DataPack.DataRsp <string> udel(string id) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { //看是否已有新闻关联,需要补 SchSystem.BLL.WebSchChn bll = new SchSystem.BLL.WebSchChn(); SchSystem.Model.WebSchChn model = new SchSystem.Model.WebSchChn(); model.ChnId = int.Parse(id); model.Stat = 2; //删除时判断是否有子栏目 if (!bll.Exists(int.Parse(id))) { SchSystem.BLL.WebSchNews bllnew = new SchSystem.BLL.WebSchNews(); if (!bllnew.ExistsChn(int.Parse(id))) { if (bll.UpdateStat(model)) { rsp.code = "success"; rsp.msg = "操作成功"; } else { rsp.code = "error"; rsp.msg = "操作失败"; } } else { rsp.code = "error"; rsp.msg = "该栏目下还有文章,请删除文章后再删除该栏目!"; } } else { rsp.code = "error"; rsp.msg = "请先删除子栏目!"; } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }
/// <summary> /// 更新一条数据 /// </summary> public bool CUpdate(SchSystem.Model.WebSchChn model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update WebSchChn set "); strSql.Append("Pid=@Pid,"); strSql.Append("SchId=@SchId,"); strSql.Append("ChnName=@ChnName,"); strSql.Append("ChnCode=@ChnCode,"); strSql.Append("Stat=@Stat,"); strSql.Append("Note=@Note"); strSql.Append(" where ChnId=@ChnId"); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.VarChar, 50), new SqlParameter("@ChnName", SqlDbType.VarChar, 50), new SqlParameter("@ChnCode", SqlDbType.Int, 4), new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@Note", SqlDbType.VarChar, 300), new SqlParameter("@ChnId", SqlDbType.Int, 4) }; parameters[0].Value = model.Pid; parameters[1].Value = model.SchId; parameters[2].Value = model.ChnName; parameters[3].Value = model.ChnCode; parameters[4].Value = model.Stat; parameters[5].Value = model.Note; parameters[6].Value = model.ChnId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.WebSchChn GetModel(int ChnId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ChnId,Pid,SchId,ChnName,ChnCode,OrderId,Stat,IsTop,Note,IsWrite,IsPlc,RecUser,RecName,RecTime,RecIp,IsLink,LinkUrl from WebSchChn "); strSql.Append(" where ChnId=@ChnId"); SqlParameter[] parameters = { new SqlParameter("@ChnId", SqlDbType.Int, 4) }; parameters[0].Value = ChnId; SchSystem.Model.WebSchChn model = new SchSystem.Model.WebSchChn(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.WebSchChn DataRowToModel(DataRow row) { SchSystem.Model.WebSchChn model = new SchSystem.Model.WebSchChn(); if (row != null) { if (row["ChnId"] != null && row["ChnId"].ToString() != "") { model.ChnId = int.Parse(row["ChnId"].ToString()); } if (row["Pid"] != null && row["Pid"].ToString() != "") { model.Pid = int.Parse(row["Pid"].ToString()); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } if (row["ChnName"] != null) { model.ChnName = row["ChnName"].ToString(); } if (row["ChnCode"] != null && row["ChnCode"].ToString() != "") { model.ChnCode = int.Parse(row["ChnCode"].ToString()); } if (row["OrderId"] != null && row["OrderId"].ToString() != "") { model.OrderId = int.Parse(row["OrderId"].ToString()); } if (row["Stat"] != null && row["Stat"].ToString() != "") { model.Stat = int.Parse(row["Stat"].ToString()); } if (row["IsTop"] != null && row["IsTop"].ToString() != "") { model.IsTop = int.Parse(row["IsTop"].ToString()); } if (row["Note"] != null) { model.Note = row["Note"].ToString(); } if (row["IsWrite"] != null && row["IsWrite"].ToString() != "") { model.IsWrite = int.Parse(row["IsWrite"].ToString()); } if (row["IsPlc"] != null && row["IsPlc"].ToString() != "") { model.IsPlc = int.Parse(row["IsPlc"].ToString()); } if (row["RecUser"] != null) { model.RecUser = row["RecUser"].ToString(); } if (row["RecName"] != null) { model.RecName = row["RecName"].ToString(); } if (row["RecTime"] != null && row["RecTime"].ToString() != "") { model.RecTime = DateTime.Parse(row["RecTime"].ToString()); } if (row["RecIp"] != null) { model.RecIp = row["RecIp"].ToString(); } if (row["IsLink"] != null && row["IsLink"].ToString() != "") { model.IsLink = int.Parse(row["IsLink"].ToString()); } if (row["LinkUrl"] != null) { model.LinkUrl = row["LinkUrl"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.WebSchChn model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update WebSchChn set "); strSql.Append("Pid=@Pid,"); strSql.Append("SchId=@SchId,"); strSql.Append("ChnName=@ChnName,"); strSql.Append("ChnCode=@ChnCode,"); strSql.Append("OrderId=@OrderId,"); strSql.Append("Stat=@Stat,"); strSql.Append("IsTop=@IsTop,"); strSql.Append("Note=@Note,"); strSql.Append("IsWrite=@IsWrite,"); strSql.Append("IsPlc=@IsPlc,"); strSql.Append("RecUser=@RecUser,"); strSql.Append("RecName=@RecName,"); strSql.Append("RecTime=@RecTime,"); strSql.Append("RecIp=@RecIp,"); strSql.Append("IsLink=@IsLink,"); strSql.Append("LinkUrl=@LinkUrl"); strSql.Append(" where ChnId=@ChnId"); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.VarChar, 50), new SqlParameter("@ChnName", SqlDbType.VarChar, 50), new SqlParameter("@ChnCode", SqlDbType.Int, 4), new SqlParameter("@OrderId", SqlDbType.Int, 4), new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@IsTop", SqlDbType.TinyInt, 1), new SqlParameter("@Note", SqlDbType.VarChar, 300), new SqlParameter("@IsWrite", SqlDbType.TinyInt, 1), new SqlParameter("@IsPlc", SqlDbType.TinyInt, 1), new SqlParameter("@RecUser", SqlDbType.VarChar, 30), new SqlParameter("@RecName", SqlDbType.VarChar, 30), new SqlParameter("@RecTime", SqlDbType.DateTime), new SqlParameter("@RecIp", SqlDbType.VarChar, 20), new SqlParameter("@IsLink", SqlDbType.TinyInt, 1), new SqlParameter("@LinkUrl", SqlDbType.VarChar, 300), new SqlParameter("@ChnId", SqlDbType.Int, 4) }; parameters[0].Value = model.Pid; parameters[1].Value = model.SchId; parameters[2].Value = model.ChnName; parameters[3].Value = model.ChnCode; parameters[4].Value = model.OrderId; parameters[5].Value = model.Stat; parameters[6].Value = model.IsTop; parameters[7].Value = model.Note; parameters[8].Value = model.IsWrite; parameters[9].Value = model.IsPlc; parameters[10].Value = model.RecUser; parameters[11].Value = model.RecName; parameters[12].Value = model.RecTime; parameters[13].Value = model.RecIp; parameters[14].Value = model.IsLink; parameters[15].Value = model.LinkUrl; parameters[16].Value = model.ChnId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public static Com.DataPack.DataRsp <string> save(string Chnid, string ChnName, string ChnCode, string Note, string Stat, string Pid) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { SchSystem.BLL.WebSchChn schchn_bll = new SchSystem.BLL.WebSchChn(); SchSystem.Model.WebSchChn schchn_model = new SchSystem.Model.WebSchChn(); schchn_model.ChnName = Com.Public.SqlEncStr(ChnName).ToString(); schchn_model.Stat = Convert.ToInt32(Com.Public.SqlEncStr(Stat)); schchn_model.ChnCode = Convert.ToInt32(Com.Public.SqlEncStr(ChnCode)); schchn_model.Note = Com.Public.SqlEncStr(Note).ToString(); schchn_model.Pid = Convert.ToInt32(Pid); schchn_model.SchId = Convert.ToInt32(Com.Session.schid.ToString()); if (Chnid != "") { schchn_model.ChnId = Convert.ToInt32(Chnid); //判断栏目代码不允许重复 if (!schchn_bll.ExistsChnCode(schchn_model.ChnId, schchn_model.ChnCode, schchn_model.SchId)) { if (schchn_bll.CUpdate(schchn_model)) { rsp.code = "success"; rsp.msg = "修改成功"; } } else { rsp.code = "error"; rsp.msg = "代码重复"; } } else { schchn_model.RecName = Com.Session.uname.ToString(); schchn_model.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); schchn_model.RecUser = Com.Session.userid.ToString(); //判断栏目代码不允许重复 if (!schchn_bll.ExistsChnCode(schchn_model.ChnId, schchn_model.ChnCode, schchn_model.SchId)) { if (schchn_bll.Add(schchn_model) != 0) { rsp.code = "success"; rsp.msg = "添加成功"; } } else { rsp.code = "error"; rsp.msg = "代码重复"; } } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }