コード例 #1
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var its = new LHItems
            {
                FCode  = txtFCode.Text.Trim(),
                FName  = txtFName.Text.Trim(),
                FSpec  = txtFSpec.Text.Trim(),
                FSpell = ChineseSpell.MakeSpellCode(txtFName.Text.Trim(), "",
                                                    SpellOptions.FirstLetterOnly).ToUpper(),
                FFlag = 1,

                //分类
                FCateId    = "2000",
                FSubCateId = ProjectItem.FId,

                FCompanyId = CurrentUser.AccountComId,
                FGroupNum  = txtFGroupNum.Text,
                FMemo      = txtFMemo.Text.Trim(),
                FIsLiquid  = ddlFIsLiquid.SelectedValue,
                FRack      = txtFRack.Text.Trim(),
                //单位
                FUnit          = ddlUnit.SelectedValue,
                FPurchasePrice = Convert.ToDecimal(txtFPurchasePrice.Text.Trim()),
                FSalesPrice    = Convert.ToDecimal(txtFSalesPrice.Text.Trim()),
                //FPieceWork1 = 0,//Convert.ToDecimal(txtFPieceWork.Text.Trim()),
                FQty        = Convert.ToDecimal(txtFQty.Text.Trim()),
                cinvdefine1 = txtcinvdefine1.Text,
                FPieceWork1 = Convert.ToDecimal(txtFPieceWork1.Text.Trim())
            };

            //  包装物问题
            if (!ddlBottleNum.SelectedValue.Equals("-1"))
            {
                var bottle = ItemsMapBottleService.Where(p => p.FCode == ProductItem.FCode && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();
                if (bottle != null)
                {
                    bottle.FBottleCode = ddlBottleNum.SelectedValue;
                    ItemsMapBottleService.SaveChanges();
                }
                else
                {
                    var bot = new LHItemsMapBottle
                    {
                        FCode       = ProductItem.FCode,
                        FBottleCode = ddlBottleNum.SelectedValue
                    };

                    ItemsMapBottleService.Add(bot);
                }
            }

            return(ItemsService.Add(its));
        }
コード例 #2
0
        /// <summary>
        ///     提交编辑
        /// </summary>
        private bool SubmintEdit()
        {
            if (ProductItem != null)
            {
                ProductItem.FName = txtFName.Text.Trim();

                //助记码
                ProductItem.FSpell = ChineseSpell.MakeSpellCode(txtFName.Text.Trim(), "",
                                                                SpellOptions.FirstLetterOnly).ToUpper();

                ProductItem.FGroupNum      = txtFGroupNum.Text.Trim();
                ProductItem.FSpec          = txtFSpec.Text.Trim();
                ProductItem.FUnit          = ddlUnit.SelectedValue.Trim();
                ProductItem.FPurchasePrice = Convert.ToDecimal(txtFPurchasePrice.Text.Trim());
                ProductItem.FSalesPrice    = Convert.ToDecimal(txtFSalesPrice.Text.Trim());
                ProductItem.FMemo          = txtFMemo.Text.Trim();//备注
                ProductItem.FCompanyId     = CurrentUser.AccountComId;
                ProductItem.FGroupNum      = txtFGroupNum.Text.Trim();
                ProductItem.FIsLiquid      = ddlFIsLiquid.SelectedValue;
                ProductItem.FPieceWork1    = 0;//Convert.ToDecimal(txtFPieceWork.Text.Trim());
                ProductItem.FQty           = Convert.ToDecimal(txtFQty.Text.Trim());
                ProductItem.FPieceWork1    = Convert.ToDecimal(txtFPieceWork1.Text.Trim());
                ProductItem.FRack          = txtFRack.Text;
                ProductItem.cinvdefine1    = txtcinvdefine1.Text.Trim();


                //  包装物问题
                if (!ddlBottleNum.SelectedValue.Equals("-1"))
                {
                    var bottle = ItemsMapBottleService.Where(p => p.FCode == ProductItem.FCode && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();
                    if (bottle != null)
                    {
                        bottle.FBottleCode = ddlBottleNum.SelectedValue;
                        bottle.FCompanyId  = CurrentUser.AccountComId;
                        ItemsMapBottleService.SaveChanges();
                    }
                    else
                    {
                        var bot = new LHItemsMapBottle
                        {
                            FCode       = ProductItem.FCode,
                            FCompanyId  = CurrentUser.AccountComId,
                            FBottleCode = ddlBottleNum.SelectedValue
                        };

                        ItemsMapBottleService.Add(bot);
                    }
                }

                return(ItemsService.SaveChanges() >= 0);
            }
            return(false);
        }