public bool Agregar() { string strSQL = "INSERT INTO " + this.m_TableName + " VALUES(null, " + this.m_IdUsuario + ", " + "'" + this.m_Titulo + "', '" + this.m_Autores + "', " + System.Convert.ToByte(this.m_Tipo) + ", " + System.Convert.ToByte(this.m_Soporte) + ", '" + clsUtiles.getStringMySqlFormatedDate(System.DateTime.Now) + "');"; clsDAL oDAL = new clsDAL(); oDAL.BeginTrans(); bool boResult = System.Convert.ToBoolean(oDAL.ExecCommand(strSQL)); this.m_Id = System.Convert.ToUInt32(oDAL.getLastIDENTITY(this.m_TableName)); // Para agregar los temas a los que pertenece la bibliografía. clsTema Tema = new clsTema(); System.Byte bytCantTemas = Tema.getCantidad(); Tema = null; if ((this.m_Temas.Length > 0) & (this.m_Temas.Length < bytCantTemas)) // Cuando se declaran explícitamente los temas ó cuando se han seleccionado todos. { for (int i = 0; i <= (this.m_Temas.Length - 1); i++) { strSQL = "INSERT INTO " + this.m_TableTemas + " VALUES(null, " + this.m_Id + ", " + System.Convert.ToByte(this.m_Temas[i].IdTema) + ");"; oDAL.ExecCommand(strSQL); } } else // Para cuando no se declaran explícitamente los temas y se desea que pertenezca a todos, se inserta un cero (0). { strSQL = "INSERT INTO " + this.m_TableTemas + " VALUES(null, " + this.m_Id + ", 0);"; } oDAL.CommitTrans(); oDAL = null; return(boResult); }
public bool Actualizar() { if (this.m_Id == 0) { return(false); } string strSQL = "UPDATE " + this.m_TableName + " SET Titulo='" + this.m_Titulo + "', " + "Autores='" + this.m_Autores + "', Tipo=" + System.Convert.ToByte(this.m_Tipo) + " WHERE Id=" + this.m_Id + ";"; clsDAL oDAL = new clsDAL(); oDAL.BeginTrans(); bool boResult = System.Convert.ToBoolean(oDAL.ExecCommand(strSQL)); // PARA AGREGAR LOS TEMAS A LOS QUE PERTENECE LA BIBLIOGRAFÍA. // 1. Eliminar todos los temas a los que pertenece la bibliografía. strSQL = "DELETE FROM " + this.m_TableTemas + " WHERE Id_Bibliografia=" + this.m_Id + ";"; oDAL.ExecCommand(strSQL); // 2. Proceso para insertar nuevamente, pero sólo los valores que se proporcionan. clsTema Tema = new clsTema(); System.Byte bytCantTemas = Tema.getCantidad(); Tema = null; if ((this.m_Temas.Length > 0) & (this.m_Temas.Length < bytCantTemas)) // Cuando se declaran explícitamente los temas ó cuando se han seleccionado todos. { for (int i = 0; i <= (this.m_Temas.Length - 1); i++) { strSQL = "INSERT INTO " + this.m_TableTemas + " VALUES(null, " + this.m_Id + ", " + System.Convert.ToByte(this.m_Temas[i].IdTema) + ");"; oDAL.ExecCommand(strSQL); } } else // Para cuando no se declaran explícitamente los temas y se desea que pertenezca a todos, se inserta un cero (0). { strSQL = "INSERT INTO " + this.m_TableTemas + " VALUES(null, " + this.m_Id + ", 0);"; } oDAL.CommitTrans(); oDAL = null; return(boResult); }