public static string updpt(string schid, string id, string dptname, string pid, string stat) { string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { try { SchSystem.BLL.SchDepartInfo bll = new SchSystem.BLL.SchDepartInfo(); SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); model.DepartId = int.Parse(id); model.Pid = int.Parse(pid); model.Stat = int.Parse(stat); model.DepartName = Com.Public.SqlEncStr(dptname); model.LastRecTime = DateTime.Now; model.LastRecUser = Com.Session.userid; bll.Update(model); ret = "success"; } catch (Exception ex) { ret = ex.Message; } } return(ret); }
public static string adddpt(string schid, string dptname, string pid, string stat) { schid = Com.Public.SqlEncStr(schid); dptname = Com.Public.SqlEncStr(dptname); pid = Com.Public.SqlEncStr(pid); stat = Com.Public.SqlEncStr(stat); string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { try { SchSystem.BLL.SchDepartInfo bll = new SchSystem.BLL.SchDepartInfo(); DataTable dtTopOrderOne = bll.GetList("top 1 OrderId", "Schid='" + schid + "' and Pid='" + pid + "' Order By OrderId Desc").Tables[0]; DataRow[] drTopOrderOne = dtTopOrderOne.Select(); int OrderId = 0; if (dtTopOrderOne.Rows.Count == 0)//如果子类为空,设置OrderId默认值为0; { OrderId = 0; } else//否则,获取最大值并加1 { foreach (DataRow item in drTopOrderOne) { OrderId = Convert.ToInt32(item["OrderId"]) + 1; } } SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); model.RecTime = DateTime.Now; model.RecUser = Com.Session.userid; model.SchId = int.Parse(schid); model.OrderId = OrderId; if (pid.ToString() == "null") { model.Pid = Convert.ToInt32(0); } else { model.Pid = int.Parse(pid); } model.Stat = int.Parse(stat); model.DepartName = Com.Public.SqlEncStr(dptname); model.LastRecTime = DateTime.Now; model.LastRecUser = Com.Session.userid; int id = bll.Add(model); ret = id.ToString(); } catch (Exception ex) { ret = ex.Message; } } return(ret); }
public bool UpdateStat(SchSystem.Model.SchDepartInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchDepartInfo set "); strSql.Append("Stat=@Stat,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser"); strSql.Append(" where DepartId=@DepartId"); SqlParameter[] parameters = { new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@DepartId", SqlDbType.Int, 4) }; parameters[0].Value = model.Stat; parameters[1].Value = model.LastRecTime; parameters[2].Value = model.LastRecUser; parameters[3].Value = model.DepartId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 交换排序 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool ChangeOrderBy(SchSystem.Model.SchDepartInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchDepartInfo set "); strSql.Append("OrderId=@OrderId "); strSql.Append(" where DepartId=@DepartId and SchId=@SchId and Stat=1"); SqlParameter[] parameters = { new SqlParameter("@OrderId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@DepartId", SqlDbType.Int, 4) }; parameters[0].Value = model.OrderId; parameters[1].Value = model.SchId; parameters[2].Value = model.DepartId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public static string updpt(string schid, string id, string dptname, string pid, string stat) { string ret = ""; Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { ret = "expire"; } else { try { SchSystem.BLL.SchDepartInfo bll = new SchSystem.BLL.SchDepartInfo(); SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); model.DepartId = int.Parse(id); model.Pid = int.Parse(pid); model.Stat = int.Parse(stat); model.DepartName = Com.Public.SqlEncStr(dptname); model.LastRecTime = DateTime.Now; model.LastRecUser = Com.SoureSession.Soureuserid; bll.Update(model); ret = "success"; } catch (Exception ex) { ret = ex.Message; } } return(ret); }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchDepartInfo DataRowToModel(DataRow row) { SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); if (row != null) { if (row["DepartId"] != null && row["DepartId"].ToString() != "") { model.DepartId = int.Parse(row["DepartId"].ToString()); } if (row["DepartName"] != null) { model.DepartName = row["DepartName"].ToString(); } if (row["Pid"] != null && row["Pid"].ToString() != "") { model.Pid = int.Parse(row["Pid"].ToString()); } if (row["OrderId"] != null && row["OrderId"].ToString() != "") { model.OrderId = int.Parse(row["OrderId"].ToString()); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } if (row["Stat"] != null && row["Stat"].ToString() != "") { model.Stat = int.Parse(row["Stat"].ToString()); } if (row["RecTime"] != null && row["RecTime"].ToString() != "") { model.RecTime = DateTime.Parse(row["RecTime"].ToString()); } if (row["RecUser"] != null) { model.RecUser = row["RecUser"].ToString(); } if (row["LastRecTime"] != null && row["LastRecTime"].ToString() != "") { model.LastRecTime = DateTime.Parse(row["LastRecTime"].ToString()); } if (row["LastRecUser"] != null) { model.LastRecUser = row["LastRecUser"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.SchDepartInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SchDepartInfo("); strSql.Append("DepartName,Pid,OrderId,SchId,Stat,RecTime,RecUser,LastRecTime,LastRecUser)"); strSql.Append(" values ("); strSql.Append("@DepartName,@Pid,@OrderId,@SchId,@Stat,@RecTime,@RecUser,@LastRecTime,@LastRecUser)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DepartName", SqlDbType.VarChar, 20), new SqlParameter("@Pid", SqlDbType.Int, 4), new SqlParameter("@OrderId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@RecTime", SqlDbType.SmallDateTime), new SqlParameter("@RecUser", SqlDbType.VarChar, 50), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20) }; parameters[0].Value = model.DepartName; parameters[1].Value = model.Pid; parameters[2].Value = model.OrderId; parameters[3].Value = model.SchId; parameters[4].Value = model.Stat; parameters[5].Value = model.RecTime; parameters[6].Value = model.RecUser; parameters[7].Value = model.LastRecTime; parameters[8].Value = model.LastRecUser; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public static string deldpt(string schid, string id) { string ret = ""; Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { ret = "expire"; } else { try { SchSystem.BLL.SchDepartInfo bll = new SchSystem.BLL.SchDepartInfo(); //判断是否有正常的子部门和人员 if (bll.ExistsUser(int.Parse(id))) { ret += "该部门下还有人员,不允许删除!"; } if (bll.ExistsPid(int.Parse(id))) { ret += "该部门下有子部门,不允许删除!"; } if (ret == "") { SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); model.DepartId = int.Parse(id); model.LastRecTime = DateTime.Now; model.LastRecUser = Com.SoureSession.Soureuserid; model.Stat = 2; bll.UpdateStat(model); ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
public static string deldpt(string schid, string id) { string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { try { SchSystem.BLL.SchDepartInfo bll = new SchSystem.BLL.SchDepartInfo(); //判断是否有正常的子部门和人员 if (bll.ExistsUser(int.Parse(id))) { ret += "该部门下还有人员,不允许删除!"; } if (bll.ExistsPid(int.Parse(id))) { ret += "该部门下有子部门,不允许删除!"; } if (ret == "") { SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); model.DepartId = int.Parse(id); model.LastRecTime = DateTime.Now; model.LastRecUser = Com.Session.userid; model.Stat = 2; bll.UpdateStat(model); ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchDepartInfo GetModel(int DepartId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 DepartId,DepartName,Pid,OrderId,SchId,Stat,RecTime,RecUser,LastRecTime,LastRecUser from SchDepartInfo "); strSql.Append(" where DepartId=@DepartId"); SqlParameter[] parameters = { new SqlParameter("@DepartId", SqlDbType.Int, 4) }; parameters[0].Value = DepartId; SchSystem.Model.SchDepartInfo model = new SchSystem.Model.SchDepartInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }