コード例 #1
0
        new public void Refresh(EPVDatabase database)
        {
            DbDataReader reader;

            Clear();
            if (unit != null)
            {
                QueryParameters parameters = new QueryParameters("unit", unit.Id);
                reader = database.ExecuteReader(querySelect, parameters);
            }
            else
            {
                reader = database.ExecuteReader(querySelect);
            }
            while (reader.Read())
            {
                if (unit != null)
                {
                    Add(new Point(reader, unit));
                }
                else
                {
                    Add(new Point(reader, units));
                }
            }

            reader.Close();
        }
コード例 #2
0
        private void tboxTrackMark_Leave(object sender, EventArgs e)
        {
            AutoCompleteStringCollection licensePlateCollection = new AutoCompleteStringCollection();
            QueryParameters parameters = new QueryParameters("trackMark", tboxTrackMark.Text);
            DbDataReader    reader     = database.ExecuteReader(Queries.LicensePlateList, parameters);

            while (reader.Read())
            {
                licensePlateCollection.Add((string)reader[0]);
            }
            reader.Close();

            tboxLicensePlate.AutoCompleteCustomSource = licensePlateCollection;
        }
コード例 #3
0
        public static BindingList <IAppointHistory> LoadList(EPVDatabase database,
                                                             int id, DateTime dateFrom, DateTime dateTo, string vehicleNum, int unitId, string cargo)
        {
            BindingList <IAppointHistory> list = new BindingList <IAppointHistory>();

            QueryParameters parameters = new QueryParameters("id", id);

            parameters.Add("dateFrom", dateFrom);
            parameters.Add("dateTo", dateTo);
            parameters.Add("vehicleNum", vehicleNum);
            parameters.Add("unitId", unitId);
            parameters.Add("cargo", cargo);

            string query = DispatcherService.Resources.Doc.Appoint.LoadHistory;

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                while (reader.Read())
                {
                    list.Add(new DispatcherService.AppointStateHistory(reader));
                }

                reader.Close();
            }

            return(list);
        }
コード例 #4
0
        public static Permit Load(EPVDatabase database, int id)
        {
            string          query      = DispatcherService.Resources.Doc.Permit.Load;
            QueryParameters parameters = new QueryParameters("id", id);

            Permit permit = null;

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                if (reader.Read())
                {
                    permit = new Permit(reader);
                }

                reader.Close();
            }

            if (permit == null)
            {
                throw new ArgumentException(DispatcherService.Resources.Error.WrongIdentifier);
            }

            permit.Vehicle = Vehicle.Load(database, permit.VehicleId);

            return(permit);
        }
コード例 #5
0
        public static List <Vehicle> LoadList(EPVDatabase database, VehicleMark mark, string licensePlate)
        {
            List <Vehicle> vehicleList = new List <Vehicle>();

            QueryParameters parameters = new QueryParameters("licensePlate", licensePlate);

            if (mark != null)
            {
                parameters.Add("vehicleMark", mark.Id);
            }
            else
            {
                parameters.Add("vehicleMark", DBNull.Value);
            }

            using (DbDataReader reader = database.ExecuteReader(LoadListQuery, parameters))
            {
                while (reader.Read())
                {
                    vehicleList.Add(new Vehicle(reader));
                }

                reader.Close();
            }

            return(vehicleList);
        }
コード例 #6
0
        private void fillLicenseAutoComplete()
        {
            string query = "select licensePlate, count(id) as cnt from docAppoints ";

            if (textBoxTrackMark.Text.Length > 0)
            {
                query += "where trackMark like '" + textBoxTrackMark.Text + "' ";
            }
            query += "group by licensePlate having count(id) > 1 order by cnt desc";

            DbDataReader reader = database.ExecuteReader(query);
            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            while (reader.Read())
            {
                collection.Add((string)reader["licensePlate"]);
            }
            reader.Close();
            textBoxLicensePlate.AutoCompleteCustomSource = collection;
        }
コード例 #7
0
        public Points(EPVDatabase database)
        {
            units       = new Units(database);
            querySelect = "select * from refPoints order by idunit, id";
            DbDataReader reader = database.ExecuteReader(querySelect);

            while (reader.Read())
            {
                Add(new Point(reader, units));
            }
            reader.Close();
        }
コード例 #8
0
        new void Refresh(EPVDatabase database)
        {
            QueryParameters parameters = new QueryParameters("appoint", appoint.Id);

            docStates = new Enumeration(database, "docState");
            DbDataReader reader = database.ExecuteReader(querySelect, parameters);

            while (reader.Read())
            {
                Add(new AppointState(reader, appoint, docStates));
            }
            reader.Close();
        }
コード例 #9
0
        public Points(EPVDatabase database, Unit unt)
        {
            unit = unt;

            querySelect = "select * from refPoints where idUnit = @unit order by id";
            QueryParameters parameters = new QueryParameters("unit", unit.Id);
            DbDataReader    reader     = database.ExecuteReader(querySelect, parameters);

            while (reader.Read())
            {
                Add(new Point(reader, unit));
            }
            reader.Close();
        }
コード例 #10
0
        public static List <VehicleMark> LoadList(EPVDatabase database)
        {
            List <VehicleMark> list = new List <VehicleMark>();

            using (DbDataReader reader = database.ExecuteReader(LoadListQuery))
            {
                while (reader.Read())
                {
                    list.Add(new VehicleMark(reader));
                }
                reader.Close();
            }

            return(list);
        }
コード例 #11
0
        public static BindingList <PlanAppoint> LoadList(EPVDatabase database)
        {
            Units units = new Units(database);

            BindingList <PlanAppoint> list = new BindingList <PlanAppoint>();

            DbDataReader reader = database.ExecuteReader(Queries.SelectFullList);

            while (reader.Read())
            {
                list.Add(new PlanAppoint(reader, units));
            }
            reader.Close();
            return(list);
        }
コード例 #12
0
        public AppointStates(EPVDatabase database, Appoint apnt)
        {
            appoint     = apnt;
            querySelect = "select * from docAppointStates where appoint = @appoint order by dateState";
            QueryParameters parameters = new QueryParameters("appoint", appoint.Id);

            docStates = new Enumeration(database, "docState");
            DbDataReader reader = database.ExecuteReader(querySelect, parameters);

            while (reader.Read())
            {
                Add(new AppointState(reader, appoint, docStates));
            }
            reader.Close();
        }
コード例 #13
0
        public Appoints(EPVDatabase database, DocStateGroups grp, Unit unt)
        {
            group     = grp;
            unit      = unt;
            units     = new Units(database);
            docStates = new Enumeration(database, "docState");
            states    = new States(database);
            points    = new Points(database);

            querySelect  = "select a.*, s.*, ";
            querySelect += "(select dateState from docAppointStates where appoint = a.id and docState = 0) as dateComing ";
            querySelect += ", (select PERMIT from docPlanAppoint where id = a.planAppoint) as permitId ";
            querySelect += "from docAppoints a, docAppointStates s ";
            querySelect += "where a.id = s.appoint and ";
            querySelect += "s.docState = (select max(s1.docState) from docAppointStates s1 where s1.appoint = a.id) ";
            querySelect += "and idUnit = @unit ";

            switch (group)
            {
            case DocStateGroups.Dispatcher:
                querySelect += "and s.docState < 3";
                break;

            case DocStateGroups.BeforeStart:
                querySelect += "and s.docState = 3";
                break;

            case DocStateGroups.OnPoint:
                querySelect += "and s.docState = 4";
                break;

            case DocStateGroups.ToExit:
                querySelect += "and s.docState = 5";
                break;
            }

            QueryParameters parameters = new QueryParameters("unit", unit.Id);

            DbDataReader reader = database.ExecuteReader(querySelect, parameters);

            while (reader.Read())
            {
                Add(new Appoint(reader, units, states, points, docStates));
            }
            reader.Close();
        }
コード例 #14
0
        public static List <PlanAppoint> LoadList(EPVDatabase database, DateTime date)
        {
            List <PlanAppoint> planAppointList = new List <PlanAppoint>();

            QueryParameters parameters = new QueryParameters("dateStart", date);

            using (DbDataReader reader = database.ExecuteReader(LoadListQuery, parameters))
            {
                while (reader.Read())
                {
                    planAppointList.Add(new PlanAppoint(reader));
                }
                reader.Close();
            }

            return(planAppointList);
        }
コード例 #15
0
        public static List <Unit> LoadList(EPVDatabase database, ISystemUser user)
        {
            List <Unit> unitList = new List <Unit>();

            string          query      = DispatcherService.Resources.Ref.Unit.ListForUser;
            QueryParameters parameters = new QueryParameters("userId", user.Id);

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                while (reader.Read())
                {
                    unitList.Add(new Unit(reader));
                }
                reader.Close();
            }

            return(unitList);
        }
コード例 #16
0
        public static List <MaterialPermitItem> LoadList(MaterialPermit document, EPVDatabase database)
        {
            List <MaterialPermitItem> itemList = new List <MaterialPermitItem>();

            QueryParameters parameters = new QueryParameters("document", document.Id);

            using (DbDataReader reader = database.ExecuteReader(QueryLoadList, parameters))
            {
                while (reader.Read())
                {
                    itemList.Add(new MaterialPermitItem(document, reader));
                }

                reader.Close();
            }

            return(itemList);
        }
コード例 #17
0
        public static BindingList <AppointLog> LoadList(EPVDatabase database, int id)
        {
            BindingList <AppointLog> list = new BindingList <AppointLog>();

            string          query      = Resources.Doc.Appoint.LoadLog;
            QueryParameters parameters = new QueryParameters("id", id);

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                while (reader.Read())
                {
                    list.Add(new AppointLog(reader));
                }

                reader.Close();
            }

            return(list);
        }
コード例 #18
0
        public static BindingList <PlanAppoint> LoadList(EPVDatabase database, DateTime date)
        {
            Units units = new Units(database);

            BindingList <PlanAppoint> list = new BindingList <PlanAppoint>();

            QueryParameters parameters = new QueryParameters("dateFrom", date);

            parameters.Add("dateTo", date.AddDays(1).AddSeconds(-1));

            DbDataReader reader = database.ExecuteReader(Queries.QuerySelectList, parameters);

            while (reader.Read())
            {
                list.Add(new PlanAppoint(reader, units));
            }
            reader.Close();
            return(list);
        }
コード例 #19
0
        public static VehicleMark Load(EPVDatabase database, int id)
        {
            VehicleMark     vehicleMark = null;
            QueryParameters parameters  = new QueryParameters("id", id);

            using (DbDataReader reader = database.ExecuteReader(LoadQuery, parameters))
            {
                if (reader.Read())
                {
                    vehicleMark = new VehicleMark(reader);
                }
                reader.Close();
            }

            if (vehicleMark == null)
            {
                throw new ArgumentException(DispatcherService.Resources.Error.WrongIdentifier);
            }

            return(vehicleMark);
        }
コード例 #20
0
        /// <summary>
        ///     Получает из БД список всех транспортов, находящихся в определенном состоянии на определенной точке
        /// </summary>
        /// <param name="database">База данных</param>
        /// <param name="point">Точка погрузки/выгрузки</param>
        /// <param name="docState">состояние</param>
        /// <returns>набор записей</returns>
        public static BindingList <AppointState> LoadList(EPVDatabase database, Point point, EnumerationItem docState)
        {
            Units       unitList  = new Units(database);
            States      stateList = new States(database);
            Enumeration docStates = new Enumeration(database, "docState");

            BindingList <AppointState> appointList = new BindingList <AppointState>();
            QueryParameters            parameters  = new QueryParameters("pointId", point.Id);

            parameters.Add("docState", docState.Id);

            DbDataReader reader = database.ExecuteReader(Classes.Queries.PointStateAppoins, parameters);

            while (reader.Read())
            {
                appointList.Add(new AppointState(reader, new Appoint(reader, unitList, stateList, docStates), docStates));
            }
            reader.Close();

            return(appointList);
        }
コード例 #21
0
        public Appoint(EPVDatabase database, Appoint copy, Units units, States states)
        {
            id = copy.Id;
            string query = "select a.*, ";

            query += "(select dateState from docAppointStates where appoint = a.id and docState = 0) as dateComing ";
            query += ", (select PERMIT from docPlanAppoint where id = a.planAppoint) as permitId ";
            query += "from docAppoints a where a.id = @id";
            QueryParameters parameters = new QueryParameters("id", id);
            DbDataReader    reader     = database.ExecuteReader(query, parameters);

            reader.Read();
            unit         = units.Find((int)reader["idUnit"]);
            trackMark    = (string)(DBNull.Value.Equals(reader["trackMark"]) ? string.Empty : reader["trackMark"]);
            licensePlate = (string)reader["licensePlate"];
            trailer      = (string)(DBNull.Value.Equals(reader["trailer"]) ? string.Empty : reader["trailer"]);
            citizen      = states.Find((int)reader["state"]);
            driverName   = (string)(DBNull.Value.Equals(reader["driverName"]) ? string.Empty : reader["driverName"]);
            driverPhone  = (string)(DBNull.Value.Equals(reader["driverPhone"]) ? string.Empty : reader["driverPhone"]);
            warrant      = (string)(DBNull.Value.Equals(reader["warrant"]) ? string.Empty : reader["warrant"]);
            whereTo      = (string)(DBNull.Value.Equals(reader["whereTo"]) ? string.Empty : reader["whereTo"]);
            cargo        = (string)(DBNull.Value.Equals(reader["cargo"]) ? string.Empty : reader["cargo"]);
            idleReason   = (string)(DBNull.Value.Equals(reader["idleReason"]) ? string.Empty : reader["idleReason"]);
            dateComing   = (DateTime)reader["dateComing"];
            docState     = copy.DocState;
            docStateDate = copy.docStateDate;


            if (DBNull.Value.Equals(reader["permitId"]))
            {
                HasPermit = false;
            }
            else
            {
                HasPermit = ((int)reader["permitId"] > 0);
                permitId  = (int)reader["permitId"];
            }

            reader.Close();
        }
コード例 #22
0
        private void FillLastAppointData()
        {
            PlanAppoint lastPlanAppoint = PlanAppoint.Vehicle.GetLastPlanAppoint(Database);

            if (lastPlanAppoint != null)
            {
                PlanAppoint.Cargo = lastPlanAppoint.Cargo;
                rboxCargo.Refresh();
                PlanAppoint.DriverName = lastPlanAppoint.DriverName;
                PlanAppoint.Contact    = lastPlanAppoint.Contact;
                PlanAppoint.WhereTo    = lastPlanAppoint.WhereTo;

                string          query      = DispatcherService.Resources.Doc.PlanAppoint.GetTrailer;
                QueryParameters parameters = new QueryParameters("id", lastPlanAppoint.Id);

                using (DbDataReader reader = Database.ExecuteReader(query, parameters))
                {
                    if (reader.Read())
                    {
                        if (!DBNull.Value.Equals(reader["trailer"]))
                        {
                            tboxTrailer.Text = (string)reader["trailer"];
                        }

                        if (!DBNull.Value.Equals(reader["state"]))
                        {
                            cboxCountry.SelectedItem = ((States)cboxCountry.DataSource).Find((int)reader["state"]);
                        }

                        if (!DBNull.Value.Equals(reader["idUnit"]))
                        {
                            cboxUnit.SelectedItem = ((Units)cboxUnit.DataSource).Find((int)reader["idUnit"]);
                        }
                    }

                    reader.Close();
                }
            }
        }
コード例 #23
0
        public static MaterialPermit Load(EPVDatabase database, int id)
        {
            MaterialPermit  materialPermit = null;
            QueryParameters parameters     = new QueryParameters("id", id);

            using (DbDataReader reader = database.ExecuteReader(LoadQuery, parameters))
            {
                if (reader.Read())
                {
                    materialPermit = new MaterialPermit(reader);
                }

                reader.Close();
            }

            if (materialPermit == null)
            {
                throw new ArgumentException(DispatcherService.Resources.Error.WrongIdentifier);
            }

            return(materialPermit);
        }
コード例 #24
0
        public PlanAppoint CreateCopy(EPVDatabase database)
        {
            Units units = new Units(database);

            QueryParameters parameters = new QueryParameters("id", Id);
            PlanAppoint     appoint    = null;

            DbDataReader reader = database.ExecuteReader(Queries.QuerySelect, parameters);

            if (reader.Read())
            {
                appoint = new PlanAppoint(reader, units);
            }
            reader.Close();

            if (appoint == null)
            {
                throw new ArgumentException("Нет записи с идентификатором " + Id.ToString());
            }

            return(appoint);
        }
コード例 #25
0
        public static List <MaterialPermit> LoadList(EPVDatabase database, Unit unit,
                                                     DateTime dateFrom, DateTime dateTo, ISystemUser user)
        {
            List <MaterialPermit> documentList = new List <MaterialPermit>();


            QueryParameters parameters = new QueryParameters("unit", unit.Id);

            parameters.Add("dateFrom", dateFrom);
            parameters.Add("dateTo", dateTo);
            parameters.Add("userId", user.Id);

            using (DbDataReader reader = database.ExecuteReader(LoadListQuery, parameters))
            {
                while (reader.Read())
                {
                    documentList.Add(new MaterialPermit(reader));
                }

                reader.Close();
            }

            return(documentList);
        }