/// <summary> /// 更新一条数据 /// </summary> public bool Update(CCT.Model.EMPLOYEEINFOModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update EMPLOYEEINFO set "); strSql.Append("EMPLOYEECODE=@EMPLOYEECODE,"); strSql.Append("EMPLOYEENAME=@EMPLOYEENAME,"); strSql.Append("CCTEMPLOYEECODE=@CCTEMPLOYEECODE"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@EMPLOYEECODE", SqlDbType.NVarChar, 50), new SqlParameter("@EMPLOYEENAME", SqlDbType.NVarChar, 50), new SqlParameter("@CCTEMPLOYEECODE", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.EMPLOYEECODE; parameters[1].Value = model.EMPLOYEENAME; parameters[2].Value = model.CCTEMPLOYEECODE; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(CCT.Model.EMPLOYEEINFOModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into EMPLOYEEINFO("); strSql.Append("EMPLOYEECODE,EMPLOYEENAME,CCTEMPLOYEECODE)"); strSql.Append(" values ("); strSql.Append("@EMPLOYEECODE,@EMPLOYEENAME,@CCTEMPLOYEECODE)"); SqlParameter[] parameters = { new SqlParameter("@EMPLOYEECODE", SqlDbType.NVarChar, 50), new SqlParameter("@EMPLOYEENAME", SqlDbType.NVarChar, 50), new SqlParameter("@CCTEMPLOYEECODE", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.EMPLOYEECODE; parameters[1].Value = model.EMPLOYEENAME; parameters[2].Value = model.CCTEMPLOYEECODE; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public CCT.Model.EMPLOYEEINFOModel GetModel(String employeecode) { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EMPLOYEECODE,EMPLOYEENAME,CCTEMPLOYEECODE from EMPLOYEEINFO "); strSql.Append(" where EMPLOYEECODE=@EMPLOYEECODE "); SqlParameter[] parameters = { new SqlParameter("@EMPLOYEECODE", SqlDbType.NVarChar, 50) }; parameters[0].Value = employeecode; CCT.Model.EMPLOYEEINFOModel model = new CCT.Model.EMPLOYEEINFOModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["EMPLOYEECODE"] != null && ds.Tables[0].Rows[0]["EMPLOYEECODE"].ToString() != "") { model.EMPLOYEECODE = ds.Tables[0].Rows[0]["EMPLOYEECODE"].ToString(); } if (ds.Tables[0].Rows[0]["EMPLOYEENAME"] != null && ds.Tables[0].Rows[0]["EMPLOYEENAME"].ToString() != "") { model.EMPLOYEENAME = ds.Tables[0].Rows[0]["EMPLOYEENAME"].ToString(); } if (ds.Tables[0].Rows[0]["CCTEMPLOYEECODE"] != null && ds.Tables[0].Rows[0]["CCTEMPLOYEECODE"].ToString() != "") { model.CCTEMPLOYEECODE = ds.Tables[0].Rows[0]["CCTEMPLOYEECODE"].ToString(); } return(model); } else { return(null); } }