Пример #1
0
        public bool UpdateLimits(ReferenceModel reference)
        {
            if (reference == null)
            {
                throw new Exception("Unable To Update Reference, Current Reference null");
            }
            using (OleDbConnection myConnection = new OleDbConnection())
            {
                myConnection.ConnectionString = _databaseConnection;
                var queryString = "update LAD8N SET Weighing_Nominal= @a,Weighing_Minimum=@b,Weighing_Maximum=@c where Reference=@d";
                try
                {
                    OleDbCommand command = new OleDbCommand(queryString, myConnection);
                    command.Parameters.AddWithValue("@a", reference.WeighingNominal);
                    command.Parameters.AddWithValue("@b", reference.WeighingMinimal);
                    command.Parameters.AddWithValue("@c", reference.WeighingMaximal);
                    command.Parameters.AddWithValue("@d", reference.Reference);

                    command.Connection.Open();
                    var exec = command.ExecuteNonQuery();
                    command.Connection.Close();
                    command.Dispose();
                    return(true);
                }
                catch (Exception e)
                {// ignored
                    MessageBox.Show(e.ToString());
                }
            }
            return(false);
        }
Пример #2
0
        public CodeSoftLabel(LabelType labelType, Settings settings, ReferenceModel reference)
        {
            InitializeComponent();
            _referenceModel = reference;
            _labelType      = labelType;
            _setting        = settings;
            switch (labelType)
            {
            case LabelType.Individual:
                _topOffset             = settings.LabelIndividualOffsetTop;
                _leftOffset            = settings.LabelIndividualOffsetLeft;
                _printer               = settings.IndividualPrinter;
                _fileLabelTemplatePath = settings.LabelLocation + @"\" + reference.LabelTempate + ".lab";
                break;

            case LabelType.Group:
                _topOffset             = settings.LabelGroupOffsetTop;
                _leftOffset            = settings.LabelGroupOffsetLeft;
                _printer               = settings.IndividualPrinter;
                _fileLabelTemplatePath = settings.LabelLocation + @"\" + reference.GroupingLabelTempate + ".lab";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(labelType), labelType, null);
            }
        }
Пример #3
0
        public Weighing(Settings settings, ReferenceModel reference)
        {
            InitializeComponent();
            _settings       = settings;
            _referenceModel = reference;
            LoadAll();

            try
            {
                WeighingDataUpdated  -= OnWeighingDataUpdated;
                WeighingDataInRange  -= OnWeighingDataInRange;
                WeighingDataOutRange -= OnWeighingDataOutRange;
            }
            catch
            {
                // ignored
            }
            WeighingDataUpdated  += OnWeighingDataUpdated;
            WeighingDataInRange  += OnWeighingDataInRange;
            WeighingDataOutRange += OnWeighingDataOutRange;
        }
Пример #4
0
        private void ReferenceDataOnReferenceDataIsLoaded(ReferenceModel model)
        {
            lblGroupSize.Text = model.QuantityGroup.ToString("000");
            txtArticle.Text   = model.ArticleNumber;
            txtEan13.Text     = Ean13.CalculateChecksumDigit(model.ArticleNumber);

            _groupingLabel = new CodeSoftLabel(LabelType.Group, Settings, _referenceData.Reference);
            _groupingLabel.InitMine();
            _individualLabel = new CodeSoftLabel(LabelType.Individual, Settings, _referenceData.Reference);
            _individualLabel.InitMine();


            docGroupPrev.Image = _groupingLabel.ResizeIfNeeded(_groupingLabel.RealSizeImage, docGroupPrev.Width,
                                                               docGroupPrev.Height);
            docIndiPrev.Image = _individualLabel.ResizeIfNeeded(_individualLabel.RealSizeImage, docIndiPrev.Width,
                                                                docIndiPrev.Height);
            try
            {
                if (_weighingStation != null)
                {
                    _weighingStation.WeighingDataUpdated  -= WeighingStationOnWeighingDataUpdated;
                    _weighingStation.WeighingDataInRange  -= WeighingStationOnWeighingDataInRange;
                    _weighingStation.WeighingDataOutRange -= WeighingStationOnWeighingDataOutRange;
                    _weighingStation.WeighingBoxRemoved   -= WeighingStationOnWeighingBoxRemoved;
                }
            }
            finally
            {
                _weighingStation = new Weighing(Settings, _referenceData.Reference);
                _weighingStation.WeighingDataUpdated  += WeighingStationOnWeighingDataUpdated;
                _weighingStation.WeighingDataInRange  += WeighingStationOnWeighingDataInRange;
                _weighingStation.WeighingDataOutRange += WeighingStationOnWeighingDataOutRange;
                _weighingStation.WeighingBoxRemoved   += WeighingStationOnWeighingBoxRemoved;
                lblHighLimit.Text = _weighingStation.UpperWeightPerBox.ToString("00000");
                lblLowLimit.Text  = _weighingStation.LowerWeightPerBox.ToString("00000");
            }
        }
Пример #5
0
        public bool LoadByReferenceName(string reference)
        {
            if (Reference != null)
            {
                throw new Exception("Unable To Load Reference, Current Reference Is not Closed!");
            }
            if (reference == "")
            {
                return(false);
            }

            using (OleDbConnection myConnection = new OleDbConnection())
            {
                myConnection.ConnectionString = _databaseConnection;
                var queryString = "select * from LAD8N where Reference='" + reference + "'";

                OleDbCommand command = new OleDbCommand(queryString, myConnection);
                try
                {
                    command.Connection.Open();
                }
                catch
                {
                    MessageBox.Show(@"Error Loading Database");
                }
                OleDbDataReader reader = command.ExecuteReader();
                if (reader == null)
                {
                    return(false);
                }
                if (reader.Read())
                {
                    Reference = new ReferenceModel
                    {
                        ArticleNumber = reader[0].ToString(),
                        Reference     = reader[1].ToString(),
                        Pokayoke      = reader[10].ToString(),
                        QuantityGroup =
                            Convert.ToInt32(reader[9].ToString().Trim() == "" ? "0" : reader[9].ToString().Trim()),
                        QuantityIndividual =
                            Convert.ToInt32(reader[8].ToString().Trim() == "" ? "0" : reader[8].ToString().Trim()),
                        QuantityLot =
                            Convert.ToInt32(reader[11].ToString().Trim() == "" ? "0" : reader[11].ToString().Trim()),
                        Bitmap               = reader[2].ToString(),
                        English              = reader[3].ToString(),
                        France               = reader[4].ToString(),
                        German               = reader[5].ToString(),
                        Spain                = reader[6].ToString(),
                        LabelTempate         = reader[7].ToString(),
                        GroupingLabelTempate = reader[15].ToString(),
                        WeighingNominal      =
                            Convert.ToInt32(reader[12].ToString().Trim() == "" ? "0" : reader[12].ToString().Trim()),
                        WeighingMinimal =
                            Convert.ToInt32(reader[13].ToString().Trim() == "" ? "0" : reader[13].ToString().Trim()),
                        WeighingMaximal =
                            Convert.ToInt32(reader[14].ToString().Trim() == "" ? "0" : reader[14].ToString().Trim())
                    };
                }
                else
                {
                    return(false);
                }
            }
            IsLoaded = true;
            ReferenceDataIsLoaded?.Invoke(Reference);
            return(true);
        }