Exemplo n.º 1
0
        /// <summary>
        /// Thêm mới một bộ môn
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CreateGenre(GENRE_OBJ obj)
        {
            int        ret = 0;
            string     sql = "CreateGenre '" + obj.CODE + "','" + obj.CODEVIEW + "',N'" + obj.GENRENAME + "',N'" + obj.GENREDESCRIPTION + "','" + obj.FACULTYCODE + "'";
            SqlCommand cm  = new SqlCommand();

            cm.CommandText = sql;
            cm.CommandType = CommandType.Text;
            ret            = db.doCommand(ref cm);
            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Chuyển dữ liệu thành List
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public List <GENRE_OBJ> FillToOBJ(DataSet ds)
        {
            List <GENRE_OBJ> lidata = new List <GENRE_OBJ>();

            foreach (DataRow dr in ds.Tables["Tmp"].Rows)
            {
                GENRE_OBJ obj = new GENRE_OBJ();

                Type myTableObject = typeof(GENRE_OBJ);
                System.Reflection.PropertyInfo[] selectFieldInfo = myTableObject.GetProperties();

                Type myObjectType = typeof(GENRE_OBJ);
                System.Reflection.PropertyInfo[] fieldInfo = myObjectType.GetProperties();

                //set object value
                foreach (System.Reflection.PropertyInfo info in selectFieldInfo)
                {
                    if (info.Name != "_ID")
                    {
                        if (dr.Table.Columns.Contains(info.Name))
                        {
                            if (!dr.IsNull(info.Name))
                            {
                                info.SetValue(obj, dr[info.Name], null);
                            }
                        }
                    }
                    else
                    {
                        //set id value
                        GENRE_OBJ objid;
                        objid = (GENRE_OBJ)info.GetValue(obj, null);
                        foreach (System.Reflection.PropertyInfo info1 in fieldInfo)
                        {
                            if (dr.Table.Columns.Contains(info1.Name))
                            {
                                info1.SetValue(objid, dr[info1.Name], null);
                            }
                        }
                        info.SetValue(obj, objid, null);
                    }
                }
                lidata.Add(obj);
            }
            return(lidata);
        }
Exemplo n.º 3
0
        public GENRE_OBJ createObject()
        {
            GENRE_OBJ obj = new GENRE_OBJ();

            return(obj);
        }