Exemple #1
0
        private void _btnAdd_Click(object sender, EventArgs e)
        {
            var batch     = _cbBatch.GetSelectedDataRow() as BatchViewModel;
            var product   = _cbProducts.GetSelectedDataRow() as Product;
            var worker    = _cbWorkers.GetSelectedDataRow() as Worker;
            var procedure = _cbProcedure.GetSelectedDataRow() as Procedure;
            var amount    = (int)_seExpectedAmount.Value;
            var date      = _deStartTime.DateTime;

            if (!_cbProcedure.Validate(procedure == null) ||
                !_cbProducts.Validate(product == null) ||
                !_cbWorkers.Validate(worker == null) ||
                !_seExpectedAmount.Validate(amount <= 0) ||
                !_deStartTime.Validate(date < new DateTime(1990, 1, 1)))
            {
                return;
            }

            if (_isAddingNew)
            {
                //var procedures = _chkProcedures.
                var produceRecord = new ProduceRecord
                {
                    Worker    = worker,
                    Batch     = null,    //batch.Id,
                    Product   = product, // batch.ProductId,
                    Procedure = procedure,
                    Amount    = amount,
                    Date      = date,
                };
                _service.AddProduceRecord(produceRecord);
                OnDataSaved(produceRecord);
            }
            else
            {
                var oldProduceRecord = _service.GetProduceRecord(_produceRecordId);

                oldProduceRecord.Amount    = amount;
                oldProduceRecord.Batch     = null;
                oldProduceRecord.Product   = product;
                oldProduceRecord.Worker    = worker;
                oldProduceRecord.Procedure = procedure;
                _deStartTime.DateTime      = date;

                _service.SaveChanges();
                OnDataSaved(oldProduceRecord);
            }


            if (_chkIsBatchAddModel.Checked)
            {
                SetAsFocused();
                ResetForm();
            }
            else
            {
                DialogResult = DialogResult.OK;
            }
        }
Exemple #2
0
        /// <summary>
        /// 新增生产记录实体
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool AddProduceRecord(ProduceRecord item)
        {
            var obj = DatabaseProvider.Insert(item);

            if (obj != null)
            {
                return(Convert.ToInt32(obj) > 0);
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// 修改生产记录实体
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool UpdateProduceRecord(ProduceRecord item)
        {
            var obj = DatabaseProvider.Update(item);

            return(Convert.ToInt32(obj) > 0);
        }
Exemple #4
0
 public void AddProduceRecord(ProduceRecord produceRecord)
 {
     _dbContext.ProduceRecords.Add(produceRecord);
     _dbContext.SaveChanges();
 }