Exemplo n.º 1
0
        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;
        }
Exemplo n.º 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);
            }

            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);
        }
        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);
        }
Exemplo n.º 4
0
        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);
        }