/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.ycyx model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ycyx set "); strSql.Append("fwhm=@fwhm,"); strSql.Append("khmc=@khmc,"); strSql.Append("gsdq=@gsdq,"); strSql.Append("dqpp=@dqpp,"); strSql.Append("dqtc=@dqtc,"); strSql.Append("dqzt=@dqzt,"); strSql.Append("iUserID=@iUserID"); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@fwhm", OleDbType.Integer, 4), new OleDbParameter("@khmc", OleDbType.Integer, 4), new OleDbParameter("@gsdq", OleDbType.Integer, 4), new OleDbParameter("@dqpp", OleDbType.VarChar, 200), new OleDbParameter("@dqtc", OleDbType.Integer, 4), new OleDbParameter("@dqzt", OleDbType.Integer, 4), new OleDbParameter("@iUserID", OleDbType.Integer, 4), new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = model.fwhm; parameters[1].Value = model.khmc; parameters[2].Value = model.gsdq; parameters[3].Value = model.dqpp; parameters[4].Value = model.dqtc; parameters[5].Value = model.dqzt; parameters[6].Value = model.iUserID; parameters[7].Value = model.ID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ycyx DataRowToModel(DataRow row) { Maticsoft.Model.ycyx model = new Maticsoft.Model.ycyx(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["fwhm"] != null && row["fwhm"].ToString() != "") { model.fwhm = int.Parse(row["fwhm"].ToString()); } if (row["khmc"] != null && row["khmc"].ToString() != "") { model.khmc = int.Parse(row["khmc"].ToString()); } if (row["gsdq"] != null && row["gsdq"].ToString() != "") { model.gsdq = int.Parse(row["gsdq"].ToString()); } if (row["dqpp"] != null) { model.dqpp = row["dqpp"].ToString(); } if (row["dqtc"] != null && row["dqtc"].ToString() != "") { model.dqtc = int.Parse(row["dqtc"].ToString()); } if (row["dqzt"] != null && row["dqzt"].ToString() != "") { model.dqzt = int.Parse(row["dqzt"].ToString()); } if (row["iUserID"] != null && row["iUserID"].ToString() != "") { model.iUserID = int.Parse(row["iUserID"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.ycyx model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ycyx("); strSql.Append("fwhm,khmc,gsdq,dqpp,dqtc,dqzt,iUserID)"); strSql.Append(" values ("); strSql.Append("@fwhm,@khmc,@gsdq,@dqpp,@dqtc,@dqzt,@iUserID)"); OleDbParameter[] parameters = { new OleDbParameter("@fwhm", OleDbType.Integer, 4), new OleDbParameter("@khmc", OleDbType.Integer, 4), new OleDbParameter("@gsdq", OleDbType.Integer, 4), new OleDbParameter("@dqpp", OleDbType.VarChar, 200), new OleDbParameter("@dqtc", OleDbType.Integer, 4), new OleDbParameter("@dqzt", OleDbType.Integer, 4), new OleDbParameter("@iUserID", OleDbType.Integer, 4) }; parameters[0].Value = model.fwhm; parameters[1].Value = model.khmc; parameters[2].Value = model.gsdq; parameters[3].Value = model.dqpp; parameters[4].Value = model.dqtc; parameters[5].Value = model.dqzt; parameters[6].Value = model.iUserID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ycyx GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,fwhm,khmc,gsdq,dqpp,dqtc,dqzt,iUserID from ycyx "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = ID; Maticsoft.Model.ycyx model = new Maticsoft.Model.ycyx(); DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }