Beispiel #1
0
        /// <summary>
        /// Thêm mới một khoa
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CreateFaculty(FACULTY_OBJ obj)
        {
            int        ret = 0;
            string     sql = "CreateFaculty '" + obj.CODE + "','" + obj.CODEVIEW + "',N'" + obj.FACULTYNAME + "',N'" + obj.FACULTYDESCRIPTION + "'";
            SqlCommand cm  = new SqlCommand();

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

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

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

                Type myObjectType = typeof(FACULTY_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
                        FACULTY_OBJ objid;
                        objid = (FACULTY_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);
        }
Beispiel #3
0
        public FACULTY_OBJ createObject()
        {
            FACULTY_OBJ obj = new FACULTY_OBJ();

            return(obj);
        }