Exemplo n.º 1
0
        public override void Save()
        {
            // QueryFishiId();
            //if (_bll.ExistsFishId(txtfishId.Text))
            //{
            //    MessageBox.Show("鱼粉id录入重复 !");
            //    return;
            //}
            if (check() == false)
            {
                return;
            }

            if (getValue( ) == false)
            {
                return;
            }

            if (_bll.Exists(_model.codeNum))
            {
                MessageBox.Show("请修改");
                return;
            }
            _model.id = _bll.Add(_model);
            if (_model.id > 0)
            {
                MessageBox.Show("保存成功");
                txtCodeNum.Tag  = _model.id;
                tmiSave.Visible = false;
            }
            else
            {
                MessageBox.Show("保存失败");
            }

            base.Save();
        }
        public override void Save( )
        {
            errorProvider1.Clear( );
            if (string.IsNullOrEmpty(txtCodeNum.Text))
            {
                errorProvider1.SetError(txtCodeNum, "不可为空");
                return;
            }
            if (string.IsNullOrEmpty(txtfishId.Text))
            {
                errorProvider1.SetError(txtfishId, "不可为空");
                return;
            }
            outResult = 0M;
            if (!string.IsNullOrEmpty(txtbondPro.Text) && decimal.TryParse(txtbondPro.Text, out outResult) == false)
            {
                errorProvider1.SetError(txtbondPro, "请重新填写");
                return;
            }
            outResult = 0M;
            if (!string.IsNullOrEmpty(txtheight.Text) && decimal.TryParse(txtheight.Text, out outResult) == false)
            {
                errorProvider1.SetError(txtheight, "请重新填写");
                return;
            }
            outResult = 0M;
            if (!string.IsNullOrEmpty(txtprice.Text) && decimal.TryParse(txtprice.Text, out outResult) == false)
            {
                errorProvider1.SetError(txtprice, "请重新填写");
                return;
            }
            outResult = 0M;
            if (!string.IsNullOrEmpty(txtrebate.Text) && decimal.TryParse(txtrebate.Text, out outResult) == false)
            {
                errorProvider1.SetError(txtrebate, "请重新填写");
                return;
            }
            outResult = 0M;
            if (!string.IsNullOrEmpty(txtpriceMY.Text) && decimal.TryParse(txtpriceMY.Text, out outResult) == false)
            {
                errorProvider1.SetError(txtpriceMY, "请重新填写");
                return;
            }
            getValue( );
            if (state.Equals("add"))
            {
                _model.id = _bll.Add(_model);
            }
            else
            {
                _model.id = _bll.Edit(_model);
            }
            if (_model.id > 0)
            {
                MessageBox.Show("保存成功");
                if (state.Equals("add"))
                {
                    txtCodeNum.Tag = _model.id;
                }
            }
            else
            {
                MessageBox.Show("保存失败");
            }

            base.Save( );
        }