示例#1
0
 public async Task <bool> UpdateClassRecord(ClassTeacherDto dto)
 {
     try
     {
         SqlConnection nwindConn = new SqlConnection("Data Source=DESKTOP-JV14P7J\\SQLEXPRESS;Initial Catalog=Portal;Integrated Security=true");
         SqlCommand    cmd       = new SqlCommand();
         if (dto.Id != 0)
         {
             cmd = new SqlCommand(string.Format("UPDATE ClassTeacher SET Name ='{0}', Location = '{1}', Teacher = '{2}' Where Id = {3}", dto.Name, dto.Location, dto.Teacher, dto.Id), nwindConn);
         }
         else
         {
             cmd = new SqlCommand(string.Format("insert into ClassTeacher (Name, Location, Teacher) values('{0}', '{1}', '{2}')", dto.Name, dto.Location, dto.Teacher), nwindConn);
         }
         nwindConn.Open();
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
     }
     return(true);
 }
示例#2
0
        public async Task <ActionResult> UpdateClassRecord(ClassTeacherDto data)
        {
            bool val = await new StudenHelper().UpdateClassRecord(data);

            return(Json(val));
        }