public bool Insert(correctingData datcorrecting) { int iRel = -1; bool bRel = false; DataAccess.CommonDB objDB = new DataAccess.CommonDB(); try { objDB.OpenConnection(); string strSql = " insert into correcting (hwtit,userid,ctime,ccon,ter,cdate,scores,messages) values (@hwtit,@userid,@ctime,@ccon,@ter,@cdate,@scores,@messages) "; objDB.Command.CommandType = System.Data.CommandType.Text; objDB.Command.CommandText = strSql; objDB.Command.Parameters.AddWithValue("@hwtit", datcorrecting.hwtit); objDB.Command.Parameters.AddWithValue("@userid", datcorrecting.userid); objDB.Command.Parameters.AddWithValue("@ctime", datcorrecting.ctime); objDB.Command.Parameters.AddWithValue("@ccon", datcorrecting.ccon); objDB.Command.Parameters.AddWithValue("@ter", datcorrecting.ter); objDB.Command.Parameters.AddWithValue("@cdate", datcorrecting.cdate); objDB.Command.Parameters.AddWithValue("@scores", datcorrecting.scores); objDB.Command.Parameters.AddWithValue("@messages", datcorrecting.messages); iRel = objDB.Command.ExecuteNonQuery(); } catch (Exception ex) { iRel = -1; } objDB.CloseConnection(); objDB.Dispose(); objDB = null; bRel = (iRel.Equals(1) ? true : false); return(bRel); }
public correctingData[] Select(string Id) { int iRel = -1; DataAccess.CommonDB objDB = new DataAccess.CommonDB(); correctingData[] datcorrecting = new correctingData[1]; string sql = "select * from correcting 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) { datcorrecting = new correctingData[nRow]; for (int i = 0; i < nRow; i++) { datcorrecting[i] = new correctingData(); datcorrecting[i].hwtit = ds.Tables[0].Rows[i]["hwtit"].ToString(); datcorrecting[i].userid = ds.Tables[0].Rows[i]["userid"].ToString(); datcorrecting[i].ctime = ds.Tables[0].Rows[i]["ctime"].ToString(); datcorrecting[i].ccon = ds.Tables[0].Rows[i]["ccon"].ToString(); datcorrecting[i].ter = ds.Tables[0].Rows[i]["ter"].ToString(); datcorrecting[i].cdate = ds.Tables[0].Rows[i]["cdate"].ToString(); datcorrecting[i].scores = ds.Tables[0].Rows[i]["scores"].ToString(); datcorrecting[i].messages = ds.Tables[0].Rows[i]["messages"].ToString(); } } } } catch (Exception ex) { iRel = -1; } objDB.CloseConnection(); objDB.Dispose(); objDB = null; return(datcorrecting); }