本文整理汇总了C#中Scheduler.BusinessLayer.Connection类的典型用法代码示例。如果您正苦于以下问题:C# Connection类的具体用法?C# Connection怎么用?C# Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于Scheduler.BusinessLayer命名空间,在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalendarExists
public bool CalendarExists()
{
string strSql = "";
SqlCommand com = null;
Connection con = null;
try {
strSql = "Select Count(*) From [CalendarEvent] " +
"WHERE [EventID][email protected] ";
con = new Connection();
con.Connect();
com = new SqlCommand();
com.Connection = con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@EventID", SqlDbType.Int));
com.Parameters["@EventID"].Value = EventID;
object o = com.ExecuteScalar();
if (Convert.ToInt32(o) > 0) {
return true;
}
return false;
} catch (SqlException ex) {
Message = ex.Message;
return false;
} finally {
if (com != null) {
com.Dispose();
com = null;
con.DisConnect();
}
}
}
示例2: UpdateData
public bool UpdateData()
{
string sql="";
SqlCommand com=null;
Connection con=null;
try
{
sql = "Update [Contact] Set ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "FirstNamePhone[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected], ";
sql += "[email protected] ";
sql += "WHERE [email protected] ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = sql;
com.Parameters.Add(new SqlParameter("@ContactID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@LastNamePhonetic", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@LastNameRomaji", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@FirstNamePhonetic", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@FirstNameRomaji", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@NickName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@CompanyName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@CompanyNamePhonetic", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@CompanyNameRomaji", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@TitleForName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@TitleForJob", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Street1", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Street2", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Street3", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@City", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@State", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@PostalCode", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Country", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@ContactType", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@BlockCode", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Email1", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Email2", SqlDbType.NVarChar));
//.........这里部分代码省略.........
示例3: getOccurrenceCount
public string getOccurrenceCount(int eventid)
{
SqlCommand com = null;
Connection con = null;
//SqlDataReader Reader = null;
string strSQL = string.Empty;
string strResult = string.Empty;
int result1;
int result2;
try
{
strSQL = "Select Count(*) from [CalendarEvent] WHERE [email protected] AND StartDateTime < GetDate() AND CalendarEventStatus = 0;";
con = new Connection();
con.Connect();
com = new SqlCommand(strSQL, con.SQLCon);
com.Parameters.Add(new SqlParameter("@EventId", SqlDbType.Int));
com.Parameters["@EventId"].Value = eventid;
result1 = (int)com.ExecuteScalar();
//strSQL = "Select Count(*) from [CalendarEvent] WHERE [email protected] AND EndDateTime >= GetDate() AND CalendarEventStatus = 0;";
strSQL = "Select Count(*) from [CalendarEvent] WHERE [email protected] AND CalendarEventStatus = 0;";
com.CommandText = strSQL;
//com.Parameters["@EventId"].Value = eventid;
result2 = (int)com.ExecuteScalar();
//strResult = result1.ToString() + " / " + (result1 + result2).ToString();
strResult = result1.ToString() + " / " + (result2).ToString();
return strResult;
}
catch (SqlException ex)
{
Message = ex.Message;
return "Error!";
}
finally
{
if (com != null)
{
com.Dispose();
com = null;
con.DisConnect();
}
}
}
示例4: getEventText
public string getEventText(int eventid, ref string startdate, ref string enddate)
{
string Result="";
string strSql="";
SqlCommand com=null;
Connection con=null;
SqlDataReader Reader=null;
DateTime dtStart=Convert.ToDateTime(null);
DateTime dtEnd=Convert.ToDateTime(null);
try
{
strSql = "Select StartDateTime, EndDateTime From [CalendarEvent] ";
strSql += "WHERE [email protected]";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@EventID", SqlDbType.BigInt));
com.Parameters["@EventID"].Value = eventid;
Reader=com.ExecuteReader();
bool IsRecord=false;
if(Reader.Read())
{
IsRecord=true;
if(Reader["StartDateTime"]!=System.DBNull.Value)
{
dtStart = Convert.ToDateTime(Reader["StartDateTime"].ToString());
}
if(Reader["EndDateTime"]!=System.DBNull.Value)
{
dtEnd = Convert.ToDateTime(Reader["EndDateTime"].ToString());
}
}
Reader.Close();
if(IsRecord)
{
if(dtStart!=Convert.ToDateTime(null))
{
Result = dtStart.ToShortDateString() + " " + dtStart.ToShortTimeString();
if(Result.IndexOf("(")>0)
{
Result = Result.Substring(0, Result.IndexOf("(")+1);
}
startdate = Result;
}
if(dtEnd!=Convert.ToDateTime(null))
{
Result = dtEnd.ToShortDateString() + " " + dtEnd.ToShortTimeString();
if(Result.IndexOf("(")>0)
{
Result = Result.Substring(0, Result.IndexOf("(")+1);
}
enddate = Result;
}
}
else Result="None";
return Result;
}
catch(SqlException ex)
{
Message=ex.Message;
return "";
}
finally
{
if(com!=null)
{
com.Dispose();
com=null;
con.DisConnect();
}
}
}
示例5: Exists
public bool Exists()
{
string strSql="";
SqlCommand com=null;
Connection con=null;
try
{
strSql = "Select Count(*) From [Course] " +
"WHERE [Name][email protected] and [email protected] and CourseId<>" + _courseid + " ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar));
com.Parameters["@Name"].Value = _name;
com.Parameters.Add(new SqlParameter("@ProgramID", SqlDbType.Int));
com.Parameters["@ProgramID"].Value = _programid;
object o = com.ExecuteScalar();
if(Convert.ToInt32(o)>0)
{
return true;
}
return false;
}
catch(SqlException ex)
{
Message=ex.Message;
return false;
}
finally
{
if(com!=null)
{
com.Dispose();
com=null;
con.DisConnect();
}
}
}
示例6: CheckTestEvents
/// <summary>
/// Checks whether Test Initial, Mid or Final are set for a Class or not.
/// </summary>
/// <returns>A boolean array with Test Event Ids or 0 if no events exist.</returns>
public bool[] CheckTestEvents()
{
string strSql = "";
SqlDataReader Reader = null;
SqlCommand com = null;
Connection con = null;
try
{
strSql = "Select TestInitialEventId,TestMidtermEventId,TestFinalEventId from [Course] WHERE [email protected];";
con = new Connection();
con.Connect();
com = new SqlCommand(strSql, con.SQLCon);
com.Parameters.Add(new SqlParameter("@CourseId", SqlDbType.Int));
com.Parameters["@CourseId"].Value = _courseid;
Reader = com.ExecuteReader();
string[] temp = new string[3];
bool[] boolArray = { false, false, false };
Reader.Read();
temp[0] = Reader[0].ToString();
temp[1] = Reader[1].ToString();
temp[2] = Reader[2].ToString();
Reader.Close();
IDataReader readerTemp = null;
if (temp[0] != null && temp[0] != "" && temp[0] != "0")
{
readerTemp = DAC.SelectStatement("Select * From Event Where EventID = " + temp[0]);
if (readerTemp.Read())
{
boolArray[0] = true;
}
else
{
DAC.EXQuery("Update [Course] Set TestInitialEventId = 0 Where CourseId = " + _courseid);
boolArray[0] = false;
}
}
if (temp[1] != null && temp[1] != "" && temp[1] != "0")
{
readerTemp = DAC.SelectStatement("Select * From Event Where EventID = " + temp[1]);
if (readerTemp.Read())
{
boolArray[1] = true;
}
else
{
DAC.EXQuery("Update [Course] Set TestMidtermEventId = 0 Where CourseId = " + _courseid);
boolArray[1] = false;
}
}
if (temp[2] != null && temp[2] != "" && temp[2] != "0")
{
readerTemp = DAC.SelectStatement("Select * From Event Where EventID = " + temp[2]);
if (readerTemp.Read())
{
boolArray[2] = true;
}
else
{
DAC.EXQuery("Update [Course] Set TestFinalEventId = 0 Where CourseId = " + _courseid);
boolArray[2] = false;
}
}
return boolArray;
}
catch (SqlException ex)
{
Message = ex.Message;
return null;
}
finally
{
if (com != null)
{
com.Dispose();
com = null;
con.DisConnect();
}
}
}
示例7: UpdateData
public bool UpdateData()
{
string strSql="";
SqlCommand com=null;
Connection con=null;
try
{
strSql = "Update [Course] Set " +
"[email protected], " +
"NamePhonetic[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected], " +
"[email protected] " +
"WHERE [email protected] ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@CourseId", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@NamePhonetic", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@NameRomaji", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@NickName", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@ProgramID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@EventID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@SpecialRemarks", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@CourseType", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@Curriculam", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@NumberStudents", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@HomeWorkMinutes", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@TestInitialEventID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@TestMidtermEventID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@TestFinalEventID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@TestInitialForm", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@TestMidtermForm", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@TestFinalForm", SqlDbType.NVarChar));
com.Parameters.Add(new SqlParameter("@CourseStatus", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@DateCreated", SqlDbType.DateTime));
com.Parameters.Add(new SqlParameter("@DateLastModified", SqlDbType.DateTime));
com.Parameters.Add(new SqlParameter("@LastModifiedByUserID", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@BreakDuration", SqlDbType.Int));
com.Parameters["@CourseId"].Value = _courseid;
com.Parameters["@Name"].Value = _name;
com.Parameters["@NamePhonetic"].Value = _namephonetic;
com.Parameters["@NameRomaji"].Value = _nameromaji;
com.Parameters["@NickName"].Value = _nickname;
com.Parameters["@ProgramID"].Value = _programid;
com.Parameters["@EventID"].Value = _eventid;
com.Parameters["@Description"].Value = _description;
com.Parameters["@SpecialRemarks"].Value = _specialremarks;
com.Parameters["@CourseType"].Value = _coursetype;
com.Parameters["@Curriculam"].Value = _curriculam;
com.Parameters["@NumberStudents"].Value = _numberstudents;
com.Parameters["@HomeWorkMinutes"].Value = _homeworkminutes;
com.Parameters["@TestInitialEventID"].Value = _testinieventid;
com.Parameters["@TestMidtermEventID"].Value = _testmideventid;
com.Parameters["@TestFinalEventID"].Value = _testfinaleventid;
com.Parameters["@TestInitialForm"].Value = _testiniform;
com.Parameters["@TestMidtermForm"].Value = _testmidform;
com.Parameters["@TestFinalForm"].Value = _testfinalform;
com.Parameters["@CourseStatus"].Value = _coursestatus;
com.Parameters["@DateCreated"].Value = DateTime.Now;
com.Parameters["@DateLastModified"].Value = DateTime.Now;
com.Parameters["@LastModifiedByUserID"].Value = Scheduler.BusinessLayer.Common.LogonID;
com.Parameters["@BreakDuration"].Value = _breakduration;
com.ExecuteNonQuery();
return true;
}
catch(SqlException ex)
{
Message=ex.Message;
return false;
}
finally
{
if(com!=null)
//.........这里部分代码省略.........
示例8: LoadDataN
//ViewClassEventsN
public bool LoadDataN()
{
string strSql = "select * From ViewClassEventsN ";
SqlDataReader Reader = null;
SqlCommand com = null;
Connection con = null;
try
{
/*
if (_courseid <= 0)
{
strSql += " Order By BrowseName ";
}
else
{
strSql += String.Format(" Where C.CourseId= {0} ", _courseid);
}
*/
BuildDataTable();
/*
con = new Connection();
con.Connect();
com = new SqlCommand();
com.Connection = con.SQLCon;
com.CommandText = strSql;
Reader = com.ExecuteReader();
*/
///*
strSql = "SpClassEventsN";
con = new Connection();
con.Connect();
com = new SqlCommand();
com.CommandType = CommandType.StoredProcedure;
com.Connection = con.SQLCon;
com.CommandText = strSql;
Reader = com.ExecuteReader();
//*/
_dtbl.Load(Reader, LoadOption.OverwriteChanges);
return true;
}
catch (SqlException ex)
{
Message = ex.Message;
return false;
}
finally
{
if (!Reader.IsClosed)
{
Reader.Close();
}
if (com != null)
{
com.Dispose();
com = null;
con.DisConnect();
}
}
}
示例9: LoadData
public DataTable LoadData(string option)
{
string strSql="";
int contacttypeid=0;
SqlCommand com=null;
Connection con=null;
SqlDataAdapter adpt=null;
if(option=="User") contacttypeid=0;
if(option=="Instructor") contacttypeid=1;
if(option=="Client") contacttypeid=2;
if(option=="Department") contacttypeid=3;
if(option=="ClientContact") contacttypeid=4;
if(option=="DepartmentContact") contacttypeid=5;
if(_dtbl==null)
{
_dtbl=new DataTable();
}
try
{
if(_contactid<=0)
{
strSql = "select BrowseName = CASE " +
"WHEN NickName IS NULL THEN CompanyName " +
"WHEN NickName = '' THEN CompanyName " +
"ELSE NickName " +
"END, " +
"*, " +
"Type = " +
"CASE ContactType " +
"When '0' Then 'User' " +
"When '1' Then 'Teacher' " +
"When '2' Then 'Client' " +
"When '3' Then 'Department' " +
"END, " +
"Status = " +
"CASE ContactStatus " +
"When '0' Then 'Active' " +
"When '1' Then 'Inactive' " +
"END, " +
"MaritalStatus = " +
"CASE Married " +
"When '0' Then 'Yes' " +
"When '1' Then 'No' " +
"ELSE '' " +
"END,Email1,Email2,Phone1,Phone2,PhoneMobile1,PhoneMobile2,PhoneBusiness1,PhoneBusiness2, CASE When (AccountRepLastName + ', ' + AccountRepFirstName) <> ', ' Then (AccountRepLastName + ', ' + AccountRepFirstName) Else '' End as AccRepName " +
"From Contact ";
if(option!="Contact")
{
strSql += "Where ContactType = " + contacttypeid.ToString() + " ";
if(RefID>0)
{
strSql += "and RefID = " + RefID.ToString() + " ";
}
}
if(option=="Instructor")
{
strSql += "Order By LastName, FirstName ";
}
else if(option=="Client")
{
strSql += "Order By BrowseName ";
}
else if(option=="DepartmentContact")
{
strSql += "Order By LastName, FirstName ";
}
else
{
strSql += "Order By ContactID";
}
}
else
{
strSql = "select BrowseName = CASE " +
"WHEN NickName IS NULL THEN CompanyName " +
"WHEN NickName = '' THEN CompanyName " +
"ELSE NickName " +
"END, " +
"*, " +
"Type = " +
"CASE ContactType " +
"When '0' Then 'User' " +
"When '1' Then 'Teacher' " +
"When '2' Then 'Client' " +
"When '3' Then 'Department' " +
"END, " +
"Status = " +
"CASE ContactStatus " +
"When '0' Then 'Active' " +
"When '1' Then 'Inactive' " +
"END, " +
"MaritalStatus = " +
"CASE Married " +
"When '0' Then 'Yes' " +
"When '1' Then 'No' " +
"ELSE '' " +
"END, CASE When (AccountRepLastName + ', ' + AccountRepFirstName) <> ', ' Then (AccountRepLastName + ', ' + AccountRepFirstName) Else '' End as AccRepName " +
"From Contact " +
//.........这里部分代码省略.........
示例10: InsertData
public bool InsertData()
{
string sql="";
SqlCommand com=null;
Connection con=null;
SqlDataReader Reader=null;
try
{
sql = "Insert into [Contact] (";
sql += "RefID, ";
sql += "LastName, ";
sql += "LastNamePhonetic, ";
sql += "LastNameRomaji, ";
sql += "FirstName, ";
sql += "FirstNamePhonetic, ";
sql += "FirstNameRomaji, ";
sql += "NickName, ";
sql += "CompanyName, ";
sql += "CompanyNamePhonetic, ";
sql += "CompanyNameRomaji, ";
sql += "TitleForName, ";
sql += "TitleForJob, ";
sql += "Street1, ";
sql += "Street2, ";
sql += "Street3, ";
sql += "City, ";
sql += "State, ";
sql += "PostalCode, ";
sql += "Country, ";
sql += "ContactType, ";
sql += "BlockCode, ";
sql += "Email1, ";
sql += "Email2, ";
sql += "AccountRepLastName, ";
sql += "AccountRepLastNamePhonetic, ";
sql += "AccountRepLastNameRomaji, ";
sql += "AccountRepFirstName, ";
sql += "AccountRepFirstNamePhonetic, ";
sql += "AccountRepFirstNameRomaji, ";
sql += "Phone1, ";
sql += "Phone2, ";
sql += "PhoneMobile1, ";
sql += "PhoneMobile2, ";
sql += "PhoneBusiness1, ";
sql += "PhoneBusiness2, ";
sql += "PhoneFax1, ";
sql += "PhoneFax2, ";
sql += "PhoneOther, ";
sql += "Url, ";
sql += "DateBirth, ";
sql += "DateJoined, ";
sql += "DateEnded, ";
sql += "TimeStatus, ";
sql += "Nationality, ";
sql += "Married, ";
sql += "NumberDependents, ";
sql += "VisaStatus, ";
sql += "VisaFromDate, ";
sql += "VisaUntilDate, ";
sql += "ClosestStation1, ";
sql += "ClosestLine1, ";
sql += "MinutesToStation1, ";
sql += "ClosestStation2, ";
sql += "ClosestLine2, ";
sql += "MinutesToStation2, ";
sql += "ContactStatus, ";
sql += "CreatedByUserId, ";
sql += "DateCreated, ";
sql += "DateLastModified, ";
sql += "LastModifiedByUserID, ";
sql += "BasePayField ";
sql += ")";
sql += "Values( ";
sql += "@RefID, ";
sql += "@LastName, ";
sql += "@LastNamePhonetic, ";
sql += "@LastNameRomaji, ";
sql += "@FirstName, ";
sql += "@FirstNamePhonetic, ";
sql += "@FirstNameRomaji, ";
sql += "@NickName, ";
sql += "@CompanyName, ";
sql += "@CompanyNamePhonetic, ";
sql += "@CompanyNameRomaji, ";
sql += "@TitleForName, ";
sql += "@TitleForJob, ";
sql += "@Street1, ";
sql += "@Street2, ";
sql += "@Street3, ";
sql += "@City, ";
sql += "@State, ";
sql += "@PostalCode, ";
sql += "@Country, ";
sql += "@ContactType, ";
sql += "@BlockCode, ";
sql += "@Email1, ";
sql += "@Email2, ";
sql += "@AccountRepLastName, ";
sql += "@AccountRepLastNamePhonetic, ";
//.........这里部分代码省略.........
示例11: Exists
public bool Exists(string strComp, int ClientID, int ContactType)
{
string strSql="";
SqlCommand com=null;
Connection con=null;
try
{
strSql = "Select Count(*) as cnt From [Contact] C, Department D " +
"Where C.ContactID=D.ContactID and " +
"[email protected] and " +
"[email protected] and " +
"[email protected] ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@CompanyName", SqlDbType.NVarChar));
com.Parameters["@CompanyName"].Value = strComp;
com.Parameters.Add(new SqlParameter("@ContactType", SqlDbType.NVarChar));
com.Parameters["@ContactType"].Value = ContactType;
com.Parameters.Add(new SqlParameter("@ClientID", SqlDbType.BigInt));
com.Parameters["@ClientID"].Value = ClientID;
object o = com.ExecuteScalar();
if(Convert.ToInt32(o)>0)
{
return true;
}
return false;
}
catch(SqlException ex)
{
Message=ex.Message;
return false;
}
finally
{
if(com!=null)
{
com.Dispose();
com=null;
con.DisConnect();
}
}
}
示例12: DeleteContactFromProgram
public void DeleteContactFromProgram()
{
string strSql = "";
SqlCommand com = null;
Connection con = null;
try
{
strSql = "Update [Program] SET Contact1ID=0 WHERE [email protected];";
strSql += "Update [Program] SET Contact2ID=0 WHERE [email protected];";
con = new Connection();
con.Connect();
com = new SqlCommand();
com.Connection = con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@ContactID", SqlDbType.Int));
com.Parameters["@ContactID"].Value = _contactid;
com.ExecuteNonQuery();
/*
strSql = "Delete from contact where [email protected] AND ContactType=4";
com.Parameters["@ContactID"].Value = _contactid;
com.CommandText = strSql;
com.ExecuteNonQuery();
*/
return;
}
catch (SqlException ex)
{
Message = ex.Message;
return;
}
finally
{
if (com != null)
{
com.Dispose();
com = null;
con.DisConnect();
}
}
}
示例13: ContactExists
public bool ContactExists(int refid, string fname, string lname)
{
string strSql="";
SqlCommand com=null;
Connection con=null;
try
{
strSql = "Select Count(*) From [Contact] " +
"WHERE [email protected] AND [email protected] AND [email protected] and [email protected] ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = strSql;
com.Parameters.Add(new SqlParameter("@FName", SqlDbType.NVarChar));
com.Parameters["@FName"].Value = fname;
com.Parameters.Add(new SqlParameter("@LName", SqlDbType.NVarChar));
com.Parameters["@LName"].Value = lname;
com.Parameters.Add(new SqlParameter("@ContactType", SqlDbType.NVarChar));
com.Parameters["@ContactType"].Value = ContactType;
com.Parameters.Add(new SqlParameter("@RefID", SqlDbType.Int));
com.Parameters["@RefID"].Value = refid;
object o = com.ExecuteScalar();
if(Convert.ToInt32(o)>0)
{
return true;
}
return false;
}
catch(SqlException ex)
{
Message=ex.Message;
return false;
}
finally
{
if(com!=null)
{
com.Dispose();
com=null;
con.DisConnect();
}
}
}
示例14: UpdateRefID
public bool UpdateRefID(int randomno)
{
string sql="";
SqlCommand com=null;
Connection con=null;
try
{
sql = "Update [Contact] Set RefID=" + RefID.ToString() + " Where RefID=" + randomno.ToString() + " ";
con=new Connection();
con.Connect();
com = new SqlCommand();
com.Connection=con.SQLCon;
com.CommandText = sql;
com.ExecuteNonQuery();
return true;
}
catch(SqlException ex)
{
Message=ex.Message;
return false;
}
finally
{
if(com!=null)
{
com.Dispose();
com=null;
con.DisConnect();
}
}
}
示例15: IsRecurring
/// <summary>
/// Determines whether the class is a single event or a series of repeating events.
/// </summary>
/// <returns>A boolean indicating if a class repeats or not.</returns>
public bool IsRecurring()
{
string strSql = "";
SqlCommand com = null;
Connection con = null;
try
{
strSql = "Select Count(*) from [Event] WHERE RecurrenceText IS NOT NULL AND RecurrenceText<>'' AND EventId=" + _eventid + ";";
con = new Connection();
con.Connect();
com = new SqlCommand(strSql, con.SQLCon);
int result = (int)com.ExecuteScalar();
//Means the class reocurrs alright
if (result == 1)
return true;
else
return false;
}
catch (SqlException ex)
{
Message = ex.Message;
return false;
}
finally
{
if (com != null)
{
com.Dispose();
com = null;
con.DisConnect();
}
}
}