// bts - The Bug Tracking System
// Copyright (C) 2004 - Eugene Konkov
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using System.Text;
using System.Globalization;
namespace ekon.bts.BackEnd{
/// <summary>
/// Background class for MS Access DB
/// </summary>
public class AccessDB : IBugTrackDB
{
private string theConnectionString;
/// <summary>
/// Construct object and establish connection to db
/// </summary>
/// <param name="ConnectionString">Full UDL filename for database</param>
public AccessDB(string ConnectionString)
{
theConnectionString=ConnectionString;
}
#region IBugTrackDB
public ArrayList GetLogins()
{
ArrayList logins=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblPerson.Login FROM tblPerson ORDER BY tblPerson.Login;";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
logins.Add(dr["Login"].ToString());
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return logins;
}
public bool IsValidPassword(string login, string password)
{
// DONE: Add AccessDB.IsValidPassword implementation
bool result=false;
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblPerson.Password, tblPerson.Login FROM tblPerson WHERE (((tblPerson.Login)='"+login+"'));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
if (dr["Password"].ToString()==password)
{
result=true;
}
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return result;
}
public UserInfo GetUserInfo(string login, string password)
{
bool isvalidpassword=false;
isvalidpassword=IsValidPassword(login,password);
if (isvalidpassword==false)
{
throw new InvalidPasswordException();
}
UserInfo userInfo=new UserInfo();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblPerson.ID, tblPerson.isAdmin, tblPerson.isTester, tblPerson.isDeveloper, tblPerson.FullName, tblPerson.Login, tblPerson.Password, tblPerson.Memo FROM tblPerson WHERE (((tblPerson.Login)='"+login+"') AND ((tblPerson.Password)='"+password+"'));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
userInfo.ID=(System.Int32)dr["ID"];
userInfo.IsAdmin=(bool)dr["isAdmin"];
userInfo.IsTester=(bool)dr["isTester"];
userInfo.IsDeveloper=(bool)dr["isDeveloper"];
userInfo.Login=(string)dr["Login"];
userInfo.FullName=(string)dr["FullName"];
userInfo.Memo=(string)dr["Memo"];
//userInfo.Password="***";// ;-)
userInfo.Password=(string)dr["Password"];
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return userInfo;
}
public ArrayList GetProjects()
{
ArrayList arrProjects=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblProject.ID, tblProject.Title, tblProject.Description FROM tblProject ORDER BY tblProject.Title;";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
ProjectInfo projinfo=new ProjectInfo();
projinfo.ID=(System.Int32)dr["ID"];
projinfo.Title=(string)dr["Title"];
projinfo.Description=(string)dr["Description"];
arrProjects.Add(projinfo);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrProjects;
}
public ArrayList GetUsers()
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
ArrayList arrUsers=new ArrayList();
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
UserInfo userInfo=new UserInfo();
//*SQL
comm.CommandText="SELECT tblPerson.ID, tblPerson.isAdmin, tblPerson.isTester, tblPerson.isDeveloper, tblPerson.FullName, tblPerson.Login, tblPerson.Password, tblPerson.Memo FROM tblPerson ORDER BY tblPerson.Login;";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
userInfo.ID=(System.Int32)dr["ID"];
userInfo.IsAdmin=(bool)dr["isAdmin"];
userInfo.IsTester=(bool)dr["isTester"];
userInfo.IsDeveloper=(bool)dr["isDeveloper"];
userInfo.Login=(string)dr["Login"];
userInfo.FullName=(string)dr["FullName"];
userInfo.Memo=(string)dr["Memo"];
//userInfo.Password="***";// ;-)
userInfo.Password=(string)dr["Password"];
arrUsers.Add(userInfo);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrUsers;
}
public ArrayList GetAssignedUsers(ProjectInfo project)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
ArrayList arrUsers=new ArrayList();
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
UserInfo userInfo=new UserInfo();
//*SQL
comm.CommandText="SELECT tblProject.ID, tblPerson.ID, tblPerson.isAdmin, tblPerson.isTester, tblPerson.isDeveloper, tblPerson.FullName, tblPerson.Login, tblPerson.Password, tblPerson.Memo FROM tblProject INNER JOIN (tblPerson INNER JOIN tblXPersonProject ON tblPerson.ID = tblXPersonProject.PersonID) ON tblProject.ID = tblXPersonProject.ProjectID WHERE (((tblProject.ID)="+project.ID.ToString()+"))";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
userInfo.ID=(System.Int32)dr["tblPerson.ID"];
userInfo.IsAdmin=(bool)dr["isAdmin"];
userInfo.IsTester=(bool)dr["isTester"];
userInfo.IsDeveloper=(bool)dr["isDeveloper"];
userInfo.Login=(string)dr["Login"];
userInfo.FullName=(string)dr["FullName"];
userInfo.Memo=(string)dr["Memo"];
//userInfo.Password="***";// ;-)
userInfo.Password=(string)dr["Password"];
arrUsers.Add(userInfo);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrUsers;
}
public void AddProject(ProjectInfo project)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="INSERT INTO tblProject (Title, Description) VALUES ('"+project.Title+"','"+project.Description+"')";
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public void AddUser(UserInfo user)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
System.Object[] args=new object[7];
if(user.IsAdmin)
{
args[0]=1;
}
else
{
args[0]=0;
}
if(user.IsTester)
{
args[1]=1;
}
else
{
args[1]=0;
}
if(user.IsDeveloper)
{
args[2]=1;
}
else
{
args[2]=0;
}
args[3]=user.FullName;
args[4]=user.Login;
args[5]=user.Password;
args[6]=user.Memo;
StringBuilder sbcomm=new StringBuilder();
sbcomm.AppendFormat("INSERT INTO tblPerson (isAdmin, isTester, isDeveloper, FullName, Login, [Password], [Memo]) VALUES ({0}, {1}, {2}, '{3}', '{4}', '{5}', '{6}');",args);
comm.CommandText=sbcomm.ToString();
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public void UpdateProject(ProjectInfo project)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
System.Object[] args=new object[3];
args[0]=project.Title;
args[1]=project.Description;
args[2]=project.ID;
StringBuilder sbcomm=new StringBuilder();
//*SQL
sbcomm.AppendFormat("UPDATE tblProject SET tblProject.Title = '{0}', tblProject.Description = '{1}' WHERE (((tblProject.ID)={2}));",args);
comm.CommandText=sbcomm.ToString();
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public void UpdateUser(UserInfo user)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
System.Object[] args=new object[8];
if(user.IsAdmin)
{
args[0]=1;
}
else
{
args[0]=0;
}
if(user.IsTester)
{
args[1]=1;
}
else
{
args[1]=0;
}
if(user.IsDeveloper)
{
args[2]=1;
}
else
{
args[2]=0;
}
args[3]=user.FullName;
args[4]=user.Login;
args[5]=user.Password;
args[6]=user.Memo;
args[7]=user.ID;
StringBuilder sbcomm=new StringBuilder();
//*SQL
sbcomm.AppendFormat("UPDATE tblPerson SET tblPerson.isAdmin = {0}, tblPerson.isTester = {1}, tblPerson.isDeveloper = {2}, tblPerson.FullName = '{3}', tblPerson.Login = '{4}', tblPerson.Password = '{5}', tblPerson.Memo = '{6}' WHERE (((tblPerson.ID)={7}));",args);
comm.CommandText=sbcomm.ToString();
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public void UpdateXUserProject(ProjectInfo project, ArrayList users)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="DELETE * FROM tblXPersonProject WHERE ProjectID="+project.ID.ToString();
comm.ExecuteNonQuery();
foreach(UserInfo uinf in users)
{
//*SQL
comm.CommandText="INSERT INTO tblXPersonProject ( PersonID,ProjectID) VALUES ( "+uinf.ID.ToString()+","+project.ID.ToString()+")";
comm.ExecuteNonQuery();
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public ArrayList GetAllBugs(ProjectInfo project)
{
ArrayList arrBugs=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT ID, Date, PersonID, ProjectID, Priority FROM tblBug WHERE (((ProjectID)="+project.ID.ToString()+")) ORDER BY Date;";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
Bug curr_bug=new Bug();
curr_bug.ID=(System.Int32)dr["ID"];
curr_bug.Date=(System.DateTime)dr["Date"];
curr_bug.PersonID=(System.Int32)dr["PersonID"];
curr_bug.Priority=(System.Int16)dr["Priority"];
curr_bug.ProjectID=(System.Int32)dr["ProjectID"];
arrBugs.Add(curr_bug);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrBugs;
}
public ArrayList GetAllBugs(ProjectInfo project, UserInfo user)
{
ArrayList arrBugs=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT ID, Date, PersonID, ProjectID, Priority FROM tblBug WHERE (((ProjectID)="+project.ID.ToString()+") AND ((PersonID)="+user.ID.ToString()+")) ORDER BY Date;";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
Bug curr_bug=new Bug();
curr_bug.ID=(System.Int32)dr["ID"];
curr_bug.Date=(System.DateTime)dr["Date"];
curr_bug.PersonID=(System.Int32)dr["PersonID"];
curr_bug.Priority=(System.Int16)dr["Priority"];
curr_bug.ProjectID=(System.Int32)dr["ProjectID"];
arrBugs.Add(curr_bug);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrBugs;
}
public ArrayList GetAllIssues(Bug givenbug)
{
ArrayList issues=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT ID, Date, PersonID, Message, BugID, StatusID FROM tblIssue WHERE (((BugID)="+givenbug.ID.ToString()+"));";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
Issue curr_issue=new Issue();
curr_issue.ID=(System.Int32)dr["ID"];
curr_issue.Date=(System.DateTime)dr["Date"];
curr_issue.PersonID=(System.Int32)dr["PersonID"];
curr_issue.Message=dr["Message"].ToString();
curr_issue.BugID=(System.Int32)dr["BugID"];
curr_issue.StatusID=(System.Int32)dr["StatusID"];
curr_issue.StatusTitle=this.GetStatus(curr_issue).ToString();
curr_issue.FromLogin=this.GetUserInfo(curr_issue.PersonID).Login;
issues.Add(curr_issue);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return issues;
}
public ArrayList GetPossibleStatuses(UserInfo user, ProjectInfo project, Status previous)
{
ArrayList possible_statuses=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT PersonID, ProjectID FROM tblXPersonProject WHERE (((PersonID)="+user.ID+") AND ((ProjectID)="+project.ID+"));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
dr.Close();
// Warning!! This code depends on tblStatus content
Status statusFixed=new Status();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)=2));";
dr=comm.ExecuteReader();
dr.Read();
statusFixed.ID=(System.Int32)dr["ID"];
statusFixed.Title=dr["Title"].ToString();
statusFixed.Description=dr["Description"].ToString();
dr.Close();
Status statusAdded=new Status();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)=1));";
dr=comm.ExecuteReader();
dr.Read();
statusAdded.ID=(System.Int32)dr["ID"];
statusAdded.Title=dr["Title"].ToString();
statusAdded.Description=dr["Description"].ToString();
dr.Close();
Status statusFeauture=new Status();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)=5));";
dr=comm.ExecuteReader();
dr.Read();
statusFeauture.ID=(System.Int32)dr["ID"];
statusFeauture.Title=dr["Title"].ToString();
statusFeauture.Description=dr["Description"].ToString();
dr.Close();
Status statusClosed=new Status();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)=4));";
dr=comm.ExecuteReader();
dr.Read();
statusClosed.ID=(System.Int32)dr["ID"];
statusClosed.Title=dr["Title"].ToString();
statusClosed.Description=dr["Description"].ToString();
dr.Close();
Status statusReviewed=new Status();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)=3));";
dr=comm.ExecuteReader();
dr.Read();
statusReviewed.ID=(System.Int32)dr["ID"];
statusReviewed.Title=dr["Title"].ToString();
statusReviewed.Description=dr["Description"].ToString();
dr.Close();
if (user.IsDeveloper)
{
if (previous != null)
{
possible_statuses.Add(previous);
if(previous.ID==1 | previous.ID==3)
{
possible_statuses.Add(statusFixed);
}
}
}
if (user.IsTester)
{
if(previous==null)
{
possible_statuses.Add(statusAdded);
}
if (previous!=null)
{
possible_statuses.Add(previous);
if (previous.ID==1 | previous.ID==2)
{
possible_statuses.Add(statusFeauture);
}
if (previous.ID==2)
{
possible_statuses.Add(statusClosed);
possible_statuses.Add(statusReviewed);
}
}
}
}
else
{
dr.Close();
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return possible_statuses;
}
public void AddBug(Bug new_bug, Issue initial_issue)
{
// TODO: Add AccessDB.AddBug implementation
//INSERT INTO tblPerson ( isAdmin, isTester, isDeveloper, FullName, Login, [Password], [Memo] )
//VALUES (0, 1, 1, 'Bill Mulder', 'bm', 'bm', 'dev and test');
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
System.Object[] args=new object[4];
args[0]=new_bug.Date.ToString("dd.MM.yyyy",DateTimeFormatInfo.InvariantInfo)+" "+new_bug.Date.ToString("T",DateTimeFormatInfo.InvariantInfo);
args[1]=new_bug.PersonID;
args[2]=new_bug.ProjectID;
args[3]=new_bug.Priority;
StringBuilder sbComm=new StringBuilder();
sbComm.AppendFormat("INSERT INTO tblBug ([Date], PersonID, ProjectID, Priority) VALUES ('{0}', {1}, {2}, {3});",args);
comm.CommandText=sbComm.ToString();
comm.ExecuteNonQuery();
//now SELECT by Date to get BugID.
//Date is unique column in tblBugs. Format: "dd.mm.yyyy hh:mm:ss"
StringBuilder sbCommSel=new StringBuilder();
sbCommSel.AppendFormat("SELECT ID FROM tblBug WHERE (Date=#{0}#);",new_bug.Date.ToString("G",DateTimeFormatInfo.InvariantInfo)/*,new_bug.Date.ToString("T",DateTimeFormatInfo.InvariantInfo)*/);
comm.CommandText=sbCommSel.ToString();
OleDbDataReader rd=comm.ExecuteReader();
// We must get just added record!!
rd.Read();
Bug added=new Bug();
added.Date=new_bug.Date;
added.PersonID=new_bug.PersonID;
added.Priority=new_bug.Priority;
added.ProjectID=new_bug.ProjectID;
added.ID=(System.Int32)rd["ID"];
AddIssue(added, initial_issue);
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public void AddIssue(Bug exist_bug, Issue new_issue)
{
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
System.Object[] args=new object[5];
args[0]=new_issue.Date.ToString("dd.MM.yyyy",DateTimeFormatInfo.InvariantInfo)+" "+new_issue.Date.ToString("T",DateTimeFormatInfo.InvariantInfo);
args[1]=new_issue.PersonID;
args[2]=new_issue.Message;
args[3]=exist_bug.ID;
args[4]=new_issue.StatusID;
StringBuilder sbComm=new StringBuilder();
sbComm.AppendFormat("INSERT INTO tblIssue ([Date], PersonID, Message, BugID, StatusID) VALUES ('{0}', {1}, '{2}', {3}, {4});",args);
comm.CommandText=sbComm.ToString();
comm.ExecuteNonQuery();
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
}
public Status GetStatus(Issue anIssue)
{
Status result=new Status();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT ID, Title, Description FROM tblStatus WHERE (((tblStatus.ID)="+anIssue.StatusID+"));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
result.ID=(System.Int32)dr["ID"];
result.Title=dr["Title"].ToString();
result.Description=dr["Description"].ToString();
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return result;
}
public ArrayList GetProjects(UserInfo user)
{
ArrayList arrProjects=new ArrayList();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblProject.ID, tblProject.Title, tblProject.Description FROM tblProject INNER JOIN (tblPerson INNER JOIN tblXPersonProject ON tblPerson.ID = tblXPersonProject.PersonID) ON tblProject.ID = tblXPersonProject.ProjectID WHERE (((tblPerson.ID)="+user.ID.ToString()+"));";
OleDbDataReader dr=comm.ExecuteReader();
while (dr.Read())
{
ProjectInfo projinfo=new ProjectInfo();
projinfo.ID=(System.Int32)dr["ID"];
projinfo.Title=(string)dr["Title"];
projinfo.Description=(string)dr["Description"];
arrProjects.Add(projinfo);
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return arrProjects;
}
public UserInfo GetUserInfo(string login)
{
UserInfo userInfo=new UserInfo();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblPerson.ID, tblPerson.isAdmin, tblPerson.isTester, tblPerson.isDeveloper, tblPerson.FullName, tblPerson.Login, tblPerson.Memo FROM tblPerson WHERE (((tblPerson.Login)='"+login+"'));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
userInfo.ID=(System.Int32)dr["ID"];
userInfo.IsAdmin=(bool)dr["isAdmin"];
userInfo.IsTester=(bool)dr["isTester"];
userInfo.IsDeveloper=(bool)dr["isDeveloper"];
userInfo.Login=(string)dr["Login"];
userInfo.FullName=(string)dr["FullName"];
userInfo.Memo=(string)dr["Memo"];
//userInfo.Password="***";// ;-)
//userInfo.Password=(string)dr["Password"];
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return userInfo;
}
public UserInfo GetUserInfo(Int32 UserID)
{
UserInfo userInfo=new UserInfo();
OleDbConnection conn=new OleDbConnection(theConnectionString);
try
{
conn.Open();
OleDbCommand comm=conn.CreateCommand();
//*SQL
comm.CommandText="SELECT tblPerson.ID, tblPerson.isAdmin, tblPerson.isTester, tblPerson.isDeveloper, tblPerson.FullName, tblPerson.Login, tblPerson.Memo FROM tblPerson WHERE (((tblPerson.ID)="+UserID.ToString()+"));";
OleDbDataReader dr=comm.ExecuteReader();
if (dr.Read())
{
userInfo.ID=(System.Int32)dr["ID"];
userInfo.IsAdmin=(bool)dr["isAdmin"];
userInfo.IsTester=(bool)dr["isTester"];
userInfo.IsDeveloper=(bool)dr["isDeveloper"];
userInfo.Login=(string)dr["Login"];
userInfo.FullName=(string)dr["FullName"];
userInfo.Memo=(string)dr["Memo"];
//userInfo.Password="***";// ;-)
//userInfo.Password=(string)dr["Password"];
}
}
catch(Exception ex)
{
//TODO process exception
System.Windows.Forms.MessageBox.Show(ex.Message,ex.GetType().ToString());
}
finally
{
conn.Close();
}
return userInfo;
}
#endregion
}
}
|