Example #1
0
        /// <summary>
        /// 修改耗材信息
        /// </summary>
        /// <param name="info">耗材信息</param>
        /// <returns>耗材id</returns>
        public int UpdateConsumable(InvConsumableInfo info)
        {
            sqlStr = "UPDATE tblInvConsumable Set ConsumableID=@ConsumableID,LotNum=@LotNum,Specification=@Specification, " +
                     " Model=@Model,SupplierID=@SupplierID,Price=@Price,ReceiveQty=@ReceiveQty,PurchaseDate=@PurchaseDate," +
                     " PurchaseID=@PurchaseID,Comments=@Comments,AvaibleQty=@AvaibleQty,UpdateDate=GetDate() " +
                     " WHERE ID = @ID";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@ID", SqlDbType.Int).Value                 = info.ID;
                command.Parameters.Add("@ConsumableID", SqlDbType.Int).Value       = SQLUtil.ConvertInt(info.Consumable.ID);
                command.Parameters.Add("@LotNum", SqlDbType.NVarChar).Value        = SQLUtil.TrimNull(info.LotNum);
                command.Parameters.Add("@Specification", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(info.Specification);
                command.Parameters.Add("@Model", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(info.Model);
                command.Parameters.Add("@SupplierID", SqlDbType.Int).Value         = SQLUtil.ConvertInt(info.Supplier.ID);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value          = info.Price;
                command.Parameters.Add("@ReceiveQty", SqlDbType.Decimal).Value     = info.ReceiveQty;
                command.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value  = SQLUtil.ConvertDateTime(info.PurchaseDate);
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value         = SQLUtil.ConvertInt(info.Purchase.ID);
                command.Parameters.Add("@AvaibleQty", SqlDbType.Decimal).Value     = info.AvaibleQty;
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value      = SQLUtil.TrimNull(info.Comments);

                command.ExecuteNonQuery();

                return(info.ID);
            }
        }
Example #2
0
        public JsonResult SaveConsumable(int userID, string sessionID, InvConsumableInfo info)
        {
            ServiceResultModel <int> result = new ServiceResultModel <int>();

            try
            {
                if (!CheckSessionID(userID, sessionID, result))
                {
                    return(MyJson(result, JsonRequestBehavior.AllowGet));
                }
                UserInfo user = null;
                if (CheckUser(userID, result, out user) == false)
                {
                    return(MyJson(result, JsonRequestBehavior.AllowGet));
                }

                if (this.invConsumableDao.CheckConsumableLotNum(info.ID, info.LotNum, info.Consumable.ID))
                {
                    result.SetFailed(ResultCodes.ParameterError, "批次号已存在");
                    return(MyJson(result, JsonRequestBehavior.AllowGet));
                }

                result.Data = this.invConsumableManager.SaveConsumable(info, user);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(MyJson(result, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public int SaveConsumable(InvConsumableInfo info, UserInfo userInfo)
        {
            if (info.ID == 0)
            {
                info.ID = this.invConsumableDao.AddConsumable(info);
            }
            else
            {
                this.invConsumableDao.UpdateConsumable(info);
            }

            return(info.ID);
        }
Example #4
0
        /// <summary>
        /// 添加采购单耗材
        /// </summary>
        /// <param name="purchaseOrderID">采购单id</param>
        /// <param name="consumableID">耗材id</param>
        public void AddConsumable(int purchaseOrderID, InvConsumableInfo consumableInfo)
        {
            sqlStr = "INSERT INTO tblPurchaseConsumable (PurchaseID,ConsumableID,Specification,Model,Price,Qty,InboundQty) " +
                     " VALUES(@PurchaseID,@ConsumableID,@Specification,@Model,@Price,@Qty,0); ";
            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value         = purchaseOrderID;
                command.Parameters.Add("@ConsumableID", SqlDbType.Int).Value       = consumableInfo.Consumable.ID;
                command.Parameters.Add("@Specification", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(consumableInfo.Specification);
                command.Parameters.Add("@Model", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(consumableInfo.Model);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value          = consumableInfo.Price;
                command.Parameters.Add("@Qty", SqlDbType.Decimal).Value            = consumableInfo.Qty;

                command.ExecuteNonQuery();
            }
        }
Example #5
0
        public JsonResult SaveConsumable(InvConsumableInfo info)
        {
            ResultModel <int> result = new ResultModel <int>();

            if (CheckSession(false) == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }
            try
            {
                result.Data = this.invConsumableManager.SaveConsumable(info, GetLoginUser());
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }
Example #6
0
        /// <summary>
        /// 添加耗材
        /// </summary>
        /// <param name="info">耗材信息</param>
        /// <returns>耗材id</returns>
        public int AddConsumable(InvConsumableInfo info)
        {
            sqlStr = "INSERT INTO tblInvConsumable(ConsumableID,LotNum,Specification,Model,SupplierID,Price,ReceiveQty,PurchaseDate,PurchaseID,AvaibleQty,Comments,AddDate) " +
                     " VALUES(@ConsumableID,@LotNum,@Specification,@Model,@SupplierID,@Price,@ReceiveQty,@PurchaseDate,@PurchaseID,@ReceiveQty,@Comments,GetDate()); " +
                     " SELECT @@IDENTITY ";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@ConsumableID", SqlDbType.Int).Value       = SQLUtil.ConvertInt(info.Consumable.ID);
                command.Parameters.Add("@LotNum", SqlDbType.NVarChar).Value        = SQLUtil.TrimNull(info.LotNum);
                command.Parameters.Add("@Specification", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(info.Specification);
                command.Parameters.Add("@Model", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(info.Model);
                command.Parameters.Add("@SupplierID", SqlDbType.Int).Value         = SQLUtil.ConvertInt(info.Supplier.ID);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value          = info.Price;
                command.Parameters.Add("@ReceiveQty", SqlDbType.Decimal).Value     = info.ReceiveQty;
                command.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value  = SQLUtil.ConvertDateTime(info.PurchaseDate);
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value         = SQLUtil.ConvertInt(info.Purchase.ID);
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value      = SQLUtil.TrimNull(info.Comments);

                info.ID = SQLUtil.ConvertInt(command.ExecuteScalar());

                return(info.ID);
            }
        }