コード例 #1
0
        public static Changes deserialise(List <byte> buffer)
        {
            int    changeSetId = Utilites.readIntFromBuffer(buffer);
            int    type        = Utilites.readIntFromBuffer(buffer);
            string tableName   = Utilites.readStringFromBuffer(buffer);
            byte   isValue     = buffer[0];

            buffer.RemoveAt(0);

            Object oldValue = null, newValue = null;

            if (isValue == 1)
            {
                if (tableName == "Предприятия")
                {
                    oldValue = FactoryInfo.deserialise(buffer);
                }
            }

            isValue = buffer[0];
            buffer.RemoveAt(0);

            if (isValue == 1)
            {
                if (tableName == "Предприятия")
                {
                    newValue = FactoryInfo.deserialise(buffer);
                }
            }

            return(new Changes(changeSetId, type, oldValue, newValue, tableName));
        }
コード例 #2
0
        private void DeleteSotrPredpr(List <byte> buffer)
        {
            FactoryInfo factoryInfo = FactoryInfo.deserialise(buffer);
            User        user        = User.deserialise(buffer);

            db.DeleteFactoryUser(factoryInfo, user);
        }
コード例 #3
0
        public void DeleteFactoryUser(FactoryInfo factory, User user)
        {
            string query = "delete from sotrpredpr where sotrID = " + user.userID + " and predprID = " + factory.predprID + ";";

            SqlCommand command = new SqlCommand(query, conn);

            command.ExecuteNonQuery();
        }
コード例 #4
0
        public void DeleteFactory(FactoryInfo factory)
        {
            string query = "delete from predpr where predprID = " + factory.predprID + ";";

            SqlCommand command = new SqlCommand(query, conn);

            command.ExecuteNonQuery();
        }
コード例 #5
0
        private void AddFactoryUser(List <byte> buffer)
        {
            User        user = User.deserialise(buffer);
            FactoryInfo info = FactoryInfo.deserialise(buffer);

            user.factoryID = info.predprID;

            db.AddToTable(user, "Сотрудники-Предприятия");
        }
コード例 #6
0
        public void AddToChangesTable(Object oldValue, Object newValue, int operationsType, string table, int prepdrID)
        {
            if (table == "Предприятия")
            {
                FactoryInfo oldV = (FactoryInfo)oldValue;
                FactoryInfo newV = (FactoryInfo)newValue;

                if (operationsType == 0)
                {
                    AddToTable(newV, table);
                    string query = "insert into TablesChanges(newValue, type, predprID, tableName) values(" + newV.predprID +
                                   ", 0, " + prepdrID + ",\'" + table + "\', 0);";
                    SqlCommand command = new SqlCommand(query, conn);
                    command.ExecuteNonQuery();
                }
            }
        }
コード例 #7
0
        private void AddFactory(List <byte> buffer)
        {
            int         userType   = Utilites.readIntFromBuffer(buffer);
            int         predprID   = Utilites.readIntFromBuffer(buffer);
            FactoryInfo newFactory = FactoryInfo.deserialise(buffer);

            db.AddToTable(newFactory, "Предприятия");

            //if (userType == 1)
            //{
            //    db.AddToTable(newFactory, "Предприятия");
            //}
            //else
            //{
            //    db.AddToChangesTable(null, newFactory, 0, "Предприятия", predprID);
            //}
        }
コード例 #8
0
        public void AddToTable(Object newValue, string tableName, object additionalValues = null)
        {
            string query = null;

            if (tableName == "Предприятия")
            {
                FactoryInfo factory = (FactoryInfo)newValue;
                query = "insert into predpr(predprID, name, address, isValid) values(" + factory.predprID + ", \'" + factory.name
                        + "\', \'" + factory.address + "\', 1);";
                string password = (string)additionalValues;
            }

            if (tableName == "Сотрудники")
            {
                User user = (User)newValue;
                query = "insert into sotr values(" + user.userID + ", \'" + user.name
                        + "\', \'" + user.surname + "\', \'" + user.patronymic + "\', \'" + user.passportSeries
                        + "\', \'" + user.passportNumber + "\', \'" + user.gender + "\', \'" +
                        user.birthday.ToString("yyyy-MM-dd") + "\', " + user.userType + ", \'" + user.job + "\');";

                string     password = (string)additionalValues;
                SqlCommand _command = new SqlCommand(query, conn);
                _command.ExecuteNonQuery();
                query = "insert into sign values(" + user.userID + ", \'" + password + "\');";
            }

            if (tableName == "Сотрудники-Предприятия")
            {
                User user = (User)newValue;
                query = "insert into sotrpredpr values(" + user.userID + "," + user.factoryID + ");";
            }

            SqlCommand command = new SqlCommand(query, conn);

            command.ExecuteNonQuery();
        }
コード例 #9
0
        private void DeleteFactory(List <byte> buffer)
        {
            FactoryInfo deletingFactory = FactoryInfo.deserialise(buffer);

            db.DeleteFactory(deletingFactory);
        }