/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Measures model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Measures set "); strSql.Append("CLID=@CLID,"); strSql.Append("MeDate=@MeDate,"); strSql.Append("MeDesc=@MeDesc"); strSql.Append(" where MeID=@MeID"); SqlParameter[] parameters = { new SqlParameter("@CLID", SqlDbType.Int, 4), new SqlParameter("@MeDate", SqlDbType.DateTime), new SqlParameter("@MeDesc", SqlDbType.NVarChar, -1), new SqlParameter("@MeID", SqlDbType.Int, 4) }; parameters[0].Value = model.CLID; parameters[1].Value = model.MeDate; parameters[2].Value = model.MeDesc; parameters[3].Value = model.MeID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Measures DataRowToModel(DataRow row) { Maticsoft.Model.Measures model = new Maticsoft.Model.Measures(); if (row != null) { if (row["MeID"] != null && row["MeID"].ToString() != "") { model.MeID = int.Parse(row["MeID"].ToString()); } if (row["CLID"] != null && row["CLID"].ToString() != "") { model.CLID = int.Parse(row["CLID"].ToString()); } if (row["CusID"] != null && row["CusID"].ToString() != "") { model.CusID = row["CusID"].ToString(); } if (row["MeDate"] != null && row["MeDate"].ToString() != "") { model.MeDate = DateTime.Parse(row["MeDate"].ToString()); } if (row["MeDesc"] != null) { model.MeDesc = row["MeDesc"].ToString(); } if (row["CusName"] != null) { model.CusName = row["CusName"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.Measures model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Measures("); strSql.Append("CLID,MeDate,MeDesc)"); strSql.Append(" values ("); strSql.Append("@CLID,@MeDate,@MeDesc)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CLID", SqlDbType.Int, 4), new SqlParameter("@MeDate", SqlDbType.DateTime), new SqlParameter("@MeDesc", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.CLID; parameters[1].Value = model.MeDate; parameters[2].Value = model.MeDesc; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Measures GetModel(int MeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MeID,CLID,MeDate,MeDesc from Measures "); strSql.Append(" where MeID=@MeID"); SqlParameter[] parameters = { new SqlParameter("@MeID", SqlDbType.Int, 4) }; parameters[0].Value = MeID; Maticsoft.Model.Measures model = new Maticsoft.Model.Measures(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
//LostAdd.htm页面添加数据 public int LostAdd(Maticsoft.Model.Measures lost) { lost.MeDate = DateTime.Now; BLL.Measures lostBLL = new BLL.Measures(); return(lostBLL.Add(lost)); }