Exemplo n.º 1
0
        private static Tab_CourseTestLog ToModel(DataRow row)
        {
            Tab_CourseTestLog model = new Tab_CourseTestLog();

            model.Idx              = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.UserIdx_Fx       = row.IsNull("UserIdx_Fx")?null:(System.Int32?)row["UserIdx_Fx"];
            model.CourseMainIdx_Fx = row.IsNull("CourseMainIdx_Fx")?null:(System.Int32?)row["CourseMainIdx_Fx"];
            model.TestAnswer       = row.IsNull("TestAnswer")?null:(System.String)row["TestAnswer"];
            model.PassBool         = row.IsNull("PassBool")?null:(System.String)row["PassBool"];
            model.CreatedDate      = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"];
            return(model);
        }
Exemplo n.º 2
0
        public int AddNew(Tab_CourseTestLog model)
        {
            string sql = "insert into Tab_CourseTestLog(UserIdx_Fx,CourseMainIdx_Fx,TestAnswer,PassBool,CreatedDate)  values(@UserIdx_Fx,@CourseMainIdx_Fx,@TestAnswer,@PassBool,@CreatedDate); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@UserIdx_Fx", model.UserIdx_Fx)
                                                                 , new SqlParameter("@CourseMainIdx_Fx", model.CourseMainIdx_Fx)
                                                                 , new SqlParameter("@TestAnswer", model.TestAnswer)
                                                                 , new SqlParameter("@PassBool", model.PassBool)
                                                                 , new SqlParameter("@CreatedDate", model.CreatedDate)
                                                                 ));

            return(Idx);
        }
Exemplo n.º 3
0
        public bool Update(Tab_CourseTestLog model)
        {
            string sql  = "update Tab_CourseTestLog set UserIdx_Fx=@UserIdx_Fx,CourseMainIdx_Fx=@CourseMainIdx_Fx,TestAnswer=@TestAnswer,PassBool=@PassBool,CreatedDate=@CreatedDate where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@UserIdx_Fx", model.UserIdx_Fx)
                                                    , new SqlParameter("@CourseMainIdx_Fx", model.CourseMainIdx_Fx)
                                                    , new SqlParameter("@TestAnswer", model.TestAnswer)
                                                    , new SqlParameter("@PassBool", model.PassBool)
                                                    , new SqlParameter("@CreatedDate", model.CreatedDate)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Exemplo n.º 4
0
        public Tab_CourseTestLog Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_CourseTestLog  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow           row   = dt.Rows[0];
            Tab_CourseTestLog model = ToModel(row);

            return(model);
        }