Exemple #1
0
        /// <summary>
        /// 更新库存状态至前一状态,若前一状态为空,则更新至第三参数
        /// </summary>
        /// <param name="user"></param>
        /// <param name="stock"></param>
        /// <param name="stockStatusEnum"></param>
        /// <returns></returns>
        public ResultModel UpdateStockStatusToPrevious(UserModel user, Stock stock, StockStatusEnum stockStatusEnum)
        {
            ResultModel result = new ResultModel();

            try
            {
                string sql = string.Format("update NFMT.dbo.St_Stock set StockStatus = ISNULL(PreStatus,{0}) where StockId = {1}", (int)stockStatusEnum, stock.StockId);
                int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null);
                if (i > 0)
                {
                    result.ResultStatus = 0;
                    result.Message = "更新成功";
                    result.AffectCount = i;
                }
                else
                {
                    result.ResultStatus = -1;
                    result.Message = "更新失败";
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }
            return result;
        }
Exemple #2
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            Stock stock = new Stock();

            int indexStockId = dr.GetOrdinal("StockId");
            stock.StockId = Convert.ToInt32(dr[indexStockId]);

            int indexStockNameId = dr.GetOrdinal("StockNameId");
            if (dr["StockNameId"] != DBNull.Value)
            {
                stock.StockNameId = Convert.ToInt32(dr[indexStockNameId]);
            }

            int indexStockNo = dr.GetOrdinal("StockNo");
            if (dr["StockNo"] != DBNull.Value)
            {
                stock.StockNo = Convert.ToString(dr[indexStockNo]);
            }

            int indexStockDate = dr.GetOrdinal("StockDate");
            if (dr["StockDate"] != DBNull.Value)
            {
                stock.StockDate = Convert.ToDateTime(dr[indexStockDate]);
            }

            int indexAssetId = dr.GetOrdinal("AssetId");
            if (dr["AssetId"] != DBNull.Value)
            {
                stock.AssetId = Convert.ToInt32(dr[indexAssetId]);
            }

            int indexBundles = dr.GetOrdinal("Bundles");
            if (dr["Bundles"] != DBNull.Value)
            {
                stock.Bundles = Convert.ToInt32(dr[indexBundles]);
            }

            int indexGrossAmount = dr.GetOrdinal("GrossAmount");
            if (dr["GrossAmount"] != DBNull.Value)
            {
                stock.GrossAmount = Convert.ToDecimal(dr[indexGrossAmount]);
            }

            int indexNetAmount = dr.GetOrdinal("NetAmount");
            if (dr["NetAmount"] != DBNull.Value)
            {
                stock.NetAmount = Convert.ToDecimal(dr[indexNetAmount]);
            }

            int indexReceiptInGap = dr.GetOrdinal("ReceiptInGap");
            if (dr["ReceiptInGap"] != DBNull.Value)
            {
                stock.ReceiptInGap = Convert.ToDecimal(dr[indexReceiptInGap]);
            }

            int indexReceiptOutGap = dr.GetOrdinal("ReceiptOutGap");
            if (dr["ReceiptOutGap"] != DBNull.Value)
            {
                stock.ReceiptOutGap = Convert.ToDecimal(dr[indexReceiptOutGap]);
            }

            int indexCurGrossAmount = dr.GetOrdinal("CurGrossAmount");
            if (dr["CurGrossAmount"] != DBNull.Value)
            {
                stock.CurGrossAmount = Convert.ToDecimal(dr[indexCurGrossAmount]);
            }

            int indexCurNetAmount = dr.GetOrdinal("CurNetAmount");
            if (dr["CurNetAmount"] != DBNull.Value)
            {
                stock.CurNetAmount = Convert.ToDecimal(dr[indexCurNetAmount]);
            }

            int indexUintId = dr.GetOrdinal("UintId");
            if (dr["UintId"] != DBNull.Value)
            {
                stock.UintId = Convert.ToInt32(dr[indexUintId]);
            }

            int indexDeliverPlaceId = dr.GetOrdinal("DeliverPlaceId");
            if (dr["DeliverPlaceId"] != DBNull.Value)
            {
                stock.DeliverPlaceId = Convert.ToInt32(dr[indexDeliverPlaceId]);
            }

            int indexBrandId = dr.GetOrdinal("BrandId");
            if (dr["BrandId"] != DBNull.Value)
            {
                stock.BrandId = Convert.ToInt32(dr[indexBrandId]);
            }

            int indexCustomsType = dr.GetOrdinal("CustomsType");
            if (dr["CustomsType"] != DBNull.Value)
            {
                stock.CustomsType = Convert.ToInt32(dr[indexCustomsType]);
            }

            int indexGroupId = dr.GetOrdinal("GroupId");
            if (dr["GroupId"] != DBNull.Value)
            {
                stock.GroupId = Convert.ToInt32(dr[indexGroupId]);
            }

            int indexCorpId = dr.GetOrdinal("CorpId");
            if (dr["CorpId"] != DBNull.Value)
            {
                stock.CorpId = Convert.ToInt32(dr[indexCorpId]);
            }

            int indexDeptId = dr.GetOrdinal("DeptId");
            if (dr["DeptId"] != DBNull.Value)
            {
                stock.DeptId = Convert.ToInt32(dr[indexDeptId]);
            }

            int indexProducerId = dr.GetOrdinal("ProducerId");
            if (dr["ProducerId"] != DBNull.Value)
            {
                stock.ProducerId = Convert.ToInt32(dr[indexProducerId]);
            }

            int indexPaperNo = dr.GetOrdinal("PaperNo");
            if (dr["PaperNo"] != DBNull.Value)
            {
                stock.PaperNo = Convert.ToString(dr[indexPaperNo]);
            }

            int indexPaperHolder = dr.GetOrdinal("PaperHolder");
            if (dr["PaperHolder"] != DBNull.Value)
            {
                stock.PaperHolder = Convert.ToInt32(dr[indexPaperHolder]);
            }

            int indexFormat = dr.GetOrdinal("Format");
            if (dr["Format"] != DBNull.Value)
            {
                stock.Format = Convert.ToString(dr[indexFormat]);
            }

            int indexOriginPlaceId = dr.GetOrdinal("OriginPlaceId");
            if (dr["OriginPlaceId"] != DBNull.Value)
            {
                stock.OriginPlaceId = Convert.ToInt32(dr[indexOriginPlaceId]);
            }

            int indexOriginPlace = dr.GetOrdinal("OriginPlace");
            if (dr["OriginPlace"] != DBNull.Value)
            {
                stock.OriginPlace = Convert.ToString(dr[indexOriginPlace]);
            }

            int indexPreStatus = dr.GetOrdinal("PreStatus");
            if (dr["PreStatus"] != DBNull.Value)
            {
                stock.PreStatus = (StockStatusEnum)Convert.ToInt32(dr[indexPreStatus]);
            }

            int indexStockStatus = dr.GetOrdinal("StockStatus");
            if (dr["StockStatus"] != DBNull.Value)
            {
                stock.StockStatus = (StockStatusEnum)Convert.ToInt32(dr[indexStockStatus]);
            }

            int indexCardNo = dr.GetOrdinal("CardNo");
            if (dr["CardNo"] != DBNull.Value)
            {
                stock.CardNo = Convert.ToString(dr[indexCardNo]);
            }

            int indexMemo = dr.GetOrdinal("Memo");
            if (dr["Memo"] != DBNull.Value)
            {
                stock.Memo = Convert.ToString(dr[indexMemo]);
            }

            int indexStockType = dr.GetOrdinal("StockType");
            if (dr["StockType"] != DBNull.Value)
            {
                stock.StockType = Convert.ToInt32(dr[indexStockType]);
            }

            return stock;
        }
Exemple #3
0
        //public ResultModel UpdateStockStatus(Stock stock, StockStatusEnum stockStatus, StockStatusEnum defaultStatus)
        //{
        //    ResultModel result = new ResultModel();
        //    try
        //    {
        //        string sql = string.Format("update dbo.St_Stock set PreStatus = StockStatus ,StockStatus = {0} where StockId = {1} ", (int)stockStatus, stock.StockId);
        //        int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null);
        //        if (i > 0)
        //        {
        //            result.ResultStatus = 0;
        //            result.Message = "更新状态成功";
        //            result.AffectCount = i;
        //        }
        //        else
        //        {
        //            result.ResultStatus = -1;
        //            result.Message = "更新状态失败";
        //            result.AffectCount = i;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        result.ResultStatus = -1;
        //        result.Message = string.Format("更新状态失败,{0}", e.Message);
        //    }
        //    return result;
        //}
        /// <summary>
        /// 直接更新库存状态
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="stockStatus"></param>
        /// <returns></returns>
        public ResultModel UpdateStockStatusDirect(Stock stock, StockStatusEnum stockStatus)
        {
            ResultModel result = new ResultModel();

            try
            {
                string sql = string.Format("update dbo.St_Stock set StockStatus = {0} where StockId = {1} ", (int)stockStatus, stock.StockId);
                int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null);

                if (i > 0)
                {
                    result.ResultStatus = 0;
                    result.Message = "更新状态成功";
                    result.AffectCount = i;
                }
                else
                {
                    result.ResultStatus = -1;
                    result.Message = "更新状态失败";
                    result.AffectCount = i;
                }
            }
            catch (Exception e)
            {
                result.ResultStatus = -1;
                result.Message = string.Format("更新状态失败,{0}", e.Message);
            }

            return result;
        }
Exemple #4
0
        public ResultModel UpdateStockStatus(UserModel user, Stock stock, StockOperateEnum operate)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    ResultModel stockResult = this.Get(user, stock.StockId);
                    stock = stockResult.ReturnValue as Stock;

                    if (stock == null || stock.StockId <= 0)
                    {
                        result.Message = "库存不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    switch (operate)
                    {
                        case StockOperateEnum.出库:
                            if (stock.StockStatus != StockStatusEnum.在库正常)
                            {
                                result.Message = "非正常库存不能进行出库操作";
                                return result;
                            }
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预售库存);
                            break;
                        case StockOperateEnum.入库:
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预入库存);
                            break;
                        case StockOperateEnum.质押:
                            if (stock.StockStatus != StockStatusEnum.在库正常)
                            {
                                result.Message = "非正常库存不能进行质押操作";
                                return result;
                            }
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预押库存);
                            break;
                        case StockOperateEnum.回购:
                            if (stock.StockStatus != StockStatusEnum.质押库存)
                            {
                                result.Message = "非质押库存不能进行回购操作";
                                return result;
                            }
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预回购库存);
                            break;
                        default:
                            result.Message = "不存在库存操作类型";
                            result.ResultStatus = -1;
                            break;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }