Ejemplo n.º 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    = "2001",
                FSubCateId = ProjectItem.FId,

                FCompanyId = CurrentUser.AccountComId,
                FGroupNum  = txtFGroupNum.Text,
                FMemo      = txtFMemo.Text.Trim(),
                FRack      = txtFRack.Text.Trim(),

                //单位
                FUnit          = ddlUnit.SelectedValue,
                FPurchasePrice = Convert.ToDecimal(txtFPurchasePrice.Text.Trim()),
                FSalesPrice    = Convert.ToDecimal(txtFSalesPrice.Text.Trim()),
                FPieceWork1    = Convert.ToDecimal(txtFPieceWork1.Text.Trim()),
                FPieceWork2    = Convert.ToDecimal(txtFPieceWork2.Text.Trim()),
                FPieceWork3    = Convert.ToDecimal(txtFPieceWork3.Text.Trim()),
                FPieceWork4    = Convert.ToDecimal(txtFPieceWork4.Text.Trim()),
                FPieceWork5    = Convert.ToDecimal(txtFPieceWork5.Text.Trim()),
                FNetWeight     = Convert.ToDecimal(txtFNetWeight.Text.Trim()),//重量
            };

            return(ItemsService.Add(its));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var errorRow = -1;

            try
            {
                using (var ts = new TransactionScope())
                {
                    var data = ViewState["dtData"] as DataTable;
                    if (data == null)
                    {
                        return;
                    }

                    var stringBuilder = new StringBuilder();

                    for (int i = 0; i < data.Rows.Count; i++)
                    {
                        errorRow = i + 1;

                        var item = new LHItems
                        {
                            FCode  = data.Rows[i]["商品代码"].ToString(),
                            FName  = data.Rows[i]["商品名称"].ToString(),
                            FSpec  = data.Rows[i]["规格"].ToString(),
                            FSpell = ChineseSpell.MakeSpellCode(data.Rows[i]["商品名称"].ToString(), "",
                                                                SpellOptions.FirstLetterOnly).ToUpper(),

                            //设置默认组号
                            FGroupNum      = data.Rows[i]["商品代码"].ToString(),
                            FUnit          = data.Rows[i]["计量单位"].ToString(),
                            FCateId        = "2002",
                            FSubCateId     = "2002",
                            FPurchasePrice = Convert.ToDecimal(data.Rows[i]["采购单价"]),
                            FSalesPrice    = Convert.ToDecimal(data.Rows[i]["发货单价"]),
                            FMemo          = data.Rows[i]["摘要"].ToString(),
                            FCompanyId     = CurrentUser.AccountComId,
                            FFlag          = 1
                        };

                        ItemsService.AddEntity(item);

                        //ItemsService.Add(item);
                    }

                    //写入数据库
                    ItemsService.SaveChanges();

                    ts.Complete();

                    Alert.Show("引入完成。", MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Alert.Show(string.Format(@"引入失败,请排查模版内容是否完善,出错定位行:{0} ", errorRow), MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
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));
        }