public int getIdcourse(String course_service) { int existe = 0; //bandera IDataReader idr = null; sb.Clear(); sb.Append("USE escuela_manejo;"); sb.Append("SELECT id_course_service FROM course_service WHERE name =" + "'" + course_service + "';"); try { con.AbrirCOnexion(); idr = con.Leer(CommandType.Text, sb.ToString()); if (idr.Read()) { existe = (Int32)idr["id_course_service"]; } return(existe); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw; } finally { idr.Close(); con.CerrarConexion(); } }//fin del metodo
public ListStore ListCourse() { ListStore data = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); IDataReader dr = null; sb.Clear(); sb.Append("SELECT id_vehicle,id_category,model,brand,plate,color,state FROM vehicle"); try { con.AbrirCOnexion(); dr = con.Leer(CommandType.Text, sb.ToString()); while (dr.Read()) { data.AppendValues(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[3].ToString(), dr[4].ToString(), dr[5].ToString(), dr[6].ToString()); //dr.Close(); }//fin de while return(data); } catch (Exception e) { ms = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, e.Message); ms.Run(); ms.Destroy(); throw; } finally { dr.Close(); con.CerrarConexion(); } }//fin del metodo
public ListStore getColumnsService(String course_service) { PaymentDetails tpaymentdetails = new PaymentDetails(); IDataReader idr = null; sb.Clear(); sb.Append("USE escuela_manejo;"); sb.Append("SELECT id_course_service, name, price, state FROM course_service WHERE name =" + "'" + course_service + "';"); try { con.AbrirCOnexion(); idr = con.Leer(CommandType.Text, sb.ToString()); while (idr.Read()) { datos.AppendValues(idr[0].ToString(), idr[1].ToString(), idr[2].ToString(), idr[3].ToString()); //benito.AppendValues(idr[0].ToString(), idr[1].ToString() , idr[2].ToString()); tpaymentdetails.Id_course_service = (Int32)idr[0]; DetailInfo.Add(tpaymentdetails); //dr.Close(); }//fin de while return(datos); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw; } finally { idr.Close(); con.CerrarConexion(); } }//fin del metodo
}//fin del metodo public bool ExistUser(Course cour) { bool exist = false; IDataReader idr = null; sb.Clear(); sb.Append("USE escuela_manejo;"); sb.Append("SELECT * FROM course where name = " + "'" + cour.Name + "';"); try { con.AbrirCOnexion(); idr = con.Leer(CommandType.Text, sb.ToString()); if (idr.Read()) { exist = true; } return(exist); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw; } finally { if (idr != null) { idr.Close(); } con.CerrarConexion(); } }
} //fin del metodo public bool ExistUser(CourseOperating courseOp) { bool exist = false; IDataReader idr = null; sb.Clear(); sb.Append("USE escuela_manejo;"); sb.Append("SELECT * FROM course_operating where id_course = " + "'" + courseOp.Id_course + "'AND id_instructor ='" + courseOp.Id_instructor + "'AND id_vehicle ='" + courseOp.Id_vehicle + "'AND id_customer ='" + courseOp.Id_customer + "'AND start_date ='" + courseOp.Start_date + "'AND end_date ='" + courseOp.End_date + "';"); try { con.AbrirCOnexion(); idr = con.Leer(CommandType.Text, sb.ToString()); if (idr.Read()) { exist = true; } return(exist); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw; } finally { if (idr != null) { idr.Close(); } con.CerrarConexion(); } }