public static Entity.Employee checkForgotPassword(string username, string email) { try { string sqlforgot = " SELECT * FROM Employee WHERE Emp_username=@user AND Emp_Email=@email"; string Addvalue = "@user,@email"; string value = username + "," + email; Entity.Employee empCheck = new Entity.Employee(); ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlforgot, Addvalue, value); //SqlDataReader readCheckRole = conn.SelectSqlDataReader(sqlforgot); if (readCheckRole.Read()) { empCheck.Emp_FName = readCheckRole["Emp_FName"].ToString(); empCheck.Emp_LName = readCheckRole["Emp_LName"].ToString(); empCheck.Emp_username = readCheckRole["Emp_username"].ToString(); empCheck.Emp_password = readCheckRole["Emp_password"].ToString(); empCheck.Emp_Email = readCheckRole["Emp_Email"].ToString(); } conn.Close(); return empCheck; } catch (Exception) { return null; } }
public static string selectCuriID(string curYear, string curCourse, string curGroup) { ClassConnectDB con=new ClassConnectDB(); string reid=""; try { string sqlSelect=@"SELECT Curri_Id FROM Curriculum Where Curri_Year=@year AND Curri_Course=@co AND Curri_Group=@group"; string Addvalue="@year,@co,@group"; string value=curYear+","+curCourse+","+curGroup; SqlDataReader dr= con.SelectWhereSqlDataReader(sqlSelect,Addvalue,value); if (dr.Read()) { reid = dr["Curri_Id"].ToString(); } return reid; } catch (Exception) { return ""; } con.Close(); }
public static bool insertDetailTeachAfter(string year, string level, string term, string group, string subject, string userid) { ClassConnectDB conn = new ClassConnectDB(); string sqlcheckvalue = "SELECT DetailTech_ID FROM DetailTech WHERE DetailTech_Level=@level and DetailTech_Class=@class and DetailTeach_Year =@year and DetailTech_Term=@term and StructSub_Code=@code"; string addvaluecheck = "@level,@class,@year,@term,@code"; string valuecheck = level + "," + group + "," + year + "," + term + "," + subject; SqlDataReader drrcheck = conn.SelectWhereSqlDataReader(sqlcheckvalue, addvaluecheck, valuecheck); if (!drrcheck.HasRows) { string sql = @"INSERT INTO DetailTech (DetailTech_Level, DetailTech_Class, DetailTeach_Year, DetailTech_Term, StructSub_Code, Create_user, CreateDate) VALUES(@level,@class,@year,@term,@code,@user,getDate())"; string addvalue = "@level,@class,@year,@term,@code,@user"; string value = level + "," + group + "," + year + "," + term + "," + subject + "," + userid; bool insert = conn.InsertValue(sql, addvalue, value); conn.Close(); if (insert) { return true; } else { return false; } } else { return false; } }
public static DataTable getCommentForPost(int thePost) { try { string sql = @"SELECT TOP 1 [KmComPost_ID] ,[KmPost_ID] ,[ComPost_Detail] ,REPLACE(CONVERT(VARCHAR(11), Create_date, 106), ' ', '-') AS datepostkm ,CONVERT(VARCHAR(12),Create_time ,114) as timepostkm ,[Create_user_id] ,[Create_user_type] FROM KmCommentPost where KmPost_ID='" + thePost + "'order by [Create_date] asc "; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); conn.Close(); return dt; } catch (Exception) { return null; } }
public static int checkCredit(string year, string level, string term, string group) { try { /**************************** * function ตรวจสอบหน่วยกิตทั้งหมด * * **************************/ int creditAll = 0; ClassConnectDB conn = new ClassConnectDB(); string sql = @"SELECT sum (CONVERT(int,(SUBSTRING([StructSub_Credit], 1 , 1 )) ))as credit FROM [WEBCSDB].[dbo].[StructSubject] where StructSub_Code in ( SELECT TOP 1000 [StructSub_Code] FROM [DetailTech] where [DetailTech_Level]='" + level + "' and [DetailTech_Class]='" + group + "' and [DetailTeach_Year]='" + year + "' and [DetailTech_Term]='" + term + "' )"; SqlDataReader drr = conn.SelectSqlDataReader(sql); if (drr.Read()) { creditAll = Convert.ToInt32(drr["credit"].ToString()); } return creditAll; } catch (Exception) { return 0; } }
public static bool insertSubject(Entity.CurriculumInfo subject) { subcode=subject.StructSub_Code.ToString(); subNameTha=subject.StructSub_NameTha.ToString(); subNameEn=subject.StructSub_NameEn.ToString(); detail=subject.StructSub_Detail.ToString(); subCre=subject.StructSub_Credit.ToString(); curID=subject.Curri_Id.ToString(); ClassConnectDB conn = new ClassConnectDB(); //conn.TransStart(); try { string insertSubject = "INSERT INTO StructSubject(StructSub_Code, StructSub_NameTha, StructSub_NameEn, StructSub_Detail, StructSub_Credit, Curri_Id)VALUES(@code,@nameTha,@nameEn,@detail,@struCre,@curiID)"; string AddvalueSubject = "@code,@nameTha,@nameEn,@detail,@struCre,@curiID"; string value = subcode + "," + subNameTha + "," + subNameEn + "," + detail + "," + subCre + "," + curID; conn.InsertValue(insertSubject,AddvalueSubject,value); return true; } catch (Exception) { return true; } conn.Close(); }
public static Entity.Teacher checkForgotPassword(string username, string email) { try { string sqlforgot = " SELECT * FROM Teacher WHERE Tch_username=@user AND Tch_email=@email"; string Addvalue = "@user,@email"; string value = username + "," + email; Entity.Teacher tchCheck = new Entity.Teacher(); ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlforgot, Addvalue, value); //SqlDataReader readCheckRole = conn.SelectSqlDataReader(sqlforgot); if (readCheckRole.Read()) { tchCheck.Tch_FName = readCheckRole["Tch_FName"].ToString(); tchCheck.Tch_LName = readCheckRole["Tch_LName"].ToString(); tchCheck.Tch_username = readCheckRole["Tch_username"].ToString(); tchCheck.Tch_password = readCheckRole["Tch_password"].ToString(); tchCheck.Tch_email = readCheckRole["Tch_email"].ToString(); } conn.Close(); return tchCheck; } catch (Exception) { return null; } }
public static Entity.Student checkForgotPassword(string username, string email) { try { string sqlforgot = " SELECT * FROM Student WHERE Std_Username=@user AND Std_email=@email"; string Addvalue = "@user,@email"; string value = username + "," + email; Entity.Student stdCheck = new Entity.Student(); ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlforgot, Addvalue, value); //SqlDataReader readCheckRole = conn.SelectSqlDataReader(sqlforgot); if (readCheckRole.Read()) { stdCheck.Std_FName = readCheckRole["Std_FName"].ToString(); stdCheck.Std_LName = readCheckRole["Std_LName"].ToString(); stdCheck.Std_Username = readCheckRole["Std_Username"].ToString(); stdCheck.Std_Password = readCheckRole["Std_Password"].ToString(); stdCheck.Std_email = readCheckRole["Std_email"].ToString(); } conn.Close(); return stdCheck; } catch (Exception) { return null; } }
public static bool deleteDetailTeach(string dchID) { ClassConnectDB conn = new ClassConnectDB(); string sql = "DELETE FROM DetailTech WHERE DetailTech_ID='" + dchID + "'"; bool del = conn.QueryExecuteNonQuery(sql); conn.Close(); return del; }
public static DataTable selectTestCode() { ClassConnectDB conn = new ClassConnectDB(); string sql = " SELECT * FROM [WEBCSDB].[dbo].[Teacher] "; SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); return dt; }
public static System.Data.DataTable manateYear() { string sql = "select YEAR(getdate())+542 as passYear,YEAR(getdate())+543 as curYear,YEAR(getdate())+544 as fuYear"; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); return dt; }
public static DataTable showSubject(string code) { try { string sql = "SELECT * FROM StructSubject Where StructSub_Code='" + code + "'"; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader dr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(dr); return dt; } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; // return null; } }
public static DataTable insertGetcoment(int clickPostID) { ClassConnectDB conn = new ClassConnectDB(); string sql = @" SELECT [ComPost_ID] ,[Post_ID] ,[ComPost_Detail] ,[Create_date] ,[Create_time] ,[Create_user_id] ,[Create_user_type] FROM [CommentPost] where Post_ID = " + clickPostID + " ORDER BY Create_date asc , Create_time asc"; SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); conn.Close(); return dt; }
public static Entity.Student checkRoleLogin(string username, string password) { try { Entity.Student stdlog = new Entity.Student(); string sqlchekRole = " SELECT * FROM Student WHERE (Std_Username = @user) AND (Std_Password = @pass)"; string Addvalue = "@user,@pass"; string value = username + "," + password; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlchekRole, Addvalue, value); if (readCheckRole.Read()) { stdlog.Std_Type = readCheckRole["Std_Type"].ToString(); stdlog.Std_FName = readCheckRole["Std_FName"].ToString(); stdlog.Std_LName = readCheckRole["Std_LName"].ToString(); stdlog.Std_Campus_Code = readCheckRole["Std_Campus_Code"].ToString(); stdlog.Std_YearEducate = readCheckRole["Std_YearEducate"].ToString(); stdlog.Std_Username = readCheckRole["Std_Username"].ToString(); stdlog.Std_Password = readCheckRole["Std_Password"].ToString(); stdlog.std_picturepath = readCheckRole["Std_picturepath"].ToString(); } string iplog = Common.network.showIp(); string logdate = "CONVERT(VARCHAR(10), GETDATE(), 104)"; string logtime = "CONVERT(VARCHAR(8), GETDATE(), 108)"; string tid = readCheckRole["Std_Campus_Code"].ToString(); string insertLog = "INSERT INTO LogLogInStd(Log_IP, Log_Date, Log_timeStart, Std_Campus_Code) VALUES('" + iplog + "'," + logdate + "," + logtime + "," + tid + ")"; conn.QueryExecuteNonQuery(insertLog); conn.Close(); return stdlog; } catch (Exception) { return null; } }
public static Entity.Teacher checkRoleLogin(string username, string password) { Entity.Teacher tch = new Entity.Teacher(); try { string sqlchekRole = " SELECT * FROM Teacher WHERE Tch_username=@user AND Tch_password=@pass"; string Addvalue = "@user,@pass"; string value = username + "," + password; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlchekRole, Addvalue, value); if (readCheckRole.Read()) { tch.Tch_ID = readCheckRole["Tch_ID"].ToString(); tch.Tch_Type = readCheckRole["Tch_Type"].ToString(); tch.Tch_FName = readCheckRole["Tch_FName"].ToString(); tch.Tch_LName = readCheckRole["Tch_LName"].ToString(); tch.Tch_username = readCheckRole["Tch_username"].ToString(); tch.Tch_password = readCheckRole["Tch_password"].ToString(); tch.Tch_picturepath = readCheckRole["Tch_picturepath"].ToString(); } string iplog = Common.network.showIp(); string logdate = "CONVERT(VARCHAR(10), GETDATE(), 104)"; string logtime = "CONVERT(VARCHAR(8), GETDATE(), 108)"; string tid = readCheckRole["Tch_ID"].ToString(); string insertLog = "INSERT INTO LogLoginTeach(Log_IP, Log_Date, Log_timeStart, Tch_ID) VALUES('" + iplog + "'," + logdate + "," + logtime + "," + tid + ")"; conn.QueryExecuteNonQuery(insertLog); conn.Close(); return tch; } catch (Exception) { return null; } }
public static Entity.Employee checkRoleLogin(string username, string password) { try { Entity.Employee emp = new Entity.Employee(); string sqlchekRole = " SELECT * FROM Employee WHERE Emp_username=@user AND Emp_password=@pass"; string Addvalue = "@user,@pass"; string value = username + "," + password; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlchekRole, Addvalue, value); if (readCheckRole.Read()) { emp.Emp_ID = readCheckRole["Emp_ID"].ToString(); emp.Emp_Type = readCheckRole["Emp_Type"].ToString(); emp.Emp_LName = readCheckRole["Emp_LName"].ToString(); emp.Emp_FName = readCheckRole["Emp_FName"].ToString(); emp.Emp_username=readCheckRole["Emp_username"].ToString(); emp.Emp_password = readCheckRole["Emp_password"].ToString(); } string iplog = Common.network.showIp(); string logdate = "CONVERT(VARCHAR(10), GETDATE(), 104)"; string logtime = "CONVERT(VARCHAR(8), GETDATE(), 108)"; string tid = readCheckRole["Emp_ID"].ToString(); string insertLog = "INSERT INTO LogLoginEmp(Log_IP, Log_Date, Log_timeStart, Emp_id) VALUES('" + iplog + "'," + logdate + "," + logtime + "," + tid + ")"; conn.QueryExecuteNonQuery(insertLog); conn.Close(); return emp; } catch (Exception) { return null; } }
public static System.Data.DataTable selectShowAllPlanTree(string yearCurriEdu) { DataTable dt = new DataTable(); try { string sql = @"SELECT ShowPlanEducate.ShowPlan_Year, ShowPlanEducate.ShowPlan_Semester, ShowPlanEducate.StructSub_Code, StructSubject.StructSub_NameTha FROM ShowPlanEducate INNER JOIN StructSubject ON ShowPlanEducate.StructSub_Code = StructSubject.StructSub_Code where ShowPlanEducate.showplan_yearupdate='" + yearCurriEdu + "'"; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); dt.Load(drr); return dt; } catch (Exception) { return null; } }
public static string selectShowNameSubjectPass(string folloSubject) { string name; ClassConnectDB conn = new ClassConnectDB(); try { string sql="SELECT StructSub_NameTha FROM StructSubject WHERE StructSub_Code='"+folloSubject+"'"; SqlDataReader drr= conn.SelectSqlDataReader(sql); if (drr.Read()) { name = drr["StructSub_NameTha"].ToString(); return name; } else return null ; } catch (Exception) { return null; } }
public static string selectCuriYear(string yearedu) { string year = ""; try { string sql = @"SELECT max( [Curri_Year]) as yearEducate FROM [Curriculum] where curri_year <= '" + yearedu + "' "; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); if (drr.Read()) { year = drr["yearEducate"].ToString(); } conn.Close(); return year; } catch (Exception) { return null; } }
public static System.Data.DataTable selectUserPost(string userid) { try { ClassConnectDB conn = new ClassConnectDB(); string sql = @"SELECT [Post_ID] ,[Post_Detail] ,[Create_date] ,[Create_time] ,[Create_user_id] ,[Create_user_type] FROM [Post] where Create_user_id = '" + userid + "' ORDER BY Create_date desc , Create_time desc "; SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); conn.Close(); return dt; } catch (Exception ex) { return null; } }
public static DataTable selectShowStudentSuject(string code, string user) { try { string sql = @"SELECT SchoolRecord.SchoolRecord_Level, SchoolRecord.SchoolRecord_Term, SchoolRecord.StructSub_Code, StructSubject.StructSub_NameTha, SchoolRecord.SchoolRecord_Grade FROM SchoolRecord INNER JOIN StructSubject ON SchoolRecord.StructSub_Code = StructSubject.StructSub_Code where SchoolRecord.Std_Campus_Code='" + user + "' AND SchoolRecord.StructSub_Code='" + code + "' "; ClassConnectDB conn = new ClassConnectDB(); DataTable dt = new DataTable(); SqlDataReader drr = conn.SelectSqlDataReader(sql); dt.Load(drr); conn.Close(); return dt; } catch (Exception ex) { Console.WriteLine(ex.ToString()); //return null; throw; } }
public static bool updateDetailTeach(string ecuID, string code, string codeOld, string year) { try { ClassConnectDB conn = new ClassConnectDB(); //string sql = "UPDATE DetailTech SET StructSub_Code='" + code + "' where DetailTech_ID='" + detailTeach + "'"; string sql = "UPDATE EducationOfStudents set StructSub_Code='" + code + "' where EduStdYearEdu=" + year + " and StructSub_Code='" + codeOld + "'"; string sql2 = "UPDATE EducationOfStudents SET StructSub_Code='" + codeOld + "' where EduStdID='" + ecuID + "'"; bool update = conn.QueryExecuteNonQuery(sql); bool upd = conn.QueryExecuteNonQuery(sql2); conn.Close(); return update; } catch (Exception ex) { return false; } }
public static DataTable selectshowSwap(string yearEdu, int year, int level, int term, DataTable dtt, string curr) { string yearPlan = DAL.PlanEducate.selectCuriYear(yearEdu); //ตรวจสอบว่าเรียนหลักสูตรไหน DataTable dtDetailTeach = selectShowDetailTechInTerm(yearEdu, year.ToString(), term.ToString()); // ตรวจสอบว่าช่วงที่เรียนปี 1-ปี N ClassConnectDB conn = new ClassConnectDB(); string sql = "SELECT StructSub_Code, StructSub_NameTha, StructSub_Credit FROM StructSubject where Curri_Id='" + curr + "'"; foreach (DataRow rrsubject in dtDetailTeach.Rows) { sql += " AND StructSub_Code <> '" + rrsubject[0].ToString() + "' "; } SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dtselect = new DataTable(); dtselect.Load(drr); DataTable dt = new DataTable(); dt.Columns.Add("no"); dt.Columns.Add("subcode"); dt.Columns.Add("subThai"); dt.Columns.Add("credite"); int i = 1; if (dtselect.Rows.Count > 0) { foreach (DataRow item in dtselect.Rows) { string code = item[0].ToString(); if (!code.Substring(0, 1).Equals("x")) { dt.Rows.Add(i, item[0], item[1], item[2]); } i++; } } conn.Close(); return dt; }
public static DataTable selectDtShowGrideViewCase3(string year, string level, string term) { ClassConnectDB conn = new ClassConnectDB(); string sql = @"SELECT StructSubject.StructSub_Code, StructSubject.StructSub_NameTha, StructSubject.StructSub_Credit, StructSubject.Curri_Id,DetailTech_ID FROM DetailTech INNER JOIN StructSubject ON DetailTech.StructSub_Code = StructSubject.StructSub_Code where DetailTech.DetailTeach_Year='" + year + "' AND DetailTech.DetailTech_Level='" + level + "' AND DetailTech.DetailTech_Term='" + term + "' AND DetailTech.DetailTeach_Status='u' "; SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dtt = new DataTable(); dtt.Load(drr); DataTable dt = new DataTable(); dt.Columns.Add("no"); dt.Columns.Add("subcode"); dt.Columns.Add("subThai"); dt.Columns.Add("credite"); dt.Columns.Add("curi"); dt.Columns.Add("dchid"); int i = 1; if (dtt.Rows.Count > 0) { foreach (DataRow item in dtt.Rows) { dt.Rows.Add(i, item[0], item[1], item[2], item[3], item[4]); i++; } } return dt; }
public static bool insertDetailTeach(string yeare, string level, string term, string group, string subject, string userid, string teacher, string classid) { /********************************* * * บันทึกรายละเอียดห้องเรียน * * *******************************/ string year = (Convert.ToInt32(yeare) + 543).ToString(); ClassConnectDB conn = new ClassConnectDB(); string sql = @"INSERT INTO DetailTech (DetailTech_Level, DetailTech_Class, DetailTeach_Year, DetailTech_Term, Tch_ID, ClassRoom_ID, StructSub_Code, Create_user, CreateDate, DetailTeach_Status) VALUES('" + level + "','" + group + "'," + year + ",'" + term + "','" + teacher + "','" + classid + "','" + subject + "','" + userid + "',getDate(),'A')"; //string addvalue = "@level,@class,@year,@term,@tchid,@classid,@code,@user,"; //string value = level + "," + group + "," + year + "," + term +","+teacher+","+classid+","+subject+ "," + userid; // bool insert = conn.InsertValue(sql, addvalue, value); bool insert = conn.QueryExecuteNonQuery(sql); conn.Close(); if (insert) { return true; } else { return false; } }
public static void selectDatatableCase3(string yearEdu, string yearCurrent, string level, string termStudy, DataTable dttt) { string yearPlan = DAL.PlanEducate.selectCuriYear(yearEdu); //ตรวจสอบว่าเรียนหลักสูตรไหน DataTable dtDetailTeach = selectShowDetailTechInTerm(yearEdu, yearCurrent, termStudy); // ตรวจสอบว่าช่วงที่เรียนปี 1-ปี N DataTable dtPlan = selectShowDetailTechInPlanCase3(dtDetailTeach, yearPlan, yearEdu, yearCurrent, termStudy, dttt); ClassConnectDB conn = new ClassConnectDB(); //DataTable dt = new DataTable(); //dt.Columns.Add("no"); //dt.Columns.Add("subcode"); //dt.Columns.Add("subThai"); //dt.Columns.Add("credite"); //dt.Columns.Add("curi"); //int i = 1; //if (dtPlan.Rows.Count > 0) //{ // foreach (DataRow item in dtPlan.Rows) // { // dt.Rows.Add(i,item[0],item[1],item[2],item[3]); // i++; // } //} foreach (DataRow item in dtPlan.Rows) { string insert = @"INSERT INTO DetailTech (DetailTech_Level, DetailTeach_Year, DetailTech_Term, StructSub_Code, DetailTeach_Status,[DetailTech_Class]) VALUES('" + level + "','" + yearCurrent + "','" + termStudy + "','" + item[0].ToString() + "','u','1')"; conn.QueryExecuteNonQuery(insert); } conn.Close(); // return dt; }
public static DataTable selectShowDetailTechInPlanCase3(DataTable dtDetailTeach, string yearPlan, string yearEdu, string yearCurrent, string term, DataTable dtcurri) { ClassConnectDB conn = new ClassConnectDB(); int yearStart = Convert.ToInt32(yearEdu); int yearEnd = Convert.ToInt32(yearCurrent); int year = 0; int range = yearEnd - yearStart; if (range <= 0) { year = 1; } else { year = range + 1; } string sql = @" Select distinct ShowPlanEducate.StructSub_Code ,StructSub_NameTha,StructSub_Credit,Curri_Id FROM ShowPlanEducate INNER JOIN StructSubject ON ShowPlanEducate.StructSub_Code = StructSubject.StructSub_Code where ( ShowPlan_YearUpdate='" + yearPlan + "' and ShowPlan_Year = " + year + " and ShowPlan_Semester='" + term + "' )"; if (dtDetailTeach.Rows.Count > 0) { foreach (DataRow rows in dtDetailTeach.Rows) { sql += " AND ShowPlanEducate.StructSub_Code <> '" + rows[0] + "'"; } } foreach (DataRow curri in dtcurri.Rows) { int curriuser = Convert.ToInt32(curri[5].ToString()); int curriAll = Convert.ToInt32(curri[4].ToString()); if (curriuser >= curriAll) { sql += " AND StructSubject.Curri_Id <> " + curri[0].ToString(); } } SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); return dt; }
public static bool updateDetailTeach(string tchid, string classid, string dchid, string subcode, string subThai) { ClassConnectDB conn = new ClassConnectDB(); string sqlupdateDetailTeach = "UPDATE DetailTech SET StructSub_Code='" + subcode + "' where DetailTech_ID='" + dchid + "' and Tch_ID='" + tchid + "'"; bool update = conn.QueryExecuteNonQuery(sqlupdateDetailTeach); string sql = "UPDATE ClassRoom SET ClassRoom_Name='" + subThai + "' where ClassRoom_ID ='" + classid + "'"; bool upd = conn.QueryExecuteNonQuery(sql); conn.Close(); return upd; }
public static bool deleteDetailTeach(string subcode, string tchID) { ClassConnectDB conn = new ClassConnectDB(); string sql = "DELETE FROM DetailTech WHERE StructSub_Code ='" + subcode + "' AND Tch_ID='" + tchID + "'"; bool del = conn.QueryExecuteNonQuery(sql); conn.Close(); return del; }
public static DataTable selectShowSwap1(string yearEdu, string year, string level, string term, string curri) { ClassConnectDB conn = new ClassConnectDB(); string yearPlan = DAL.PlanEducate.selectCuriYear(yearEdu); //ตรวจสอบว่าเรียนหลักสูตรไหน DataTable dttt = new DataTable(); dttt.Columns.Add("code"); int lev = Convert.ToInt32(level); for (int i = 1; i <= lev; i++) { DataTable dtDetailTeach = selectShowDetailTechInTerm(yearEdu, year, i.ToString()); // ตรวจสอบว่าช่วงที่เรียนปี 1-ปี N foreach (DataRow rr in dtDetailTeach.Rows) { dttt.Rows.Add(rr[0].ToString()); } } string sql = @"SELECT StructSubject.StructSub_Code as code, StructSubject.StructSub_NameTha as nameTha, StructSubject.StructSub_Credit as credit FROM Curriculum INNER JOIN StructSubject ON Curriculum.Curri_Id = StructSubject.Curri_Id where Curriculum.Curri_Id='" + curri + "' "; foreach (DataRow item in dttt.Rows) { sql += " and StructSubject.StructSub_Code <> '" + item[0].ToString() + "' "; } DataTable dtt = new DataTable(); SqlDataReader drr = conn.SelectSqlDataReader(sql); dtt.Load(drr); return dtt; }