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 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 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 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.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 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 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 selectCommentPost(int postID) { ClassConnectDB conn = new ClassConnectDB(); string sql = @" SELECT Top 1 [ComPost_ID] ,[Post_ID] ,[ComPost_Detail] ,[Create_date] ,[Create_time] ,[Create_user_id] ,[Create_user_type] FROM [CommentPost] where Post_ID = " + postID + " ORDER BY Create_date desc , Create_time desc"; 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 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 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 bool insertGradeStart2(string detailTeachID, string grade, string userid, string usertype, string code) { ClassConnectDB conn = new ClassConnectDB(); string sql = @"INSERT INTO SchoolRecord (DeEduStd, SchoolRecord_Grade, Std_Campus_Code, Create_User, Create_Type, Create_Date) VALUES ('" + detailTeachID + "','" + grade + "','" + code + "','" + userid + "','" + usertype + "',getDate())"; bool insert = conn.QueryExecuteNonQuery(sql); conn.Close(); if (insert) { return true; } else { return false; }; }
public static bool checkvalueDoubleShowgride(string ye, string level, string term, string group, string subject, string userid, string teacher) { /**** * * ตรวจสอบข้อมูลก่อนจะเพิ่มเข้ารายละเอียดการสอนว่ามี ข้อมูลหรือไม่ * * ***************/ string year = (Convert.ToInt32(ye) + 543).ToString(); ClassConnectDB conn = new ClassConnectDB(); string sql = @" select * FROM [DetailTech] where DetailTeach_Year='" + year + "' and DetailTech_Level='" + level + "' and DetailTech_Term='" + term + "' and DetailTech_Class='" + group + "' and StructSub_Code ='" + subject + "' and DetailTeach_Status='A' "; SqlDataReader drr = conn.SelectSqlDataReader(sql); if (drr.HasRows) { conn.Close(); return false; } else { conn.Close(); return true; } }
public static DataTable selectShowSubjectShowpopup(string year, string code, string nameThai) { ClassConnectDB conn = new ClassConnectDB(); string sql = "Select * FROM [StructSubject] where 1=1 "; if (!string.IsNullOrEmpty(code)) { sql += " and [StructSub_Code]='" + code + "'"; } if (!string.IsNullOrEmpty(nameThai)) { sql += " and [StructSub_NameTha] LIKE '%" + nameThai + "%'"; } SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); conn.Close(); return dt; }
public static DataTable searchShowDetailTeach(string year, string level, string term) { ClassConnectDB conn = new ClassConnectDB(); string sql = @"SELECT (DetailTech.DetailTeach_Year) as DetailTeach_Year, (DetailTech.DetailTech_Level) as DetailTech_Level , (DetailTech.DetailTech_Term) as DetailTech_Term, ( StructSubject.StructSub_Code) as StructSub_Code,( StructSubject.StructSub_NameTha) as StructSub_NameTha, (StructSubject.StructSub_NameEn ) as StructSub_NameEn , (StructSubject.StructSub_Credit ) as StructSub_Credit FROM DetailTech INNER JOIN StructSubject ON DetailTech.StructSub_Code = StructSubject.StructSub_Code WHERE 1=1 "; if (!year.Equals("N")) { sql += " AND [DetailTeach_Year]='" + year + "' "; } if (!level.Equals("0")) { sql += " AND [DetailTech_Level]= '" + level + "'"; } if (!term.Equals("0")) { sql += " AND [DetailTech_Term] ='" + term + "'"; } SqlDataReader drr = conn.SelectSqlDataReader(sql); DataTable dt = new DataTable(); dt.Load(drr); conn.Close(); return dt; }
public static bool insertGradeStart(string year, string level, string term, string code, string resultGrade, string userid, string usertype) { ClassConnectDB conn = new ClassConnectDB(); string sql = @"INSERT INTO SchoolRecord (SchoolRecord_Year, SchoolRecord_Level, SchoolRecord_Term, StructSub_Code, SchoolRecord_Grade, Std_Campus_Code, Create_User, Create_Type, Create_Date) VALUES (@year,@level,@term,@code,@grade,@stdcode,@stdcode,@createtpe,getDate())"; string addvalue = "@year,@level,@term,@code,@grade,@stdcode,@createtpe"; string value = year + "," + level + "," + term + "," + code + "," + resultGrade + "," + userid + "," + usertype; bool insert = conn.InsertValue(sql, addvalue, value); conn.Close(); if (insert) { return true; } else { return false; }; }
public static DataTable selectShowGrideAddGradeStart(string year) { try { DateTime datetime = DateTime.Now; int yearCurrent = (datetime.Year + 543); int yearEdu = Convert.ToInt32(year); ClassConnectDB conn = new ClassConnectDB(); string sql = @"SELECT DetailTech_ID, DetailTech.DetailTeach_Year, DetailTech.DetailTech_Level, DetailTech.DetailTech_Term, StructSubject.StructSub_Code, StructSubject.StructSub_NameTha FROM StructSubject INNER JOIN DetailTech ON StructSubject.StructSub_Code = DetailTech.StructSub_Code WHERE DetailTeach_Status='N' "; int count = 1; for (int i = yearEdu; i < yearCurrent; i++) { if (count == 1) { sql += " AND (DetailTech.DetailTeach_Year='" + i + "' and DetailTech_Class='1' and [DetailTech_Level]='" + count + "' ) "; } else { sql += " OR (DetailTech.DetailTeach_Year='" + i + "' and DetailTech_Class='1' and [DetailTech_Level]='" + count + "') "; } count++; } sql += " order by DetailTech.DetailTeach_Year "; DataTable dtt = new DataTable(); SqlDataReader drrread = conn.SelectSqlDataReader(sql); dtt.Load(drrread); conn.Close(); return dtt; } catch (Exception) { return null; } }
public static string checkTerm(string yearEdu) { string term = ""; ClassConnectDB conn = new ClassConnectDB(); string sql = @" SELECT max ([DetailTech_Term]) as term FROM [DetailTech] where DetailTeach_Year = " + yearEdu + ""; SqlDataReader drr = conn.SelectSqlDataReader(sql); if (drr.Read()) { term = drr["term"].ToString(); } conn.Close(); return term; }
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 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 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 bool insertNewSubjectStd(string year, string yearcurri, string userid) { string sqlinsert = @" insert into EducationOfStudents ( [EduStdLevel],[EduStdTerm] ,[StructSub_Code],[Create_user],[CreateDate],[EduStdYearEdu],[EduStdYearCurri]) SELECT [ShowPlan_Year],[ShowPlan_Semester],[StructSub_Code] ,'" + userid + "' ,GETDATE() ,'" + year + "','" + yearcurri + "' FROM [WEBCSDB].[dbo].[ShowPlanEducate] where ShowPlan_YearUpdate='" + yearcurri + "'"; ClassConnectDB conn = new ClassConnectDB(); bool insert = conn.QueryExecuteNonQuery(sqlinsert); conn.Close(); return insert; }
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 bool checkBtnOpenNewEducationPage(string year) { string sql = @" select * from EducationOfStudents where EduStdYearEdu='" + year + "'"; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); bool check; if (drr.HasRows) { check = true; } else { check = false; } drr.Close(); conn.Close(); return check; }