Example #1
0
        /// <summary>
        /// 修改服务信息
        /// </summary>
        /// <param name="info">服务信息</param>
        /// <returns>服务id</returns>
        public int UpdateService(InvServiceInfo info)
        {
            sqlStr = "UPDATE tblInvService Set FujiClass2ID=@FujiClass2ID,Name=@Name,TotalTimes=@TotalTimes,Price=@Price,StartDate=@StartDate,EndDate=@EndDate, " +
                     " SupplierID=@SupplierID,PurchaseID=@PurchaseID,PurchaseDate=@PurchaseDate,Comments=@Comments,AvaibleTimes=@AvaibleTimes,UpdateDate=GetDate() " +
                     " WHERE ID = @ID";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@ID", SqlDbType.Int).Value                = info.ID;
                command.Parameters.Add("@FujiClass2ID", SqlDbType.Int).Value      = SQLUtil.ConvertInt(info.FujiClass2.ID);
                command.Parameters.Add("@Name", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(info.Name);
                command.Parameters.Add("@TotalTimes", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.TotalTimes);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value         = info.Price;
                command.Parameters.Add("@StartDate", SqlDbType.DateTime).Value    = SQLUtil.ConvertDateTime(info.StartDate);
                command.Parameters.Add("@EndDate", SqlDbType.DateTime).Value      = SQLUtil.ConvertDateTime(info.EndDate);
                command.Parameters.Add("@SupplierID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Supplier.ID);
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Purchase.ID);
                command.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value = SQLUtil.ConvertDateTime(info.PurchaseDate);
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value     = SQLUtil.TrimNull(info.Comments);
                command.Parameters.Add("@AvaibleTimes", SqlDbType.Int).Value      = SQLUtil.ConvertInt(info.AvaibleTimes);

                command.ExecuteNonQuery();

                return(info.ID);
            }
        }
Example #2
0
        /// <summary>
        /// 添加服务
        /// </summary>
        /// <param name="info">服务信息</param>
        /// <returns>服务id</returns>
        public int AddService(InvServiceInfo info)
        {
            sqlStr = "INSERT INTO tblInvService(FujiClass2ID,Name,TotalTimes,Price,StartDate,EndDate,SupplierID,PurchaseID,PurchaseDate,Comments,AvaibleTimes,AddDate) " +
                     " VALUES(@FujiClass2ID,@Name,@TotalTimes,@Price,@StartDate,@EndDate,@SupplierID,@PurchaseID,@PurchaseDate,@Comments,@AvaibleTimes,GetDate()); " +
                     " SELECT @@IDENTITY ";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@FujiClass2ID", SqlDbType.Int).Value      = SQLUtil.ConvertInt(info.FujiClass2.ID);
                command.Parameters.Add("@Name", SqlDbType.NVarChar).Value         = SQLUtil.TrimNull(info.Name);
                command.Parameters.Add("@TotalTimes", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.TotalTimes);
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value         = info.Price;
                command.Parameters.Add("@StartDate", SqlDbType.DateTime).Value    = SQLUtil.ConvertDateTime(info.StartDate);
                command.Parameters.Add("@EndDate", SqlDbType.DateTime).Value      = SQLUtil.ConvertDateTime(info.EndDate);
                command.Parameters.Add("@SupplierID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Supplier.ID);
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value        = SQLUtil.ConvertInt(info.Purchase.ID);
                command.Parameters.Add("@PurchaseDate", SqlDbType.DateTime).Value = SQLUtil.ConvertDateTime(info.PurchaseDate);
                command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value     = SQLUtil.TrimNull(info.Comments);
                command.Parameters.Add("@AvaibleTimes", SqlDbType.Int).Value      = SQLUtil.ConvertInt(info.AvaibleTimes);

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

                return(info.ID);
            }
        }
Example #3
0
        public JsonResult SaveService(int userID, string sessionID, InvServiceInfo 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));
                }

                result.Data = this.invServiceManager.SaveService(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 #4
0
        public int SaveService(InvServiceInfo info, UserInfo userInfo)
        {
            if (info.ID == 0)
            {
                info.ID = this.invServiceDao.AddService(info);
            }
            else
            {
                this.invServiceDao.UpdateService(info);
            }

            return(info.ID);
        }
Example #5
0
        public void UpdateService(InvServiceInfo service)
        {
            sqlStr = "UPDATE tblPurchaseService Set TotalTimes = @TotalTimes " +
                     " WHERE PurchaseID = @PurchaseID AND FujiClass2ID = @FujiClass2ID AND Name = @Name ";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@TotalTimes", SqlDbType.Int).Value   = service.TotalTimes;
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value   = service.Purchase.ID;
                command.Parameters.Add("@FujiClass2ID", SqlDbType.Int).Value = service.FujiClass2.ID;
                command.Parameters.Add("@Name", SqlDbType.NVarChar).Value    = service.Name;

                command.ExecuteNonQuery();
            }
        }
Example #6
0
        /// <summary>
        /// 添加采购单服务
        /// </summary>
        /// <param name="purchaseOrderID">采购单id</param>
        /// <param name="serviceID">服务id</param>
        public void AddService(int purchaseOrderID, InvServiceInfo serviceInfo)
        {
            sqlStr = "INSERT INTO tblPurchaseService (PurchaseID,FujiClass2ID,Name,TotalTimes,Price,StartDate,EndDate) " +
                     " VALUES(@PurchaseID,@FujiClass2ID,@Name,@TotalTimes,@Price,@StartDate,@EndDate); ";
            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@PurchaseID", SqlDbType.Int).Value     = purchaseOrderID;
                command.Parameters.Add("@FujiClass2ID", SqlDbType.Int).Value   = serviceInfo.FujiClass2.ID;
                command.Parameters.Add("@Name", SqlDbType.NVarChar).Value      = SQLUtil.TrimNull(serviceInfo.Name);
                command.Parameters.Add("@TotalTimes", SqlDbType.Int).Value     = serviceInfo.TotalTimes;
                command.Parameters.Add("@Price", SqlDbType.Decimal).Value      = serviceInfo.Price;
                command.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = SQLUtil.ConvertDateTime(serviceInfo.StartDate);
                command.Parameters.Add("@EndDate", SqlDbType.DateTime).Value   = SQLUtil.ConvertDateTime(serviceInfo.EndDate);

                command.ExecuteNonQuery();
            }
        }
Example #7
0
        public JsonResult SaveService(InvServiceInfo 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.invServiceManager.SaveService(info, GetLoginUser());
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }