public ActionResult EditMaintenanceRecord(EditMaintenanceRecordModel model)
 {
     if (ModelState.IsValid)
     {
         var result = MaintenanceRecordBLL.EditMaintenanceRecord(model, base.CurrentUserID);
         base.DoLog(OperationTypeEnum.Edit, result, "MaintenanceRecordID:" + model.ID);
         return(Json(result));
     }
     else
     {
         return(PartialView("_EditMaintenanceRecord", model));
     }
 }
        public static OperationResult EditMaintenanceRecord(EditMaintenanceRecordModel model, int currentUserID)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@RecordDetails", SqlDbType.NVarChar),
                new SqlParameter("@UpdateUser", SqlDbType.Int),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime),
                new SqlParameter("@ID", SqlDbType.BigInt),
            };

            paras[0].Value = model.RecordDetails;
            paras[1].Value = currentUserID;
            paras[2].Value = DateTime.Now;
            paras[3].Value = model.ID;

            #region  SQL
            string sql = @"UPDATE   dbo.MaintenanceRecord
       SET      RecordDetails = @RecordDetails ,
                UpdateUser = @UpdateUser ,
                UpdateTime = @UpdateTime 
       WHERE    ID = @ID";
            #endregion


            int    result = MSSQLHelper.ExecuteNonQuery(CommandType.Text, sql, paras.ToArray());
            string msg    = string.Empty;
            switch (result)
            {
            case 1:
                msg = PromptInformation.OperationSuccess;
                break;

            case 0:
                msg = PromptInformation.NotExists;
                break;

            case -1:
                msg = PromptInformation.DBError;
                break;
            }
            return(new OperationResult()
            {
                Success = result > 0,
                Message = msg
            });
        }
        public static SelectResult <EditMaintenanceRecordModel> GetMaintenanceRecordByID(int id)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@ID",
                    SqlDbType     = SqlDbType.Int,
                },
            };

            paras[0].Value = id;
            string sql = @"SELECT mr.ID,mr.RecordDetails,ve.VehicleName
  FROM dbo.MaintenanceRecord mr 
  INNER JOIN dbo.Vehicles ve ON ve.ID=mr.VehicleID  
      WHERE mr.ID=@ID";

            List <EditMaintenanceRecordModel> list = ConvertToList <EditMaintenanceRecordModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras.ToArray()));

            EditMaintenanceRecordModel data = null;
            string msg = string.Empty;

            if (list == null)
            {
                msg = PromptInformation.DBError;
            }
            else if (list.Count == 0)
            {
                msg = PromptInformation.NotExists;
            }
            else
            {
                data = list[0];
            }
            return(new SelectResult <EditMaintenanceRecordModel>()
            {
                DataResult = data,
                Message = msg
            });
        }