/// <summary> /// 增加一条数据 /// </summary> public int Add(YJUI.Model.ui_neibuDep model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@departmentname", SqlDbType.VarChar, 100), new SqlParameter("@remark", SqlDbType.Text) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.departmentname; parameters[2].Value = model.remark; DbHelperSQL.RunProcedure("ui_neibuDep_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
/// <summary> /// 得到一个对象实体 /// </summary> public YJUI.Model.ui_neibuDep DataRowToModel(DataRow row) { YJUI.Model.ui_neibuDep model = new YJUI.Model.ui_neibuDep(); 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["remark"] != null) { model.remark = row["remark"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public YJUI.Model.ui_neibuDep GetModel(int id) { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; YJUI.Model.ui_neibuDep model = new YJUI.Model.ui_neibuDep(); DataSet ds = DbHelperSQL.RunProcedure("ui_neibuDep_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(YJUI.Model.ui_neibuDep model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@departmentname", SqlDbType.VarChar, 100), new SqlParameter("@remark", SqlDbType.Text) }; parameters[0].Value = model.id; parameters[1].Value = model.departmentname; parameters[2].Value = model.remark; DbHelperSQL.RunProcedure("ui_neibuDep_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }