当前位置: 首页>>代码示例>>C#>>正文


C# Connection.DisConnect方法代码示例

本文整理汇总了C#中Scheduler.BusinessLayer.Connection.DisConnect方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.DisConnect方法的具体用法?C# Connection.DisConnect怎么用?C# Connection.DisConnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scheduler.BusinessLayer.Connection的用法示例。


在下文中一共展示了Connection.DisConnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetData


//.........这里部分代码省略.........
                con.Connect();
                com = new SqlCommand();
                com.CommandType = CommandType.StoredProcedure;
                com.Connection = con.SQLCon;
                com.CommandText = strSql;

                com.Parameters.Add(new SqlParameter("StartDateTime", SqlDbType.DateTime));
                if (isnull)
                    com.Parameters["StartDateTime"].Value = DBNull.Value;
                else
                    com.Parameters["StartDateTime"].Value = startdate;
                com.Parameters.Add(new SqlParameter("EndDateTime", SqlDbType.DateTime));
                if (isnull)
                    com.Parameters["EndDateTime"].Value = DBNull.Value;
                else
                    com.Parameters["EndDateTime"].Value = enddate;
                SqlDataReader reader = com.ExecuteReader();
                ds.GetPayrollByInstructor.Clear();
                ds.GetPayrollByInstructor.Load(reader, LoadOption.OverwriteChanges);
                DataSet1.GetPayrollByInstructorDataTable table = new DataSet1.GetPayrollByInstructorDataTable();
                foreach (DataSet1.GetPayrollByInstructorRow row in ds.GetPayrollByInstructor.Rows)
                {
                    #region Adding to temptable
                    System.Data.DataRow[] olddr = ds.GetPayrollByInstructor.Select("TeacherID = " + row.TeacherID);
                    System.Data.DataRow[] newdr = table.Select("TeacherID = " + row.TeacherID);
                    if (olddr.Length != 4)
                    {
                        int total = newdr.Length + olddr.Length;
                        if(total != 4)
                        {
                            bool evefound = false, morfound = false, dayfound = false, satfound = false;
                            foreach (DataSet1.GetPayrollByInstructorRow srow in olddr)
                            {
                                switch (srow.DayType)
                                {
                                    case "Evening":
                                        evefound = true;
                                        break;
                                    case "Morning":
                                        morfound = true;
                                        break;
                                    case "Saturday":
                                        satfound = true;
                                        break;
                                    case "Daytime":
                                        dayfound = true;
                                        break;
                                }

                            }
                            foreach (DataSet1.GetPayrollByInstructorRow srow in newdr)
                            {
                                switch (srow.DayType)
                                {
                                    case "Evening":
                                        evefound = true;
                                        break;
                                    case "Morning":
                                        morfound = true;
                                        break;
                                    case "Saturday":
                                        satfound = true;
                                        break;
                                    case "Daytime":
                                        dayfound = true;
                                        break;
                                }
                            }
                            if (!dayfound)
                                table.AddGetPayrollByInstructorRow(row.TeacherID, row.InstructorName, Convert.ToDecimal(0.00), Convert.ToDecimal(1.0), row.BasePayField, Convert.ToDecimal(0.00), "Daytime");
                            if (!satfound)
                                table.AddGetPayrollByInstructorRow(row.TeacherID, row.InstructorName, Convert.ToDecimal(0.00), Convert.ToDecimal(1.2), row.BasePayField, Convert.ToDecimal(0.00), "Saturday");
                            if (!morfound)
                                table.AddGetPayrollByInstructorRow(row.TeacherID, row.InstructorName, Convert.ToDecimal(0.00), Convert.ToDecimal(1.1), row.BasePayField, Convert.ToDecimal(0.00), "Morning");
                            if (!evefound)
                                table.AddGetPayrollByInstructorRow(row.TeacherID, row.InstructorName, Convert.ToDecimal(0.00), Convert.ToDecimal(1.2), row.BasePayField, Convert.ToDecimal(0.00), "Evening");

                        }
                    }
                    #endregion
                }
                foreach (DataSet1.GetPayrollByInstructorRow row in table)
                {
                    ds.GetPayrollByInstructor.AddGetPayrollByInstructorRow(row.TeacherID, row.InstructorName, row.TotalHours, row.HourlyRate, row.BasePayField, row.Total, row.DayType);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (com != null)
                {
                    com.Dispose();
                    com = null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsPayrollByInstructor.cs

示例2: getEventText


//.........这里部分代码省略.........

                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();
                string id = "";
                bool IsRecord = false;
                if (Reader.Read())
                {
                    IsRecord = true;
                    if (Start)
                    {
                        if (Reader["StartDateTime"] != System.DBNull.Value)
                        {
                            dtStart = Convert.ToDateTime(Reader["StartDateTime"].ToString());
                        }
                    }
                    else
                    {
                        if (Reader["EndDateTime"] != System.DBNull.Value)
                        {
                            dtEnd = Convert.ToDateTime(Reader["EndDateTime"].ToString());
                        }
                    }
                    if(getInstructor)
                    {
                        if (Reader["ScheduledTeacherID"] != System.DBNull.Value)
                        {
                            id = Convert.ToString(Reader["ScheduledTeacherID"]);
                            //instructorName = getInstructorName(id);
                        }
                        else
                        {
                            instructorName = "None";
                        }
                    }
                    if (id == "0")
                        instructorName = "None";
                }
                Reader.Close();
                if (IsRecord)
                {
                    if (Start)
                    {
                        if (dtStart != Convert.ToDateTime(null))
                        {
                            Result = dtStart.ToShortDateString() + " " + dtStart.ToShortTimeString();
                            if (Result.IndexOf("(") > 0)
                            {
                                Result = Result.Substring(0, Result.IndexOf("(") + 1);
                            }
                            startdate = Result;
                        }
                    }
                    else
                    {
                        if (dtEnd != Convert.ToDateTime(null))
                        {
                            Result = dtEnd.ToShortDateString() + " " + dtEnd.ToShortTimeString();
                            if (Result.IndexOf("(") > 0)
                            {
                                Result = Result.Substring(0, Result.IndexOf("(") + 1);
                            }
                            enddate = Result;
                        }
                    }

                    if (id != "None" && id != "0")
                    {
                        instructorName = getInstructorName(id,con);
                    }
                    else
                        instructorName = "None";
                }
                else
                { Result = "None"; instructorName = "None"; }

                return Result;
            }
            catch (SqlException ex)
            {
                Message = ex.Message;
                return "";
            }
            finally
            {
                if (com != null)
                {
                    com.Dispose();
                    com = null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsCourse.cs

示例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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:45,代码来源:clsCourse.cs

示例4: CloneData

        public static int CloneData(int CourseId)
        {
            string strSql = "";
            SqlCommand com = null;
            Connection con = null;
            try
            {
                strSql = "usp_CourseClone";

                con = new Connection();
                con.Connect();
                com = new SqlCommand();
                com.CommandType = CommandType.StoredProcedure;
                com.Connection = con.SQLCon;
                com.CommandText = strSql;

                com.Parameters.Add(new SqlParameter("CourseId", SqlDbType.Int));
                com.Parameters["CourseId"].Value = CourseId;
                com.Parameters.Add(new SqlParameter("creatorID", SqlDbType.Int));
                com.Parameters["creatorID"].Value = Common.LogonID;
                com.Parameters.Add(new SqlParameter("insertedID", SqlDbType.Int));
                com.Parameters["insertedID"].Direction = ParameterDirection.Output;

                com.ExecuteNonQuery();

                return (int)com.Parameters["insertedID"].Value;
            }
            finally
            {
                if (com != null)
                {
                    com.Dispose();
                    com = null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:37,代码来源:clsCourse.cs

示例5: DeleteData

        public bool DeleteData()
        {
            string strSql="";
            SqlCommand com=null;
            Connection con=null;
            try
            {
                con=new Connection();
                con.Connect();
                com = new SqlCommand();
                com.Connection=con.SQLCon;

                com.Parameters.Add(new SqlParameter("@CourseId", SqlDbType.Int));
                com.Parameters["@CourseId"].Value = _courseid;

                //Test Initial Event ID
                strSql =  "Delete From [Event] " +
                    "WHERE EventID IN (Select TestInitialEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                strSql =  "Delete From [CalendarEvent] " +
                    "WHERE EventID IN (Select TestInitialEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                //Test MidTerm Event ID
                strSql =  "Delete From [Event] " +
                    "WHERE EventID IN (Select TestMidTermEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                strSql =  "Delete From [CalendarEvent] " +
                    "WHERE EventID IN (Select TestMidTermEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                //Test Final Event ID
                strSql =  "Delete From [Event] " +
                    "WHERE EventID IN (Select TestFinalEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                strSql =  "Delete From [CalendarEvent] " +
                    "WHERE EventID IN (Select TestFinalEventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                //Event ID
                strSql =  "Delete From [Event] " +
                    "WHERE EventID IN (Select EventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                strSql =  "Delete From [CalendarEvent] " +
                    "WHERE EventID IN (Select EventID From [Course] " +
                    "WHERE [email protected])  ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                strSql =  "Delete From [Course] " +
                    "WHERE [email protected] ";
                com.CommandText=strSql;
                com.ExecuteNonQuery();

                return true;
            }
            catch(SqlException ex)
            {
                Message=ex.Message;
                return false;
            }
            finally
            {
                if(com!=null)
                {
                    com.Dispose();
                    com=null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:89,代码来源:clsCourse.cs

示例6: LoadData


//.........这里部分代码省略.........
                    _namephonetic = Reader["NamePhonetic"].ToString();
                    _nameromaji = Reader["NameRomaji"].ToString();
                    if(Reader["ProgramID"]!=System.DBNull.Value)
                    {
                        _programid = Convert.ToInt32(Reader["ProgramID"].ToString());
                    }
                    _program = Reader["Program"].ToString();
                    _nickname = Reader["NickName"].ToString();
                    _description = Reader["Description"].ToString();
                    _coursetype = Reader["CourseType"].ToString();
                    _specialremarks = Reader["SpecialRemarks"].ToString();
                    _curriculam = Reader["Curriculam"].ToString();
                    _numberstudents = Convert.ToInt32(Reader["NumberStudents"].ToString());
                    _homeworkminutes = Convert.ToInt32(Reader["HomeWorkMinutes"].ToString());
                    _eventid = Convert.ToInt32(Reader["EventID"].ToString());
                    _testinieventid = Convert.ToInt32(Reader["TestInitialEventID"].ToString());
                    _testmideventid = Convert.ToInt32(Reader["TestMidtermEventID"].ToString());
                    _testfinaleventid = Convert.ToInt32(Reader["TestFinalEventID"].ToString());
                    _testiniform = Reader["TestInitialForm"].ToString();
                    _testmidform = Reader["TestMidtermForm"].ToString();
                    _testfinalform = Reader["TestFinalForm"].ToString();
                    _coursestatus = Convert.ToInt32(Reader["CourseStatus"].ToString());
                    _breakduration = Convert.ToInt32(Reader["BreakDuration"].ToString());

                    _dtbl.Rows.Add(new object[]

                    {
                        _courseid,
                        Reader["BrowseName"].ToString(),
                        _name,
                        _namephonetic,
                        _nameromaji,
                        _nickname,
                        _programid,
                        _program,
                        Reader["Client"].ToString(),
                        Reader["Department"].ToString(),
                        _description,
                        _coursetype,
                        _specialremarks,
                        _curriculam,
                        _numberstudents,
                        _homeworkminutes,
                        _eventid,
                        _testinieventid,
                        _testmideventid,
                        _testfinaleventid,
                        Reader["TestInitialForm"].ToString(),
                        Reader["TestMidtermForm"].ToString(),
                        Reader["TestFinalForm"].ToString(),
                        strstatus,
                        _breakduration
                    });
                }
                Reader.Close();

                int intEID=0;
                string startdate="", enddate="";
                string instructorName = "";
                foreach(DataRow dr in _dtbl.Rows)
                {
                    intEID = Convert.ToInt32(dr["EventID"].ToString());

                    //getEventText(intEID, ref startdate, ref enddate);
                    startdate = getEventText(intEID, true,true,ref instructorName);
                    enddate = getEventText(intEID, false);

                    // gad - Enable these comments 1-3 in order to allow a cloned Class that has no start or end date
                    // to be opened instead of generating an exception
                    //1 if (startdate.ToString() != "None")
                    //2 {
                        dr["EventStartDateTime"] = startdate;
                        dr["EventEndDateTime"] = enddate;
                        dr["OccurrenceCount"] = getOccurrenceCount(intEID);
                        dr["ScheduledInstructor"] = instructorName;
                        dr.AcceptChanges();
                    //3 }
                }

                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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsCourse.cs

示例7: LoadOtherEvents

        //Loads Other Events (Events with 'EventType' fields set to anything but ZERO.
        /* Event Type Field Values:
         * 'Class' =  Repeating or Single Occurence
         * 'Test Initial', 'Test Mid', 'Test Final', 'Extra Class'
         */
        public DataTable LoadOtherEvents(bool IsRecurring)
        {
            string strSql = "";
            SqlDataReader Reader = null;
            SqlCommand com = null;
            Connection con = null;

            try
            {
                //Here we need to make sure that we use different commands for selecting Tests and Extra Classes
                //because extra classes only exist for repeating class events and NOT single occuring class events!

                //Loading Positive Exceptions first
                _dtbl = new DataTable();
                /*
                strSql = "Select Count(*) from Event WHERE RecurrenceText IS NOT NULL AND EventId=" + _eventid + ";";
                con = new Connection();
                con.Connect();
                com = new SqlCommand(strSql, con.SQLCon);
                int result = (int)com.ExecuteScalar();
                */
                con = new Connection();
                con.Connect();
                //Means the class event exists and class reocurrs alright
                if (_eventid > 0 && IsRecurring)
                {
                    strSql = "Select * from [CalendarEvent] WHERE EventId=" + _eventid + " AND EventType='Extra Class';";
                    com = new SqlCommand(strSql, con.SQLCon);
                    Reader = com.ExecuteReader();
                    if (Reader.HasRows)
                        _dtbl.Load(Reader);
                    Reader.Close();
                }

                //Now, Loading the Test Events (if any)
                strSql = "Select TestInitialEventId,TestMidtermEventId,TestFinalEventId from [Course] WHERE [email protected]";
                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];
                Reader.Read();
                temp[0] = Reader[0].ToString();
                temp[1] = Reader[1].ToString();
                temp[2] = Reader[2].ToString();
                Reader.Close();

                string temp2 = "";
                if (temp[0] != null && temp[0] != "")
                    temp2 = temp[0];
                if (temp[1] != null && temp[1] != "")
                    temp2 += "," + temp[1];
                if (temp[2] != null && temp[2] != "")
                    temp2 += "," + temp[2];

                strSql = "SELECT * from [CalendarEvent] WHERE EventType LIKE 'Test%' AND EventId IN (" + temp2 + ");";
                //com = new SqlCommand(strSql, con.SQLCon);
                com.CommandText = strSql;
                Reader = com.ExecuteReader();

                if (Reader.HasRows)
                {
                    if (_dtbl.Rows.Count==0) _dtbl.Load(Reader);
                    else
                    {
                        DataTable _temp = new DataTable();
                        _temp.Load(Reader);
                        _dtbl.Merge(_temp);
                    }
                }

                Reader.Close();

                return _dtbl;
            }
            catch (SqlException ex)
            {
                Message = ex.Message;
                return null;
            }
            finally
            {
                if (com != null)
                {
                    com.Dispose();
                    com = null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:96,代码来源:clsCourse.cs

示例8: 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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:49,代码来源:clsContact.cs

示例9: InsertData


//.........这里部分代码省略.........
                com.Parameters["@Street3"].Value = Street3;
                com.Parameters["@City"].Value = City;
                com.Parameters["@State"].Value = State;
                com.Parameters["@PostalCode"].Value = PostalCode;
                com.Parameters["@Country"].Value = Country;
                com.Parameters["@ContactType"].Value = ContactType;
                com.Parameters["@BlockCode"].Value = BlockCode;
                com.Parameters["@Email1"].Value = Email1;
                com.Parameters["@Email2"].Value = Email2;
                com.Parameters["@AccountRepLastName"].Value = AccountRepLastName;
                com.Parameters["@AccountRepLastNamePhonetic"].Value = AccountRepLastNamePhonetic;
                com.Parameters["@AccountRepLastNameRomaji"].Value = AccountRepLastNameRomaji;
                com.Parameters["@AccountRepFirstName"].Value = AccountRepFirstName;
                com.Parameters["@AccountRepFirstNamePhonetic"].Value = AccountRepFirstNamePhonetic;
                com.Parameters["@AccountRepFirstNameRomaji"].Value = AccountRepFirstNameRomaji;
                com.Parameters["@Phone1"].Value = Phone1;
                com.Parameters["@Phone2"].Value = Phone2;
                com.Parameters["@PhoneMobile1"].Value = PhoneMobile1;
                com.Parameters["@PhoneMobile2"].Value = PhoneMobile2;
                com.Parameters["@PhoneBusiness1"].Value = PhoneBusiness1;
                com.Parameters["@PhoneBusiness2"].Value = PhoneBusiness2;
                com.Parameters["@PhoneFax1"].Value = PhoneFax1;
                com.Parameters["@PhoneFax2"].Value = PhoneFax2;
                com.Parameters["@PhoneOther"].Value = PhoneOther;
                com.Parameters["@Url"].Value = Url;

                if(DateBirth==Convert.ToDateTime(null))
                    com.Parameters["@DateBirth"].Value = DBNull.Value;
                else
                    com.Parameters["@DateBirth"].Value = DateBirth;

                if(DateJoined==Convert.ToDateTime(null))
                    com.Parameters["@DateJoined"].Value = DBNull.Value;
                else
                    com.Parameters["@DateJoined"].Value = DateJoined;

                if(DateEnded==Convert.ToDateTime(null))
                    com.Parameters["@DateEnded"].Value = DBNull.Value;
                else
                    com.Parameters["@DateEnded"].Value = DateEnded;

                com.Parameters["@TimeStatus"].Value = TimeStatus;
                com.Parameters["@Nationality"].Value = Nationality;
                com.Parameters["@Married"].Value = Married;
                com.Parameters["@NumberDependents"].Value = NumberDependents;
                com.Parameters["@VisaStatus"].Value = VisaStatus;

                if(VisaFromDate==Convert.ToDateTime(null))
                    com.Parameters["@VisaFromDate"].Value = DBNull.Value;
                else
                    com.Parameters["@VisaFromDate"].Value = VisaFromDate;

                if(VisaUntilDate==Convert.ToDateTime(null))
                    com.Parameters["@VisaUntilDate"].Value = DBNull.Value;
                else
                    com.Parameters["@VisaUntilDate"].Value = VisaUntilDate;

                com.Parameters["@ClosestStation1"].Value = ClosestStation1;
                com.Parameters["@ClosestLine1"].Value = ClosestLine1;
                com.Parameters["@MinutesToStation1"].Value =MinutesToStation1;
                com.Parameters["@ClosestStation2"].Value = ClosestStation2;
                com.Parameters["@ClosestLine2"].Value = ClosestLine2;
                com.Parameters["@MinutesToStation2"].Value = MinutesToStation2;
                com.Parameters["@ContactStatus"].Value = ContactStatus;
                com.Parameters["@CreatedByUserId"].Value = Scheduler.BusinessLayer.Common.LogonID;
                com.Parameters["@DateCreated"].Value = DateTime.Now;
                com.Parameters["@DateLastModified"].Value = DateTime.Now;
                com.Parameters["@LastModifiedByUserID"].Value = Scheduler.BusinessLayer.Common.LogonID;
                com.Parameters["@BasePayField"].Value = BaseRate;
                Reader = com.ExecuteReader();
                if(Reader.Read())
                {
                    _contactid = Convert.ToInt32(Reader[0].ToString());
                }

                return true;
            }
            catch(SqlException ex)
            {
                Message=ex.Message;
                return false;
            }
            finally
            {
                if(Reader!=null)
                {
                    if(Reader.IsClosed==false)
                    {
                        Reader.Close();
                        Reader=null;
                    }
                }
                if(com!=null)
                {
                    com.Dispose();
                    com=null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsContact.cs

示例10: 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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:42,代码来源:clsContact.cs

示例11: 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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:48,代码来源:clsContact.cs

示例12: 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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:35,代码来源:clsContact.cs

示例13: UpdateData


//.........这里部分代码省略.........
                com.Parameters["@LastNamePhonetic"].Value = LastNamePhonetic;
                com.Parameters["@LastNameRomaji"].Value = LastNameRomaji;
                com.Parameters["@FirstName"].Value = FirstName;
                com.Parameters["@FirstNamePhonetic"].Value = FirstNamePhonetic;
                com.Parameters["@FirstNameRomaji"].Value = FirstNameRomaji;
                com.Parameters["@NickName"].Value = NickName;
                com.Parameters["@CompanyName"].Value = CompanyName;
                com.Parameters["@CompanyNamePhonetic"].Value = CompanyNamePhonetic;
                com.Parameters["@CompanyNameRomaji"].Value = CompanyNameRomaji;
                com.Parameters["@TitleForName"].Value = TitleForName;
                com.Parameters["@TitleForJob"].Value = TitleForJob;
                com.Parameters["@Street1"].Value = Street1;
                com.Parameters["@Street2"].Value = Street2;
                com.Parameters["@Street3"].Value = Street3;
                com.Parameters["@City"].Value = City;
                com.Parameters["@State"].Value = State;
                com.Parameters["@PostalCode"].Value = PostalCode;
                com.Parameters["@Country"].Value = Country;
                com.Parameters["@ContactType"].Value = ContactType;
                com.Parameters["@BlockCode"].Value = BlockCode;
                com.Parameters["@Email1"].Value = Email1;
                com.Parameters["@Email2"].Value = Email2;
                com.Parameters["@AccountRepLastName"].Value = AccountRepLastName;
                com.Parameters["@AccountRepLastNamePhonetic"].Value = AccountRepLastNamePhonetic;
                com.Parameters["@AccountRepLastNameRomaji"].Value = AccountRepLastNameRomaji;
                com.Parameters["@AccountRepFirstName"].Value = AccountRepFirstName;
                com.Parameters["@AccountRepFirstNamePhonetic"].Value = AccountRepFirstNamePhonetic;
                com.Parameters["@AccountRepFirstNameRomaji"].Value = AccountRepFirstNameRomaji;
                com.Parameters["@Phone1"].Value = Phone1;
                com.Parameters["@Phone2"].Value = Phone2;
                com.Parameters["@PhoneMobile1"].Value = PhoneMobile1;
                com.Parameters["@PhoneMobile2"].Value = PhoneMobile2;
                com.Parameters["@PhoneBusiness1"].Value = PhoneBusiness1;
                com.Parameters["@PhoneBusiness2"].Value = PhoneBusiness2;
                com.Parameters["@PhoneFax1"].Value = PhoneFax1;
                com.Parameters["@PhoneFax2"].Value = PhoneFax2;
                com.Parameters["@PhoneOther"].Value = PhoneOther;
                com.Parameters["@Url"].Value = Url;
                if(DateBirth==Convert.ToDateTime(null))
                    com.Parameters["@DateBirth"].Value = System.DBNull.Value;
                else
                    com.Parameters["@DateBirth"].Value = DateBirth;

                if(DateJoined==Convert.ToDateTime(null))
                    com.Parameters["@DateJoined"].Value = System.DBNull.Value;
                else
                    com.Parameters["@DateJoined"].Value = DateJoined;

                if(DateEnded==Convert.ToDateTime(null))
                    com.Parameters["@DateEnded"].Value = System.DBNull.Value;
                else
                    com.Parameters["@DateEnded"].Value = DateEnded;

                com.Parameters["@TimeStatus"].Value = TimeStatus;
                com.Parameters["@Nationality"].Value = Nationality;
                com.Parameters["@Married"].Value = Married;
                com.Parameters["@NumberDependents"].Value = NumberDependents;
                com.Parameters["@VisaStatus"].Value = VisaStatus;

                if(VisaFromDate==Convert.ToDateTime(null))
                    com.Parameters["@VisaFromDate"].Value = System.DBNull.Value;
                else
                    com.Parameters["@VisaFromDate"].Value = VisaFromDate;

                if(VisaUntilDate==Convert.ToDateTime(null))
                    com.Parameters["@VisaUntilDate"].Value = System.DBNull.Value;
                else
                    com.Parameters["@VisaUntilDate"].Value = VisaUntilDate;

                com.Parameters["@ClosestStation1"].Value = ClosestStation1;
                com.Parameters["@ClosestLine1"].Value = ClosestLine1;
                com.Parameters["@MinutesToStation1"].Value =MinutesToStation1;
                com.Parameters["@ClosestStation2"].Value = ClosestStation2;
                com.Parameters["@ClosestLine2"].Value = ClosestLine2;
                com.Parameters["@MinutesToStation2"].Value = MinutesToStation2;
                com.Parameters["@ContactStatus"].Value = ContactStatus;
                com.Parameters["@DateCreated"].Value = DateTime.Now;
                com.Parameters["@DateLastModified"].Value = DateTime.Now;
                com.Parameters["@LastModifiedByUserID"].Value = Scheduler.BusinessLayer.Common.LogonID;
                com.Parameters["@BasePayField"].Value = BaseRate;

                com.ExecuteNonQuery();

                return true;
            }
            catch(SqlException ex)
            {
                Message=ex.Message;
                return false;
            }
            finally
            {
                if(com!=null)
                {
                    com.Dispose();
                    com=null;
                    con.DisConnect();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsContact.cs

示例14: IsEventExists

        public bool IsEventExists(int evtid)
        {
            string strSql="";
            SqlCommand com=null;
            Connection con=null;
            try
            {
                strSql =  "Select Count(EventID) From [Event] " +
                    "WHERE EventID=" + evtid.ToString() + " ";

                con=new Connection();
                con.Connect();
                com = new SqlCommand();
                com.Connection=con.SQLCon;
                com.CommandText = strSql;

                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();
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:39,代码来源:clsCourse.cs

示例15: LoadData


//.........这里部分代码省略.........
                        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 " +
                        "WHERE ContactID = " + _contactid + " ";
                }

                con=new Connection();
                con.Connect();
                com = new SqlCommand();
                com.Connection=con.SQLCon;
                com.CommandText = strSql;

                adpt=new SqlDataAdapter();
                adpt.SelectCommand = com;
                adpt.Fill(_dtbl);

                if(contacttypeid==2)
                {
                    _dtbl.Columns.Add("Contact1", Type.GetType("System.String"));
                    _dtbl.Columns.Add("Contact2", Type.GetType("System.String"));
                    _dtbl.Columns.Add("Contact1Phone", Type.GetType("System.String"));
                    _dtbl.Columns.Add("Contact2Phone", Type.GetType("System.String"));

                    //Get the contacts
                    int contid=0;
                    string contact1="";
                    string contact2="";
                    string phone1="";
                    string phone2="";
                    foreach(DataRow dr in _dtbl.Rows)
                    {
                        contid=0;
                        contact1="";
                        contact2="";
                        phone1="";
                        phone2="";
                        contid=Convert.ToInt32(dr["ContactID"].ToString());
                        GetContact(contid, ref contact1, ref contact2, ref phone1, ref phone2);
                        dr["Contact1"] = contact1;
                        dr["Contact2"] = contact2;
                        dr["Contact1Phone"] = phone1;
                        dr["Contact2Phone"] = phone2;
                        dr.AcceptChanges();
                    }
                }

                return _dtbl;
            }
            catch(SqlException ex)
            {
                Message=ex.Message;
                return null;
            }
            finally
            {
                if(com!=null)
                {
                    com.Dispose();
                    com=null;
                    con.DisConnect();
                    adpt.Dispose();
                    adpt=null;
                }
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:101,代码来源:clsContact.cs


注:本文中的Scheduler.BusinessLayer.Connection.DisConnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。