public int Update(Person t) { string query = @"UPDATE Person SET names= :names, lastName= :lastName, secondLastName= :secondLastName, address= :address, phone= :phone, email= :email, photo= :photo, updateDate=CURRENT_TIMESTAMP WHERE Personid= :PersonId"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[8]; parameters1[0] = new OracleParameter(":PersonId", t.PersonId); parameters1[0] = new OracleParameter(":names", t.Names); parameters1[0] = new OracleParameter(":lastName", t.LastName); parameters1[0] = new OracleParameter(":secondLastName", t.SecondLastName); parameters1[0] = new OracleParameter(":phone", t.Address); parameters1[0] = new OracleParameter(":email", t.Phone); parameters1[0] = new OracleParameter(":class", t.Email); if (t.Pathrevision == t.PathImage) { parameters1[0] = new OracleParameter(":photo", t.Photo); } else { if (int.Parse(t.Photo)==0) { parameters1[0] = new OracleParameter(":photo", t.PersonId); File.Copy(t.PathImage, DBImplementation.pathImages + t.PersonId + ".png"); } else { System.GC.Collect(); System.GC.WaitForPendingFinalizers(); parameters1[0] = new OracleParameter(":photo", t.PersonId); File.Delete(DBImplementation.pathImages + t.PersonId + ".png"); File.Copy(t.PathImage, DBImplementation.pathImages + t.PersonId + ".png"); } } cmd.Parameters.AddRange(parameters1); return DBImplementation.ExecuteBasicCommand(cmd); } catch (Exception ex) { throw ex; } }
//Disabled public int Disabled(Teacher t) { string query = @"UPDATE Person SET status=0 WHERE Personid= :PersonId"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[1]; parameters1[0] = new OracleParameter(":PersonId", t.PersonId); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//Delete public int Delete(Horario t) { string query = @"UPDATE timetable SET status=0 Where timeTableid= :idHorario"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[1]; parameters1[0] = new OracleParameter(":idHorario", t.idHorario); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//Update public int Update(Teacher t) { string query = @"UPDATE Person SET names= :names, lastName= :lastName, secondLastName= :secondLastName, addres= :address, phone= :phone, email= :email,latitude= :latitude, longitude= :longitude, TownId= :town, photo= :photo, updateDate=CURRENT_TIMESTAMP WHERE Personid= :PersonId"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[11]; parameters1[0] = new OracleParameter(":PersonId", t.PersonId); parameters1[1] = new OracleParameter(":names", t.Names); parameters1[2] = new OracleParameter(":lastName", t.LastName); parameters1[3] = new OracleParameter(":secondLastName", t.SecondLastName); parameters1[4] = new OracleParameter(":address", t.Address); parameters1[5] = new OracleParameter(":phone", t.Phone); parameters1[6] = new OracleParameter(":email", t.Email); parameters1[7] = new OracleParameter(":latitude", t.Latitude); parameters1[8] = new OracleParameter(":userName", t.Longitude); parameters1[9] = new OracleParameter(":town", t.TownId); if (t.Pathrevision == t.PathImage) { parameters1[10] = new OracleParameter(":photo", t.PersonId); } else { parameters1[10] = new OracleParameter(":photo", t.PersonId); File.Delete(t.Pathrevision); File.Copy(t.PathImage, DBImplementation.pathImages + t.PersonId + ".png"); } cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//Insert public int Insert(Horario t) { string query = @"INSERT INTO timetable (hourStart, hourFinish, day) VALUES( :horaIn, :horaFin, :Day)"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[1]; parameters1[0] = new OracleParameter(":horaIn", t.HoraInicio); parameters1[1] = new OracleParameter(":horaFin", t.HoraFin); parameters1[2] = new OracleParameter(":Day", t.Day); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//UPDATE password public int Updatepass(User t) { string query = @"UPDATE USERACCOUNT SET PASSWORD=standard_hash(:password, 'MD5'), REVISIONPASS=1, UPDATEDATE=CURRENT_TIMESTAMP WHERE USERID=:Userid"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[2]; parameters1[0] = new OracleParameter(":password", t.Password); parameters1[1] = new OracleParameter(":Userid", t.UserID); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//Update public int Update(Horario t) { string query = @"UPDATE timetable SET hourStart= :horaIn, hourFinish= :horaFin, updateDate=CURRENT_TIMESTAMP, day= :Day WHERE timeTableid= :idHorario"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[4]; parameters1[0] = new OracleParameter(":horaIn", t.HoraInicio); parameters1[1] = new OracleParameter(":horaFin", t.HoraFin); parameters1[2] = new OracleParameter(":Day", t.Day); parameters1[3] = new OracleParameter(":idHorario", t.idHorario); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }
//Insert public int Insert(User t) { string query = @"INSERT INTO Users (userName, password, role,Personid) VALUES( :userName,standard_hash(:password, 'MD5'), :role, :PersonId)"; try { OracleCommand cmd = DBImplementation.CreateBasicCommand(query); OracleParameter[] parameters1 = new OracleParameter[4]; parameters1[0] = new OracleParameter(":userName", t.UserName); parameters1[1] = new OracleParameter(":password", t.UserName); parameters1[2] = new OracleParameter(":role", t.Role); parameters1[3] = new OracleParameter(":PersonIdsword", t.PersonId); cmd.Parameters.AddRange(parameters1); return(DBImplementation.ExecuteBasicCommand(cmd)); } catch (Exception ex) { throw ex; } }