Exemple #1
0
        public override void Save()
        {
            DriverList driverList = DriverList.getInstance();

            string dateBirthSql = string.Empty;

            if (DateBirth != string.Empty)
            {
                dateBirthSql = string.Concat(_dateBirth.Year.ToString(), "-", _dateBirth.Month.ToString(), "-",
                                             _dateBirth.Day.ToString());
            }

            string dateStopNotificationSql = string.Empty;

            if (DateStopNotification.Year != 1)
            {
                dateStopNotificationSql = string.Concat(DateStopNotification.Year.ToString(), "-",
                                                        DateStopNotification.Month.ToString(), "-", DateStopNotification.Day.ToString());
            }

            int id;

            int.TryParse(Provider.Insert("Driver", Id, GetName(NameType.Full), Region.Id, dateBirthSql, _mobile, email,
                                         _fired, _expSince, PositionID,
                                         DeptID, Login, OwnerID, suppyAddress, SexIndex, _decret,
                                         dateStopNotificationSql, _number, _isDriver, _from1C), out id);
            Id = id;

            driverList.Add(this);
        }
Exemple #2
0
        /// <summary>
        /// This method provides List of Drivers available in Database.
        /// </summary>
        /// <param name="strWhere">Specifies condition for retrieving records.</param>
        /// <returns>Collection of Driver Objects.</returns>
        public static DriverList GetList(string strWhere)
        {
            DriverList objList = null;
            string     strSql  = "SELECT * FROM DRIVERMASTER";

            if (strWhere != string.Empty)
            {
                strSql = strSql + " WHERE " + strWhere;
            }
            strSql += " ORDER BY NAME";

            using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString()))
            {
                using (SqlCommand objCmd = new SqlCommand())
                {
                    objCmd.Connection  = Conn;
                    objCmd.CommandType = CommandType.Text;
                    objCmd.CommandText = strSql;

                    if (Conn.State != ConnectionState.Open)
                    {
                        Conn.Open();
                    }

                    using (SqlDataReader oReader = objCmd.ExecuteReader())
                    {
                        if (oReader.HasRows)
                        {
                            objList = new DriverList();
                            while (oReader.Read())
                            {
                                objList.Add(FillDataRecord(oReader));
                            }
                        }
                        oReader.Close();
                        oReader.Dispose();
                    }
                }
            }
            return(objList);
        }