public override void Save()
        {
            if (Check() == false)
            {
                return;
            }

            _entity = new FishEntity.HomemadeStorageEntity();
            _en     = new FishEntity.ProductEntity();
            GetEntity();

            _entity.createman  = FishEntity.Variable.User.username;
            _entity.createtime = DateTime.Now;
            _entity.modifyman  = _entity.createman;
            _entity.modifytime = _entity.createtime;

            _entity.code = FishBll.Bll.SequenceUtil.GetHomemadeStorageSequence();
            while (_bll.Exists(_entity.code))
            {
                _entity.code = FishBll.Bll.SequenceUtil.GetHomemadeStorageSequence();
            }

            int id = _bll.Add(_entity);

            _bll.Add1(_en);
            if (id > 0)
            {
                _entity.id   = id;
                txtCode.Text = _entity.code;
                //更新 鱼粉资料 的自制仓 成本,数量 , 重量
                //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                //decimal cost = _entity.unitprice.Value * _entity.netweight.Value;
                //decimal weight = _entity.netweight.Value;
                //bool isok = productBll.UpdateHomemade(_entity.productid.Value , weight , cost, _entity.packages.Value);

                //更新 鱼粉资料的 自制仓 入库重量,数量,采购单价,销售单价,入库时间等信息
                FishBll.Bll.ProductExBll productExBll = new FishBll.Bll.ProductExBll();
                bool isok = productExBll.UpdateHomeMadeInfo(_entity.productid.Value, _entity.storageweight, _entity.storagequantity, _entity.selfprice, _entity.saleprice, _entity.storagetime.Value.ToString("yyyy/MM/dd"));

                //tmiCancel.Visible = false;
                //tmiSave.Visible = false;
                //tmiAdd.Visible = true;
                //tmiModify.Visible = true;
                //tmiDelete.Visible = true;
                //tmiQuery.Visible = true;
                //tmiPrevious.Visible = true;
                //tmiNext.Visible = true;
                //txtfishname.Enabled = false;
                //txtFishCode.Enabled = false;
                ControlButtomRoles();

                MessageBox.Show("新增成功。");
            }
            else
            {
                MessageBox.Show("新增失败。");
            }
            return;
        }
Beispiel #2
0
        public override int Delete()
        {
            if (_entity == null)
            {
                return(0);
            }

            string msg = string.Format("你确定要删除提货单号为【{0}】的记录吗?", _entity.code);

            if (MessageBox.Show(msg, "询问", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return(0);
            }

            _bll.Delete(_entity.id);
            FishBll.Bll.LoadingDetailBll          detailbll = new FishBll.Bll.LoadingDetailBll();
            List <FishEntity.LoadingDetailEntity> details   = detailbll.GetDetailOfBill(_entity.id);

            if (details != null)
            {
                FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                foreach (FishEntity.LoadingDetailEntity item in details)
                {
                    //FishEntity.ProductEntity product = productBll.GetModel(item.productid);
                    //if (product == null) continue;
                    //if (product.state == FishEntity.Constant.STATE_SELFMAKE.ToString ())
                    //{
                    //    productBll.UpdateHomemadeWeightQuantity(item.productid , item.tons, item.packages );
                    //}
                    //else
                    //{
                    //    productBll.UpdateRemainWeightQuantity(item.productid , item.tons, item.packages);
                    //}

                    FishBll.Bll.ProductExBll productexbll = new FishBll.Bll.ProductExBll();
                    productexbll.UpdateSaleInfo(item.productid, -item.tons, -item.packages);
                    FishBll.Bll.ContractDetailBll contractdetailbll = new FishBll.Bll.ContractDetailBll();
                    contractdetailbll.UpdateContractWeight(item.contractid, item.contractdetailid, -item.tons, -item.packages);
                }
            }
            detailbll.DeleteByMid(_entity.id);

            ClearText();

            Query();

            return(1);
        }
        public override int Delete()
        {
            if (_entity == null)
            {
                return(0);
            }

            string msg = string.Format("你确定要删除自制仓入库单号为【{0}】的记录吗?", _entity.code);

            if (MessageBox.Show(msg, "询问", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return(0);
            }

            bool isok = _bll.Delete(_entity.id);

            if (isok)
            {
                //更新 鱼粉 的自制仓 成本,数量 , 重量
                //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                //decimal cost = - _entity.packages.Value * _entity.unitprice.Value;
                //decimal weight = - _entity.netweight.Value;
                //int number = -_entity.packages.Value;
                //isok = productBll.UpdateHomemade(_entity.productid.Value, weight , cost, number);


                //更新鱼粉资料 的自制仓入库重量数量,采购单价=0,销售单价=0,入库时间=""
                FishBll.Bll.ProductExBll productexBll = new FishBll.Bll.ProductExBll();
                decimal storageweight   = -_entity.storageweight;
                int     storagequantity = -_entity.storagequantity;
                decimal selfprice       = 0.00m;
                decimal saleprice       = 0.00m;
                string  storagetime     = string.Empty;
                productexBll.UpdateHomeMadeInfo(_entity.productid.Value, storageweight, storagequantity, selfprice, saleprice, storagetime);

                //

                //
                _entity = null;
                ClearContent();
                Query();
            }
            else
            {
            }
            return(1);
        }
Beispiel #4
0
        protected void UpdateProductCount(int productId, decimal weight, int quanity)
        {
            //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
            //FishEntity.ProductEntity product = productBll.GetModel(productId);
            //if (product.state == FishEntity.Constant.STATE_SELFMAKE.ToString())
            //{
            //    productBll.UpdateHomemadeWeightQuantity(productId, weight, quanity);
            //}
            //else
            //{
            //    productBll.UpdateRemainWeightQuantity(productId, weight, quanity);
            //}


            FishBll.Bll.ProductExBll productexbll = new FishBll.Bll.ProductExBll();
            productexbll.UpdateSaleInfo(productId, weight, quanity);
        }
 protected void UpdateProductCount(int productId, decimal weight, int quanity)
 {
     FishBll.Bll.ProductExBll productexbll = new FishBll.Bll.ProductExBll();
     productexbll.UpdateSaleInfo(productId, weight, quanity);
 }
        protected void AddDetails(int mid, bool isAdd, out decimal cost_hj, int n_solutionid, int s_solutionid)
        {
            cost_hj = 0;
            List <FishEntity.FoodOutDetailEntityVO> listNews   = GetDetails(mid);
            List <FishEntity.FoodOutDetailEntityVO> listsource = null;

            FishBll.Bll.ProductBll   productBll   = new FishBll.Bll.ProductBll();
            FishBll.Bll.ProductExBll productExBll = new FishBll.Bll.ProductExBll();

            if (isAdd == false)
            {
                listsource = _detailBll.GetDetailByMid(mid);
                if (listsource != null)
                {
                    //foreach (FishEntity.FoodOutDetailEntityVO item in listsource)
                    //{
                    //    bool isExist = listNews.Exists((i) => { return i.id == item.id; });
                    //    if (isExist) continue;

                    //    productBll.UpdateHomemadeWeightQuantityCost(item.productid, item.tons, item.package , item.tons * item.homemadeunitprice );
                    //    bool isDelte = _detailBll.Delete(item.id);
                    //}

                    List <FishEntity.FoodOutDetailEntityVO> solution = listsource.FindAll((i) => { return(i.solutionid == s_solutionid); });
                    if (solution != null)
                    {
                        foreach (FishEntity.FoodOutDetailEntityVO detail in solution)
                        {
                            if (/*detail.no < FinishNo &&*/ detail.productid > 0)
                            {
                                productExBll.UpdateHomeMadeInfo(detail.productid, detail.tons, detail.package);
                            }
                            else if (/*detail.no == FinishNo &&*/ detail.productid > 0)
                            {
                                productExBll.UpdateHomeMadeInfo(detail.productid, -detail.tons, -detail.package);
                            }
                        }
                        _detailBll.DeleteByMid(mid);
                    }
                }
            }

            foreach (FishEntity.FoodOutDetailEntityVO item in listNews)
            {
                cost_hj += item.cost;

                //if (item.id == 0)
                //{
                int detailId = _detailBll.Add(item);
                if (detailId > 0 && item.solutionid == n_solutionid)
                {
                    //减少 明细中鱼粉自制仓 吨位,包数,成本
                    //productBll.UpdateHomemadeWeightQuantityCost(item.productid, -item.tons, -item.package , -item.tons * item.homemadeunitprice );
                    item.id = detailId;
                    if (/*item.no < FinishNo &&*/ item.productid > 0)
                    {
                        productExBll.UpdateHomeMadeInfo(item.productid, -item.tons, -item.package);
                    }
                    else if (/*item.no == FinishNo &&*/ item.productid > 0)
                    {
                        productExBll.UpdateHomeMadeInfo(item.productid, item.tons, item.package);
                    }
                }
            }

            SetDetail(listNews);
        }
        public override int Modify()
        {
            if (_entity == null)
            {
                return(0);
            }
            if (Check() == false)
            {
                return(0);
            }

            int     s_productId = _entity.productid.Value;
            decimal s_weight    = _entity.netweight.Value;
            decimal s_cost      = _entity.unitprice.Value * _entity.netweight.Value;
            int     s_packages  = _entity.packages.Value;

            decimal s_storageweight   = _entity.storageweight;
            int     s_storagequantity = _entity.storagequantity;


            GetEntity();

            int     d_productId = _entity.productid.Value;
            decimal d_weight    = _entity.netweight.Value;
            decimal d_cost      = _entity.unitprice.Value * _entity.netweight.Value;
            int     d_packages  = _entity.packages.Value;

            decimal d_storageweight   = _entity.storageweight;
            int     d_storagequantity = _entity.storagequantity;

            decimal weight   = d_weight - s_weight;
            decimal cost     = d_cost - s_cost;
            int     packages = d_packages - s_packages;

            decimal storageweight   = d_storageweight - s_storageweight;
            int     storagequantity = d_storagequantity - s_storagequantity;

            _entity.modifyman  = FishEntity.Variable.User.username;
            _entity.modifytime = DateTime.Now;

            bool isok = _bll.Update(_entity);

            if (isok)
            {
                if (s_productId == d_productId)
                {//当鱼粉ID没有改变时, 更新 鱼粉的状态为 “自营”,重量,数量,成本
                    weight   = d_weight - s_weight;
                    packages = d_packages - s_packages;
                    cost     = d_cost - s_cost;
                    //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                    //isok = productBll.UpdateHomemade(_entity.productid.Value, weight, cost, packages);

                    //单鱼粉id没有改变时,更新鱼粉自制仓入库重量数量,采购单价,销售单价,入库时间
                    FishBll.Bll.ProductExBll productExBll = new FishBll.Bll.ProductExBll();
                    isok = productExBll.UpdateHomeMadeInfo(_entity.productid.Value, storageweight, storagequantity, _entity.selfprice, _entity.saleprice, _entity.storagetime.Value.ToString("yyyy/MM/dd"));
                }
                else
                {//当鱼粉id改变时,先调整原鱼粉资料的自制仓 成本,数量 , 重量,再调整新鱼粉资料的自制仓 成本,数量 , 重量
                 //TODO 暂时屏蔽 这种情况。

                    //weight = -s_weight;
                    //packages = -s_packages;
                    //cost = -s_cost;

                    //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                    //productBll.UpdateHomemade(s_productId, weight, cost, packages);

                    //weight = d_weight;
                    //packages = d_packages;
                    //cost = d_cost;

                    //isok = productBll.UpdateHomemade( d_productId , weight, cost, packages);
                }

                MessageBox.Show("修改成功。");
            }
            else
            {
                MessageBox.Show("修改失败。");
            }
            return(1);
        }
Beispiel #8
0
        protected bool Check()
        {
            errorProvider1.Clear();
            bool    isok     = true;
            int     tempInt1 = 0;
            int     tempInt2 = 0;
            decimal temp2    = 0;

            if (int.TryParse(txtNumber.Text, out tempInt1) == false)
            {
                errorProvider1.SetError(txtNumber, "请输入正确数字。");
                isok = false;
            }
            else
            {
                if (tempInt1 < 1)
                {
                    isok = false;
                    errorProvider1.SetError(txtNumber, "请输入大于零的件数。");
                }
            }

            if (int.TryParse(txtActualNum.Text, out tempInt2) == false)
            {
                errorProvider1.SetError(txtActualNum, "请输入正确数字。");
                isok = false;
            }
            else
            {
                if (tempInt2 < 1)
                {
                    isok = false;
                    errorProvider1.SetError(txtActualNum, "请输入大于零的件数。");
                }
            }

            if (tempInt1 < tempInt2)
            {
                errorProvider1.SetError(txtActualNum, "实际件数必须小于等于件数。");
                isok = false;
            }

            if (decimal.TryParse(txtTon.Text, out temp2) == false)
            {
                errorProvider1.SetError(txtTon, "请输入正确的数字。");
                isok = false;
            }
            else
            {
                if (temp2 <= 0)
                {
                    isok = false;
                    errorProvider1.SetError(txtTon, "请输入大于零的吨数。");
                }
            }

            if (true == string.IsNullOrEmpty(txtCompanyCode.Text))
            {
                errorProvider1.SetError(txtCompanyName, "请选择委托单位。");
                isok = false;
            }
            if (true == string.IsNullOrEmpty(txtFishCode.Text))
            {
                errorProvider1.SetError(txtFishName, "请选择鱼粉。");
                isok = false;
            }

            int productid = 0;

            if (txtFishCode.Tag != null && int.TryParse(txtFishCode.Tag.ToString(), out productid))
            {
                productid = int.Parse(txtFishCode.Tag.ToString());
                //FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll();
                //FishEntity.ProductEntity model = productBll.GetModel(productid);
                //if (model != null && (model.price == null || model.price.Value <= 0))
                //{
                //    isok = false;
                //    MessageBox.Show("鱼粉的购买单价必须大于零,请修改鱼粉资料中的购买单价。");
                //}
                FishBll.Bll.ProductExBll   productexBll = new FishBll.Bll.ProductExBll();
                FishEntity.ProductExEntity model        = productexBll.GetModel(productid);
                if (model != null && (model.confirmrmb.HasValue == false || model.confirmrmb.Value <= 0))
                {
                    isok = false;
                    MessageBox.Show("鱼粉的确盘人民币购买价格必须大于零,请修改鱼粉资料中的确盘人民币购买价格。");
                }
            }

            return(isok);
        }