Esempio n. 1
0
        public JsonResult SaveComponent(int userID, string sessionID, InvComponentInfo 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.invComponentDao.CheckComponentSerialCode(info.ID, info.SerialCode))
                {
                    result.SetFailed(ResultCodes.ParameterError, "序列号已存在");
                    return(MyJson(result, JsonRequestBehavior.AllowGet));
                }

                result.Data = this.invComponentManager.SaveComponent(info, user);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(MyJson(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        /// <summary>
        /// 修改零件信息
        /// </summary>
        /// <param name="info">零件信息</param>
        /// <returns>零件id</returns>
        public int UpdateComponent(InvComponentInfo info)
        {
            sqlStr = "UPDATE tblInvComponent Set ComponentID=@ComponentID,EquipmentID=@EquipmentID,SerialCode=@SerialCode,Specification=@Specification, " +
                     " Model=@Model,SupplierID=@SupplierID,Price=@Price,PurchaseDate=@PurchaseDate," +
                     " PurchaseID=@PurchaseID,Comments=@Comments,StatusID=@StatusID,UpdateDate=GetDate() " +
                     " WHERE ID = @ID";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@ID", SqlDbType.Int).Value                 = info.ID;
                command.Parameters.Add("@ComponentID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Component.ID);
                command.Parameters.Add("@EquipmentID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Equipment.ID);
                command.Parameters.Add("@SerialCode", SqlDbType.NVarChar).Value    = SQLUtil.TrimNull(info.SerialCode);
                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("@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);
                command.Parameters.Add("@StatusID", SqlDbType.Int).Value           = SQLUtil.ConvertInt(info.Status.ID);

                command.ExecuteNonQuery();

                return(info.ID);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 添加零件
        /// </summary>
        /// <param name="info">零件信息</param>
        /// <returns>零件id</returns>
        public int AddComponent(InvComponentInfo info)
        {
            sqlStr = "INSERT INTO tblInvComponent(ComponentID,EquipmentID,SerialCode,Specification,Model,SupplierID,Price,PurchaseDate,PurchaseID,Comments,StatusID,AddDate) " +
                     " VALUES(@ComponentID,@EquipmentID,@SerialCode,@Specification,@Model,@SupplierID,@Price,@PurchaseDate,@PurchaseID,@Comments,@StatusID,GetDate()); " +
                     " SELECT @@IDENTITY ";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@ComponentID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Component.ID);
                command.Parameters.Add("@EquipmentID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Equipment.ID);
                command.Parameters.Add("@SerialCode", SqlDbType.NVarChar).Value    = SQLUtil.TrimNull(info.SerialCode);
                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("@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);
                command.Parameters.Add("@StatusID", SqlDbType.Int).Value           = SQLUtil.ConvertInt(info.Status.ID);

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

                return(info.ID);
            }
        }
Esempio n. 4
0
        public int SaveComponent(InvComponentInfo info, UserInfo userInfo)
        {
            if (info.ID == 0)
            {
                info.ID = this.invComponentDao.AddComponent(info);
            }
            else
            {
                this.invComponentDao.UpdateComponent(info);
            }

            return(info.ID);
        }
Esempio n. 5
0
        /// <summary>
        /// 添加采购单零件
        /// </summary>
        /// <param name="purchaseOrderID">采购单id</param>
        /// <param name="componentID">零件id</param>
        public void AddComponent(int purchaseOrderID, InvComponentInfo componentInfo)
        {
            sqlStr = "INSERT INTO tblPurchaseComponent (PurchaseID,ComponentID,EquipmentID,Specification,Model,Price,Qty,InboundQty) " +
                     " VALUES(@PurchaseID,@ComponentID,@EquipmentID,@Specification,@Model,@Price,@Qty,0); ";
            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value         = purchaseOrderID;
                command.Parameters.Add("@EquipmentID", SqlDbType.Int).Value        = componentInfo.Equipment.ID;
                command.Parameters.Add("@ComponentID", SqlDbType.Int).Value        = componentInfo.Component.ID;
                command.Parameters.Add("@Specification", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(componentInfo.Specification);
                command.Parameters.Add("@Model", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(componentInfo.Model);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value          = componentInfo.Price;
                command.Parameters.Add("@Qty", SqlDbType.Int).Value = componentInfo.Qty;

                command.ExecuteNonQuery();
            }
        }
Esempio n. 6
0
        public JsonResult SaveComponent(InvComponentInfo 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.invComponentManager.SaveComponent(info, GetLoginUser());
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }