Beispiel #1
0
        public bool add(Section section, DbTransaction transaction)
        {
            IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO();
            fpObjectDAO.add(section, transaction);

            SqlTransaction trans = (SqlTransaction)transaction;
            String sql = "insert into Section(ObjectId, name, other, dept) values " +
                "(@ObjectId, @name, @other, @dept)";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.Transaction = trans;
            cmd.Connection = trans.Connection;
            cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, section.objectId));
            cmd.Parameters.Add(genSqlParameter("name", SqlDbType.NVarChar, 255, section.name));
            cmd.Parameters.Add(genSqlParameter("other", SqlDbType.NVarChar, 255, section.other));

            if(section == null)
                cmd.Parameters.Add(genSqlParameter("other", SqlDbType.Int, 10, null));
            else
                cmd.Parameters.Add(genSqlParameter("other", SqlDbType.Int, 10, section.dept.objectId));

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            return true;
        }
Beispiel #2
0
        private List<Section> getQueryResult(SqlCommand cmd)
        {

            IDepartmentDAO deptDAO = DAOFactory.getInstance().createDepartmentDAO();
            DbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();

            List<Section> sections = new List<Section>();
            Section section = null;

            dt.Load(reader);
            reader.Close();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    section = new Section();
                    section.objectId = getInt(dt.Rows[i]["ObjectId"]);
                    section.createDate = getDateTime(dt.Rows[i]["CreateDate"]);
                    section.updateDate = getDateTime(dt.Rows[i]["UpdateDate"]);
                    section.updateBy = getString(dt.Rows[i]["UpdateBy"]);
                    section.isDeleted = (getInt(dt.Rows[i]["IsDeleted"]) == 1);
                    section.name = getString(dt.Rows[i]["name"]);
                    section.other = getString(dt.Rows[i]["other"]);
                    section.dept = deptDAO.get(getInt(dt.Rows[i]["dept"]), cmd.Transaction);

                    sections.Add(section);
                }
            }
            return sections;
        }
Beispiel #3
0
 public bool delete(Section section, DbTransaction transaction)
 {
     IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO();
     return fpObjectDAO.delete(section, transaction);
 }