//---------------------------------------------- //---------------------------------------------- private bool IsSameDeptCode(iLocalDB db, string code) { db.Open(); string query = string.Format("SELECT xDept_name FROM xDEPARTMENT WHERE xDept_code='{0}'", code); // {0}에는 code 값이 들어감 string err_msg = db.Query(query); string title = ""; if (err_msg != null) { MessageBox.Show(query + "\n\n" + err_msg, "SQL Error"); return(false); } db.ExecuteReader(query); while (db.Read()) { title = db.GetData("xDept_name").ToString(); } if (title != cbx_학과입력.SelectedValue.ToString()) //입력 학과랑 학번이랑 틀림 { return(false); } else { return(true); } }
}//Main //-------------------------------------------------- static bool? tableExists(iLocalDB db, string tableName) { string result = db.Query(string.Format("select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME='{0}'", tableName)); if (result != null) return null; return db.HasRows; }
//---------------------------------------------- //---------------------------------------------- static bool DB_Query(iLocalDB db, string query) { string err_msg = db.Query(query); if (err_msg != null) { MessageBox.Show("Error\n" + err_msg + "\n" + query); return(false); } return(true); }
//------------------------------------------------ static bool DB_Query(iLocalDB db, string query) { string err_msg = db.Query(query); if (err_msg != null) { Console.WriteLine("Error\n" + err_msg + "\n" + query); return false; } return true; }
//----------------------------------------------- static bool IsValidDeptCode(iLocalDB db, string code) { string query = string.Format("SELECT * FROM xDEPARTMENT WHERE xDept_code='{0}'", code); string res = db.Query(query); if(res != null) { Console.WriteLine(res); return false; } if (db.HasRows) return true; return false; }
//--------------------------------------------------- static bool IsNewHakbun(iLocalDB db, string hakbun) { string query = string.Format("SELECT xHakbun FROM xSTUDENTS WHERE xHakbun='{0}'", hakbun); string res = db.Query(query); if (res != null) { Console.WriteLine(res); return false; } if (db.HasRows) return Error("같은 학번이 이미 존재합니다." + hakbun); return true; }
//----------------------------------------------- private bool IsNewHakbun(iLocalDB db, string hakbun) { string query = string.Format("select xHakbun from xSTUDENTS where xHakbun='{0}'", hakbun); string res = db.Query(query); if (res != null) { return(false); } if (db.HasRows) { return(Error("같은 학번이 이미 존재합니다." + hakbun)); } return(true); }
//----------------------------------------------- private bool IsValidDeptCode(iLocalDB db, string code) { string query = string.Format("SELECT * FROM xDEPARTMENT WHERE xDept_code='{0}'", code); string res = db.Query(query); if (res != null) { MessageBox.Show(res); return(false); } if (db.HasRows) { return(true); } return(false); }
//---------------------------------------------- //---------------------------------------------- private bool IsNewHackbun(iLocalDB db, string 학번) { string query = string.Format("SELECT xHakbun FROM xSTUDENTS WHERE xHakbun='{0}'", 학번); // {0}에는 code 값이 들어감 string res = db.Query(query); if (res == "") { MessageBox.Show(res); return(false); } else if (db.HasRows) { return(Error("같은 학번이 이미 존재합니다" + 학번)); } else { return(true); } }