public static bool updateChangeNewsPasswordPage(string userID, string newPassword) { try { string sqlupdate = " UPDATE Employee SET Emp_password=@pass WHERE Emp_ID=@id"; string Addvalue = "@pass,@id"; string value = newPassword+","+userID; ClassConnectDB conn = new ClassConnectDB(); conn.UpdateValue(sqlupdate, Addvalue, value); conn.Close(); return true; } catch (Exception) { return false; } }
// public static DataTable showStudentSendHomeWork(string detailTeachid, string numhomework) // { // try // { // ClassConnectDB conn = new ClassConnectDB(); // string sql = @"SELECT Student.Std_FName, Student.Std_LName, edu.EduStdLevel, dedu.DeEduStdClass, // Homework.Homework_Num, Homework.Homework_Path, // CONVERT(VARCHAR(11),Homework.Update_date, 106) // , CONVERT(VARCHAR(8),Homework.Update_date, 108) // FROM EnrollIn INNER JOIN // Homework ON EnrollIn.Enroll_ID = Homework.Enroll_ID INNER JOIN // Student ON EnrollIn.Std_Campus_Code = Student.Std_Campus_Code INNER JOIN // DetailEducationOfStudent dedu ON EnrollIn.DeEduStd = dedu.DeEduStd INNER JOIN // EducationOfStudents edu ON dedu.EduStdID=edu.EduStdID // Where (Homework.Homework_Num='" + numhomework + "') AND ( edu.EduStdID = '" + detailTeachid + "') "; // SqlDataReader drr = conn.SelectSqlDataReader(sql); // DataTable dt = new DataTable(); // dt.Load(drr); // return dt; // } // catch (Exception) // { // return null; // } // } public static bool showStudentSendHomeWork(string homeworkid, string enroolid, string path) { try { string sqlupdate = "UPDATE Homework SET Update_date =getdate(), Homework_Status ='Y', Homework_Path =@path WHERE Homework_ID=@hwid"; string addvalue = "@path,@hwid"; string value = path + "," + homeworkid; ClassConnectDB conn = new ClassConnectDB(); bool update = conn.UpdateValue(sqlupdate, addvalue, value); conn.Close(); if (update) { return true; } else { return false; } } catch (Exception) { return false; } }
public static bool updateSubjectPage(Entity.CurriculumInfo subject) { try { string code = subject.StructSub_Code; string nameTha = subject.StructSub_NameTha; string nameEn = subject.StructSub_NameEn; string detail = subject.StructSub_Detail; string credit = subject.StructSub_Credit; string sql = @"UPDATE StructSubject SET StructSub_NameTha =@nametha, StructSub_NameEn =@nameEn, StructSub_Detail =@nameDe, StructSub_Credit =@nameCre Where StructSub_Code =@code "; string Addvalue = "@nametha,@nameEn,@nameDe,@nameCre,@code"; string value = nameTha + "," + nameEn + "," + detail + "," + credit + "," + code; ClassConnectDB conn = new ClassConnectDB(); conn.UpdateValue(sql, Addvalue, value); return true; } catch (Exception) { return false; } }
public static bool updateTeacher(Entity.Teacher tch) { try { ClassConnectDB conn = new ClassConnectDB(); string id = tch.Tch_ID.ToString(); string fname = tch.Tch_FName.ToString(); string fnameEn = tch.Tch_FNameEn.ToString(); string lname = tch.Tch_LName.ToString(); string lnameEn = tch.Tch_LNameEn.ToString(); string nickname = tch.Tch_Nickname.ToString(); string sex = tch.Tch_Sex.ToString(); // string birth = tch.Tch_Birth.ToString(); string address = tch.Tch_Address.ToString(); string tel = tch.Tch_Tel.ToString(); string type = tch.Tch_Type.ToString(); string email = tch.Tch_email.ToString(); string username = tch.Tch_username.ToString(); string password = tch.Tch_password.ToString(); string picturepath = tch.Tch_picturepath.ToString(); string typeTch = tch.Tch_TypeInSch.ToString(); string sqlupdate = ""; string Adddvalue = ""; string value = ""; if (username == "1") { //************************ ไมอัพเดท username password sqlupdate = @"UPDATE Teacher SET Tch_FName =@fname, Tch_LName =@lname, Tch_FNameEn =@fnameEn, Tch_LNameEn =@lnameEn, Tch_Nickname =@nickName, Tch_Sex =@sex, Tch_Address =@address, Tch_Tel =@tel, Tch_Type =@type, Tch_email =@email, Tch_picturepath=@pic ,Tch_TypeInSch=@tchtype where Tch_ID=@id"; Adddvalue = "@fname,@lname,@fnameEn,@lnameEn,@nickName,@sex,@address,@tel,@type,@email,@id,@pic,@tchtype"; value = fname + "," + lname + "," + fnameEn + "," + lnameEn + "," + nickname + "," + sex + "," + address + "," + tel + "," + type + "," + email + ","+ id + "," + picturepath+","+typeTch; } else { sqlupdate = @"UPDATE Teacher SET Tch_FName =@fname, Tch_LName =@lname, Tch_FNameEn =@fnameEn, Tch_LNameEn =@lnameEn, Tch_Nickname =@nickName, Tch_Sex =@sex, Tch_Address =@address, Tch_Tel =@tel, Tch_Type =@type, Tch_email =@email, Tch_username =@username, Tch_password =@pass , Tch_picturepath=@pic ,Tch_TypeInSch=@tchtype where Tch_ID=@id"; Adddvalue = "@fname,@lname,@fnameEn,@lnameEn,@nickName,@sex,@address,@tel,@type,@email,@username,@pass,@id,@pic,@tchtype"; value = fname + "," + lname + "," + fnameEn + "," + lnameEn + "," + nickname + "," + sex + "," + address + "," + tel + "," + type + "," + email + "," + username + "," + password + "," + id + "," + picturepath+","+typeTch; } bool update = conn.UpdateValue(sqlupdate, Adddvalue, value); conn.Close(); if (update) { return true; } else return false; } catch (Exception) { return false; } }
public static bool updateChangeNewsPasswordPage(string userID, string newPassword) { try { string sqlupdate = "UPDATE Student SET Std_Password=@pass Where Std_Campus_Code=@id"; string Addvalue = "@pass,@id"; string value = newPassword + "," + userID; ClassConnectDB conn = new ClassConnectDB(); conn.UpdateValue(sqlupdate, Addvalue, value); conn.Close(); return true; } catch (Exception) { return false; } }
public static bool updateUserStudent(Entity.Student student) { try { ClassConnectDB conn = new ClassConnectDB(); string id = student.Std_Campus_Code.ToString(); string code = student.Std_Campus_Code.ToString(); string fname = student.Std_FName.ToString(); string fnameEn = student.Std_FNameEn.ToString(); string lname = student.Std_LName.ToString(); string lnameEn = student.Std_LNameEn.ToString(); string nickname = student.Std_Nickname.ToString(); string sex = student.Std_Sex.ToString(); string birth = student.Std_Birth.ToString(); string address = student.Std_Address.ToString(); string tel = student.Std_Tel.ToString(); string type = student.Std_Type.ToString(); string email = student.Std_email.ToString(); string username = student.Std_Campus_Code.ToString(); string password = student.Std_Password.ToString(); string group = student.Std_Group.ToString(); string year = student.Std_YearEducate.ToString(); string picturepath = student.std_picturepath.ToString(); string sqlupdate = @"UPDATE Student SET Std_FName=@name, Std_LName =@lname, Std_FNameEn =@fnameEn, Std_LNameEn =@LnameEn, Std_Nickname =@nickname, Std_Campus_Code =@code, Std_Sex =@sex, Std_Birth =@birth, Std_Address =@address, Std_Tel =@tel, Std_Type =@type, Std_YearEducate =@year, Std_Group =@group, Std_email =@email, Std_Username =@username, Std_Password =@pass ,Std_picturepath=@picpath where Std_Campus_Code=@id"; string Adddvalue = "@name,@lname,@fnameEn,@LnameEn,@nickname,@code,@sex,@birth,@address,@tel,@type,@year,@group,@email,@username,@pass,@picpath,@id"; string value = fname + "," + lname + "," + fnameEn + "," + lnameEn + "," + nickname + "," + code + "," + sex + "," + birth + "," + address + "," + tel + "," + type + "," + year + "," + group + "," + email + "," + username + "," + password + "," + picturepath + "," + id; bool update = conn.UpdateValue(sqlupdate, Adddvalue, value); conn.Close(); if (update) { return true; } else return false; } catch (Exception) { return false; } }