public bool Modify(messgaeData datmessgae) { int iRel = -1; bool bRel = false; DataAccess.CommonDB objDB = new DataAccess.CommonDB(); try { objDB.OpenConnection(); string strSql = "update messgae set messtit=@messtit,messtime=@messtime,messcon=@messcon where Id = @Id"; objDB.Command.CommandType = System.Data.CommandType.Text; objDB.Command.CommandText = strSql; objDB.Command.Parameters.AddWithValue("@messtit", datmessgae.messtit); objDB.Command.Parameters.AddWithValue("@messtime", datmessgae.messtime); objDB.Command.Parameters.AddWithValue("@messcon", datmessgae.messcon); objDB.Command.Parameters.AddWithValue("@Id", datmessgae.Id); iRel = objDB.Command.ExecuteNonQuery(); } catch (Exception ex) { iRel = -1; } objDB.CloseConnection(); objDB.Dispose(); objDB = null; bRel = (iRel.Equals(1) ? true : false); return(bRel); }
public messgaeData[] Select(string Id) { int iRel = -1; DataAccess.CommonDB objDB = new DataAccess.CommonDB(); messgaeData[] datmessgae = new messgaeData[1]; string sql = "select * from messgae where Id= " + Id + " "; try { objDB.OpenConnection(); DataSet ds = objDB.QueryData(sql, "departmentinfo"); if (ds.Tables.Count > 0) { long nRow = ds.Tables[0].Rows.Count; if (nRow > 0) { datmessgae = new messgaeData[nRow]; for (int i = 0; i < nRow; i++) { datmessgae[i] = new messgaeData(); datmessgae[i].messtit = ds.Tables[0].Rows[i]["messtit"].ToString(); datmessgae[i].messtime = ds.Tables[0].Rows[i]["messtime"].ToString(); datmessgae[i].messcon = ds.Tables[0].Rows[i]["messcon"].ToString(); } } } } catch (Exception ex) { iRel = -1; } objDB.CloseConnection(); objDB.Dispose(); objDB = null; return(datmessgae); }