示例#1
0
        public bool Insert(homeworkData dathomework)
        {
            int  iRel = -1;
            bool bRel = false;

            DataAccess.CommonDB objDB = new DataAccess.CommonDB();
            try
            {
                objDB.OpenConnection();
                string strSql = " insert into homework (hwtit,hwtime,hwer,press,userclass)  values (@hwtit,@hwtime,@hwer,@press,@userclass) ";
                objDB.Command.CommandType = System.Data.CommandType.Text;
                objDB.Command.CommandText = strSql;
                objDB.Command.Parameters.AddWithValue("@hwtit", dathomework.hwtit);
                objDB.Command.Parameters.AddWithValue("@hwtime", dathomework.hwtime);
                objDB.Command.Parameters.AddWithValue("@hwer", dathomework.hwer);
                objDB.Command.Parameters.AddWithValue("@press", dathomework.press);
                objDB.Command.Parameters.AddWithValue("@userclass", dathomework.userclass);
                iRel = objDB.Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                iRel = -1;
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            bRel  = (iRel.Equals(1) ? true : false);
            return(bRel);
        }
示例#2
0
        public bool Modify(homeworkData dathomework)
        {
            int  iRel = -1;
            bool bRel = false;

            DataAccess.CommonDB objDB = new DataAccess.CommonDB();
            try
            {
                objDB.OpenConnection();
                string strSql = "update homework set hwtit=@hwtit,hwtime=@hwtime,hwer=@hwer,press=@press,userclass=@userclass where Id = @Id";
                objDB.Command.CommandType = System.Data.CommandType.Text;
                objDB.Command.CommandText = strSql;
                objDB.Command.Parameters.AddWithValue("@hwtit", dathomework.hwtit);
                objDB.Command.Parameters.AddWithValue("@hwtime", dathomework.hwtime);
                objDB.Command.Parameters.AddWithValue("@hwer", dathomework.hwer);
                objDB.Command.Parameters.AddWithValue("@press", dathomework.press);
                objDB.Command.Parameters.AddWithValue("@userclass", dathomework.userclass);
                objDB.Command.Parameters.AddWithValue("@Id", dathomework.Id);
                iRel = objDB.Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            { iRel = -1; }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            bRel  = (iRel.Equals(1) ? true : false); return(bRel);
        }
示例#3
0
        public homeworkData[] Select(string Id)
        {
            int iRel = -1;

            DataAccess.CommonDB objDB       = new DataAccess.CommonDB();
            homeworkData[]      dathomework = new homeworkData[1];
            string sql = "select * from homework 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)
                    {
                        dathomework = new homeworkData[nRow];
                        for (int i = 0; i < nRow; i++)
                        {
                            dathomework[i]           = new homeworkData();
                            dathomework[i].hwtit     = ds.Tables[0].Rows[i]["hwtit"].ToString();
                            dathomework[i].hwtime    = ds.Tables[0].Rows[i]["hwtime"].ToString();
                            dathomework[i].hwer      = ds.Tables[0].Rows[i]["hwer"].ToString();
                            dathomework[i].press     = ds.Tables[0].Rows[i]["press"].ToString();
                            dathomework[i].userclass = ds.Tables[0].Rows[i]["userclass"].ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                iRel = -1;
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            return(dathomework);
        }