/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.IMS_FACE_CAMERA DataRowToModel(DataRow row) { Maticsoft.Model.IMS_FACE_CAMERA model = new Maticsoft.Model.IMS_FACE_CAMERA(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = decimal.Parse(row["ID"].ToString()); } if (row["CameraName"] != null) { model.CameraName = row["CameraName"].ToString(); } if (row["CameraIP"] != null) { model.CameraIP = row["CameraIP"].ToString(); } if (row["CameraPort"] != null) { model.CameraPort = row["CameraPort"].ToString(); } if (row["CameraUser"] != null) { model.CameraUser = row["CameraUser"].ToString(); } if (row["CameraPwd"] != null) { model.CameraPwd = row["CameraPwd"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.IMS_FACE_CAMERA model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into IMS_FACE_CAMERA("); strSql.Append("CameraName,CameraIP,CameraPort,CameraUser,CameraPwd)"); strSql.Append(" values ("); strSql.Append("@CameraName,@CameraIP,@CameraPort,@CameraUser,@CameraPwd)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CameraName", SqlDbType.VarChar, 50), new SqlParameter("@CameraIP", SqlDbType.VarChar, 50), new SqlParameter("@CameraPort", SqlDbType.VarChar, 50), new SqlParameter("@CameraUser", SqlDbType.VarChar, 50), new SqlParameter("@CameraPwd", SqlDbType.VarChar, 50) }; parameters[0].Value = model.CameraName; parameters[1].Value = model.CameraIP; parameters[2].Value = model.CameraPort; parameters[3].Value = model.CameraUser; parameters[4].Value = model.CameraPwd; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.IMS_FACE_CAMERA model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update IMS_FACE_CAMERA set "); strSql.Append("CameraName=@CameraName,"); strSql.Append("CameraIP=@CameraIP,"); strSql.Append("CameraPort=@CameraPort,"); strSql.Append("CameraUser=@CameraUser,"); strSql.Append("CameraPwd=@CameraPwd"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@CameraName", SqlDbType.VarChar, 50), new SqlParameter("@CameraIP", SqlDbType.VarChar, 50), new SqlParameter("@CameraPort", SqlDbType.VarChar, 50), new SqlParameter("@CameraUser", SqlDbType.VarChar, 50), new SqlParameter("@CameraPwd", SqlDbType.VarChar, 50), new SqlParameter("@ID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.CameraName; parameters[1].Value = model.CameraIP; parameters[2].Value = model.CameraPort; parameters[3].Value = model.CameraUser; parameters[4].Value = model.CameraPwd; parameters[5].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.IMS_FACE_CAMERA GetModel(decimal ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,CameraName,CameraIP,CameraPort,CameraUser,CameraPwd from IMS_FACE_CAMERA "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Decimal) }; parameters[0].Value = ID; Maticsoft.Model.IMS_FACE_CAMERA model = new Maticsoft.Model.IMS_FACE_CAMERA(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }