/// <summary> /// 显示部门 /// </summary> /// <param name="id"></param> /// <returns></returns> protected string DepartmentShow(string id) { if (id.Trim() != "") { _departModel = _departBll.GetModel(Convert.ToInt32(id)); if (_departModel != null) { return(_departModel.DepartmentName); } } return(""); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Haikan.SchoolProjectsCore.MDB.Model.Department model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Department set "); strSql.Append("DepartmentName=@DepartmentName,"); strSql.Append("ChargeMan=@ChargeMan,"); strSql.Append("Tel=@Tel,"); strSql.Append("Fax=@Fax,"); strSql.Append("details=@details,"); strSql.Append("IsDelete=@IsDelete"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@DepartmentName", SqlDbType.VarChar, 50), new SqlParameter("@ChargeMan", SqlDbType.VarChar, 50), new SqlParameter("@Tel", SqlDbType.VarChar, 50), new SqlParameter("@Fax", SqlDbType.VarChar, 50), new SqlParameter("@details", SqlDbType.VarChar, 8000), new SqlParameter("@IsDelete", SqlDbType.VarChar, 255), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.DepartmentName; parameters[1].Value = model.ChargeMan; parameters[2].Value = model.Tel; parameters[3].Value = model.Fax; parameters[4].Value = model.details; parameters[5].Value = model.IsDelete; parameters[6].Value = model.ID; int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Haikan.SchoolProjectsCore.MDB.Model.Department model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Department("); strSql.Append("DepartmentName,ChargeMan,Tel,Fax,details,IsDelete)"); strSql.Append(" values ("); strSql.Append("@DepartmentName,@ChargeMan,@Tel,@Fax,@details,@IsDelete)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DepartmentName", SqlDbType.VarChar, 50), new SqlParameter("@ChargeMan", SqlDbType.VarChar, 50), new SqlParameter("@Tel", SqlDbType.VarChar, 50), new SqlParameter("@Fax", SqlDbType.VarChar, 50), new SqlParameter("@details", SqlDbType.VarChar, 8000), new SqlParameter("@IsDelete", SqlDbType.VarChar, 255) }; parameters[0].Value = model.DepartmentName; parameters[1].Value = model.ChargeMan; parameters[2].Value = model.Tel; parameters[3].Value = model.Fax; parameters[4].Value = model.details; parameters[5].Value = model.IsDelete; object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Haikan.SchoolProjectsCore.MDB.Model.Department DataRowToModel(DataRow row) { Haikan.SchoolProjectsCore.MDB.Model.Department model = new Haikan.SchoolProjectsCore.MDB.Model.Department(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["DepartmentName"] != null) { model.DepartmentName = row["DepartmentName"].ToString(); } if (row["ChargeMan"] != null) { model.ChargeMan = row["ChargeMan"].ToString(); } if (row["Tel"] != null) { model.Tel = row["Tel"].ToString(); } if (row["Fax"] != null) { model.Fax = row["Fax"].ToString(); } if (row["details"] != null) { model.details = row["details"].ToString(); } if (row["IsDelete"] != null) { model.IsDelete = row["IsDelete"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Haikan.SchoolProjectsCore.MDB.Model.Department GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,DepartmentName,ChargeMan,Tel,Fax,details,IsDelete from Department "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Haikan.SchoolProjectsCore.MDB.Model.Department model = new Haikan.SchoolProjectsCore.MDB.Model.Department(); DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }