Beispiel #1
0
        /// <summary>
        /// 新增入库货物数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool InsertEnterWarehouseBillGoods(EnterWarehouseBillGoods data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.Id),
                    MakeParam(CUSTOMERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.CustomerId),
                    MakeParam(CUSTOMERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.CustomerName),
                    MakeParam(GOODSID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.GoodsId),
                    MakeParam(GOODSNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.GoodsNo),
                    MakeParam(GOODSNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.GoodsName),
                    MakeParam(BRAND_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Brand??string.Empty),
                    MakeParam(SPECMODEL_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.SpecModel),
                    MakeParam(GWEIGHT_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.GWeight??string.Empty),
                    MakeParam(GRADE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.Grade??string.Empty),
                    MakeParam(BATCHNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.BatchNo),
                    MakeParam(PACKING_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.Packing??string.Empty),
                    MakeParam(WAREHOUSE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Warehouse),
                    MakeParam(LOCATION_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.Location??string.Empty),
                    MakeParam(PACKAGES_PARAM, SqlDbType.Int, 4, ParameterDirection.Input, (object)data.Packages),
                    MakeParam(PIECEWEIGHT_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.PieceWeight),
                    MakeParam(TUNNAGES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.Tunnages),
                    MakeParam(PILES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.Piles),
                    MakeParam(TENTHOUSANDS_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TenThousands),
                    MakeParam(PRODUCTIONDATE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.ProductionDate),
                    MakeParam(SHIPMENTBILLGOODSIDS_PARAM, SqlDbType.NVarChar, 500, ParameterDirection.Input, (object)data.ShipmentBillGoodsIds??string.Empty),
                    MakeParam(ENTERWAREHOUSEBILLID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.EnterWarehouseBillId),
                    MakeParam(DELIVERYNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DeliveryNo??string.Empty),
                    MakeParam(CREATETIME_PARAM, SqlDbType.DateTime, 8, ParameterDirection.Input, (object)data.CreateTime),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            if (Execute("InsertEnterWarehouseBillGoods", Params, out strErrText) >= 0)
                return true;
            else
                return false;
        }
Beispiel #2
0
        public ActionResult EnterWarehouse(EnterWarehouseBillViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                EnterWarehouseBill bill = new EnterWarehouseBill();
                bill.Id = model.Id;
                bill.BillNo = model.BillNo;
                bill.PlanId = model.PlanId;
                bill.CustomerId = model.CustomerId;
                bill.CustomerName = model.CustomerName;
                bill.DeliveryNo = model.DeliveryNo;
                bill.EnterType = model.EnterType;
                bill.IsConsigning = model.IsConsigning;
                bill.Warehouse = model.Warehouse;
                bill.UnloadingForceFeePrice = model.UnloadingForceFeePrice;
                bill.ForceFee = model.ForceFee;
                bill.StorageFeePrice = model.StorageFeePrice;
                bill.HasDrayage = model.HasDrayage;
                bill.Remark = model.Remark;
                bill.CreateTime = DateTime.Parse(model.CreateTime);

                List<EnterWarehouseBillGoods> listGoods = new List<EnterWarehouseBillGoods>();
                foreach (EnterWarehouseBillGoodsViewModel m in model.Goods)
                {
                    EnterWarehouseBillGoods g = new EnterWarehouseBillGoods();
                    g.Id = m.Id;
                    g.CustomerId = model.CustomerId;
                    g.CustomerName = model.CustomerName;
                    g.GoodsId = m.GoodsId;
                    g.GoodsNo = m.GoodsNo;
                    g.GoodsName = m.GoodsName;
                    g.Brand = m.Brand;
                    g.SpecModel = m.SpecModel;
                    g.GWeight = m.GWeight;
                    g.Grade = m.Grade;
                    g.BatchNo = m.BatchNo;
                    g.Packing = m.Packing;
                    g.Warehouse = model.Warehouse;
                    g.Location = m.Location;
                    g.Packages = m.Packages;
                    g.PieceWeight = m.PieceWeight;
                    g.Tunnages = m.Tunnages;
                    g.Piles = m.Piles;
                    g.TenThousands = m.TenThousands;
                    g.ProductionDate = m.ProductionDate;
                    g.ShipmentBillGoodsIds = m.ShipmentBillGoodsIds;
                    g.EnterWarehouseBillId = m.EnterWarehouseBillId;
                    g.DeliveryNo = model.DeliveryNo;
                    g.CreateTime = DateTime.Parse(model.CreateTime);
                    listGoods.Add(g);
                }

                //保存数据
                string strErrText;
                StockSystem stock = new StockSystem();
                if (bill.Id == 0)
                {
                    long nEnterWarehouseBillId = stock.InsertEnterWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText);
                    if (nEnterWarehouseBillId > 0)
                    {
                        //读取入库单号
                        bill = stock.LoadEnterWarehouseBill(nEnterWarehouseBillId, LoginAccountId, LoginStaffName, out strErrText);
                        if (bill == null)
                        {
                            var ret = new
                            {
                                EnterWarehouseBillNo = string.Empty,
                                ErrorText = strErrText
                            };
                            return Json(ret);
                        }
                        else
                        {
                            var ret = new
                            {
                                EnterWarehouseBillNo = bill.BillNo,
                                ErrorText = string.Empty
                            };
                            return Json(ret);
                        }
                    }
                    else
                    {
                        var ret = new
                        {
                            EnterWarehouseBillNo = string.Empty,
                            ErrorText = strErrText
                        };
                        return Json(ret);
                    }
                }
                else
                {
                    if (stock.UpdateEnterWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText))
                    {
                        var ret = new
                        {
                            EnterWarehouseBillNo = bill.BillNo,
                            ErrorText = string.Empty
                        };
                        return Json(ret);
                    }
                    else
                    {
                        var ret = new
                        {
                            EnterWarehouseBillNo = string.Empty,
                            ErrorText = strErrText
                        };
                        return Json(ret);
                    }
                }
            }
            return View(model);
        }