Пример #1
0
        public override void Save()
        {
            FishEntity.EnterWarehouseReceipts _fish = new FishEntity.EnterWarehouseReceipts();
            _fish.Code = FishBll.Bll.SequenceUtil.GetEnterWarehouseReceipts();
            decimal temp = 0;

            _fish.Requester = txtRequester.Text.Trim();
            _fish.Shipname  = txtShipname.Text.Trim();
            decimal.TryParse(txttonnage.Text, out temp);
            _fish.Tonnage    = temp;
            _fish.TName      = cmbtName.SelectedValue == null ? string.Empty : cmbtName.SelectedValue.ToString().Trim();
            _fish.Billnumber = txtBillnumber.Text;
            decimal.TryParse(txtNumberOfPieces.Text, out temp);
            _fish.NumberOfPieces = temp;
            _fish.Unpackingdate  = dtpUnpackingdate.Value;
            decimal.TryParse(txtactualnumber.Text, out temp);
            _fish.Actualnumber    = temp;
            _fish.StorageLocation = txtStorageLocation.Text.Trim();
            _fish.Position        = txtposition.Text.Trim();
            _fish.Remarks         = txtRemarks.Text.Trim();
            _fish.Createtime      = DateTime.Now;
            _fish.Createman       = FishEntity.Variable.User.username;
            _fish.Modifytime      = DateTime.Now;
            _fish.Modifyman       = FishEntity.Variable.User.username;
            _fish.TO         = txtTO.Text.Trim();
            _fish.Zhuangjiao = txtZhuangjiao.Text;
            _fish.ContractNo = txtContractNo.Text;
            _fish.TEL        = txtTEL.Text.Trim();
            _fish.ANTI       = txtANTI.Text.Trim();
            _fish.FAX        = txtFAX.Text.Trim();

            FishBll.Bll.EnterWarehouseReceiptsBll bll = new FishBll.Bll.EnterWarehouseReceiptsBll();

            bool isok = bll.Exists(_fish.Code);

            while (isok)
            {
                _fish.Code = FishBll.Bll.SequenceUtil.GetEnterWarehouseReceipts();
                isok       = bll.Exists(_fish.Code);
            }
            int id = bll.Add(_fish);

            if (id > 0)
            {
                _fish.Id          = id;
                tmiQuery.Visible  = false;
                tmiDelete.Visible = false;
                tmiModify.Visible = false;
                tmiAdd.Visible    = false;
                tmiSave.Visible   = true;
                tmiCancel.Visible = true;
                MessageBox.Show("添加成功。");
                txtcode.Text = _fish.Code.ToString();
            }
            else
            {
                // txtCode.Text = _fish.Code;
                MessageBox.Show("添加失败。");
            }
        }
        public override void Save()
        {
            if (Check( ) == false)
            {
                return;
            }

            FishEntity.EnterWarehouseReceipts _fish = new FishEntity.EnterWarehouseReceipts();

            int temp = 0;

            _entity.anti = txtanti.Text;
            //_entity . code = txtCode . Text;
            _entity.codeNum         = txtcodeNum.Text;
            _entity.codeNumContract = txtcodeNumContract.Text;
            _entity.deliverybills   = txtdeliverybills.Text;
            _entity.enUntil         = txtenUntil.Text;
            _entity.fat             = txtfat.Text;
            _entity.fax             = txtfax.Text;
            _entity.fishId          = txtfishId.Text;
            _entity.hf          = txthf.Text;
            _entity.location    = txtlocation.Text;
            _entity.locationDis = txtlocationDis.Text;
            int.TryParse(txtnumber.Text, out temp);
            _entity.number = temp;
            temp           = 0;
            int.TryParse(txtnumOfPack.Text, out temp);
            _entity.numOfPack  = temp;
            _entity.protein    = txtprotein.Text;
            _entity.remark     = txtremark.Text;
            _entity.sand       = txtsand.Text;
            _entity.shipno     = txtshipno.Text;
            _entity.shy        = txtshy.Text;
            _entity.TEL        = txtTEL.Text;
            _entity.TO         = txtTO.Text;
            _entity.TVN        = txtTVN.Text;
            _entity.water      = txtwater.Text;
            _entity.za         = txtza.Text;
            _entity.brand      = cmbbrand.Text;
            _entity.country    = cmbcountry.Text;
            _entity.proName    = cmbproName.Text;
            _entity.qualitySpe = cmbqualitySpe.Text;
            _entity.downDate   = dtdownDate.Value;

            decimal te = 0;

            decimal.TryParse(txtHeight.Text, out te);
            _entity.height = te;

            FishBll.Bll.EnterWarehouseReceiptsBll bll = new FishBll.Bll.EnterWarehouseReceiptsBll();

            bool isok = bll.Exists(_entity.code);

            while (isok)
            {
                _entity.code = FishBll.Bll.SequenceUtil.GetEnterWarehouseReceipts();
                isok         = bll.Exists(_entity.code);
            }
            int id = bll.Add(_fish);

            if (id > 0)
            {
                _entity.id        = id;
                tmiQuery.Visible  = false;
                tmiDelete.Visible = false;
                tmiModify.Visible = false;
                tmiAdd.Visible    = false;
                tmiSave.Visible   = true;
                tmiCancel.Visible = true;
                MessageBox.Show("添加成功。");
                txtCode.Text = _entity.code.ToString();
            }
            else
            {
                // txtCode.Text = _fish.Code;
                MessageBox.Show("添加失败。");
            }
        }